Skip to content

Commit

Permalink
Merge pull request #9986 from Pokechu22/partition-info
Browse files Browse the repository at this point in the history
FilesystemWidget: Show more information about partitions
  • Loading branch information
Tilka authored Aug 4, 2021
2 parents 28b7e2e + 0b86a03 commit 9c65519
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion Source/Core/DolphinQt/Config/FilesystemWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <future>

#include "Common/StringUtil.h"

#include "DiscIO/DiscExtractor.h"
#include "DiscIO/DiscUtils.h"
#include "DiscIO/Filesystem.h"
Expand Down Expand Up @@ -101,7 +103,7 @@ void FilesystemWidget::PopulateView()

for (size_t i = 0; i < partitions.size(); i++)
{
auto* item = new QStandardItem(tr("Partition %1").arg(i));
auto* item = new QStandardItem;
item->setEditable(false);

item->setIcon(Resources::GetScaledIcon("isoproperties_disc"));
Expand All @@ -123,6 +125,58 @@ void FilesystemWidget::PopulateView()
void FilesystemWidget::PopulateDirectory(int partition_id, QStandardItem* root,
const DiscIO::Partition& partition)
{
auto partition_type = m_volume->GetPartitionType(partition);
auto game_id = m_volume->GetGameID(partition);
auto title_id = m_volume->GetTitleID(partition);

QString text = root->text();

if (!text.isEmpty())
text += QStringLiteral(" - ");

if (partition_type)
{
QString partition_type_str;
switch (partition_type.value())
{
case DiscIO::PARTITION_DATA:
partition_type_str = tr("Data Partition (%1)").arg(partition_type.value());
break;
case DiscIO::PARTITION_UPDATE:
partition_type_str = tr("Update Partition (%1)").arg(partition_type.value());
break;
case DiscIO::PARTITION_CHANNEL:
partition_type_str = tr("Channel Partition (%1)").arg(partition_type.value());
break;
case DiscIO::PARTITION_INSTALL:
partition_type_str = tr("Install Partition (%1)").arg(partition_type.value());
break;
default:
partition_type_str =
tr("Other Partition (%1)").arg(partition_type.value(), 8, 16, QLatin1Char('0'));
break;
}
text += partition_type_str + QStringLiteral(" - ");
}

text += QString::fromStdString(game_id);

if (title_id)
{
text += QStringLiteral(" - %1 (").arg(title_id.value(), 16, 16, QLatin1Char('0'));
for (u32 i = 0; i < 4; i++)
{
char c = static_cast<char>(title_id.value() >> 8 * (3 - i));
if (IsPrintableCharacter(c))
text += QLatin1Char(c);
else
text += QLatin1Char('.');
}
text += QLatin1Char(')');
}

root->setText(text);

const DiscIO::FileSystem* const file_system = m_volume->GetFileSystem(partition);
if (file_system)
PopulateDirectory(partition_id, root, file_system->GetRoot());
Expand Down

0 comments on commit 9c65519

Please sign in to comment.