diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index 8fd0f0c513..969868a028 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -145,7 +145,7 @@ void GameList::MakeListView() connect(hor_header, &QHeaderView::sectionResized, this, &GameList::OnSectionResized); if (!Settings::GetQSettings().contains(QStringLiteral("tableheader/state"))) - m_list->sortByColumn(static_cast(GameListModel::Column::COL_TITLE), Qt::AscendingOrder); + m_list->sortByColumn(static_cast(GameListModel::Column::Title), Qt::AscendingOrder); const auto SetResizeMode = [&hor_header](const GameListModel::Column column, const QHeaderView::ResizeMode mode) { @@ -154,28 +154,28 @@ void GameList::MakeListView() { using Column = GameListModel::Column; using Mode = QHeaderView::ResizeMode; - SetResizeMode(Column::COL_PLATFORM, Mode::Fixed); - SetResizeMode(Column::COL_BANNER, Mode::Fixed); - SetResizeMode(Column::COL_TITLE, Mode::Interactive); - SetResizeMode(Column::COL_DESCRIPTION, Mode::Interactive); - SetResizeMode(Column::COL_MAKER, Mode::Interactive); - SetResizeMode(Column::COL_ID, Mode::Fixed); - SetResizeMode(Column::COL_COUNTRY, Mode::Fixed); - SetResizeMode(Column::COL_SIZE, Mode::Fixed); - SetResizeMode(Column::COL_FILE_NAME, Mode::Interactive); - SetResizeMode(Column::COL_FILE_PATH, Mode::Interactive); - SetResizeMode(Column::COL_FILE_FORMAT, Mode::Fixed); - SetResizeMode(Column::COL_BLOCK_SIZE, Mode::Fixed); - SetResizeMode(Column::COL_COMPRESSION, Mode::Fixed); - SetResizeMode(Column::COL_TAGS, Mode::Interactive); + SetResizeMode(Column::Platform, Mode::Fixed); + SetResizeMode(Column::Banner, Mode::Fixed); + SetResizeMode(Column::Title, Mode::Interactive); + SetResizeMode(Column::Description, Mode::Interactive); + SetResizeMode(Column::Maker, Mode::Interactive); + SetResizeMode(Column::ID, Mode::Fixed); + SetResizeMode(Column::Country, Mode::Fixed); + SetResizeMode(Column::Size, Mode::Fixed); + SetResizeMode(Column::FileName, Mode::Interactive); + SetResizeMode(Column::FilePath, Mode::Interactive); + SetResizeMode(Column::FileFormat, Mode::Fixed); + SetResizeMode(Column::BlockSize, Mode::Fixed); + SetResizeMode(Column::Compression, Mode::Fixed); + SetResizeMode(Column::Tags, Mode::Interactive); // Cells have 3 pixels of padding, so the width of these needs to be image width + 6. Banners // are 96 pixels wide, platform and country icons are 32 pixels wide. - m_list->setColumnWidth(static_cast(Column::COL_BANNER), 102); - m_list->setColumnWidth(static_cast(Column::COL_PLATFORM), 38); - m_list->setColumnWidth(static_cast(Column::COL_COUNTRY), 38); - m_list->setColumnWidth(static_cast(Column::COL_SIZE), 85); - m_list->setColumnWidth(static_cast(Column::COL_ID), 70); + m_list->setColumnWidth(static_cast(Column::Banner), 102); + m_list->setColumnWidth(static_cast(Column::Platform), 38); + m_list->setColumnWidth(static_cast(Column::Country), 38); + m_list->setColumnWidth(static_cast(Column::Size), 85); + m_list->setColumnWidth(static_cast(Column::ID), 70); } // There's some odd platform-specific behavior with default minimum section size @@ -206,20 +206,20 @@ void GameList::UpdateColumnVisibility() }; using Column = GameListModel::Column; - SetVisiblity(Column::COL_PLATFORM, config.m_showSystemColumn); - SetVisiblity(Column::COL_BANNER, config.m_showBannerColumn); - SetVisiblity(Column::COL_TITLE, config.m_showTitleColumn); - SetVisiblity(Column::COL_DESCRIPTION, config.m_showDescriptionColumn); - SetVisiblity(Column::COL_MAKER, config.m_showMakerColumn); - SetVisiblity(Column::COL_ID, config.m_showIDColumn); - SetVisiblity(Column::COL_COUNTRY, config.m_showRegionColumn); - SetVisiblity(Column::COL_SIZE, config.m_showSizeColumn); - SetVisiblity(Column::COL_FILE_NAME, config.m_showFileNameColumn); - SetVisiblity(Column::COL_FILE_PATH, config.m_showFilePathColumn); - SetVisiblity(Column::COL_FILE_FORMAT, config.m_showFileFormatColumn); - SetVisiblity(Column::COL_BLOCK_SIZE, config.m_showBlockSizeColumn); - SetVisiblity(Column::COL_COMPRESSION, config.m_showCompressionColumn); - SetVisiblity(Column::COL_TAGS, config.m_showTagsColumn); + SetVisiblity(Column::Platform, config.m_showSystemColumn); + SetVisiblity(Column::Banner, config.m_showBannerColumn); + SetVisiblity(Column::Title, config.m_showTitleColumn); + SetVisiblity(Column::Description, config.m_showDescriptionColumn); + SetVisiblity(Column::Maker, config.m_showMakerColumn); + SetVisiblity(Column::ID, config.m_showIDColumn); + SetVisiblity(Column::Country, config.m_showRegionColumn); + SetVisiblity(Column::Size, config.m_showSizeColumn); + SetVisiblity(Column::FileName, config.m_showFileNameColumn); + SetVisiblity(Column::FilePath, config.m_showFilePathColumn); + SetVisiblity(Column::FileFormat, config.m_showFileFormatColumn); + SetVisiblity(Column::BlockSize, config.m_showBlockSizeColumn); + SetVisiblity(Column::Compression, config.m_showCompressionColumn); + SetVisiblity(Column::Tags, config.m_showTagsColumn); } void GameList::MakeEmptyView() @@ -891,20 +891,21 @@ void GameList::OnColumnVisibilityToggled(const QString& row, bool visible) { using Column = GameListModel::Column; static const QMap rowname_to_column = { - {tr("Platform"), Column::COL_PLATFORM}, - {tr("Banner"), Column::COL_BANNER}, - {tr("Title"), Column::COL_TITLE}, - {tr("Description"), Column::COL_DESCRIPTION}, - {tr("Maker"), Column::COL_MAKER}, - {tr("File Name"), Column::COL_FILE_NAME}, - {tr("File Path"), Column::COL_FILE_PATH}, - {tr("Game ID"), Column::COL_ID}, - {tr("Region"), Column::COL_COUNTRY}, - {tr("File Size"), Column::COL_SIZE}, - {tr("File Format"), Column::COL_FILE_FORMAT}, - {tr("Block Size"), Column::COL_BLOCK_SIZE}, - {tr("Compression"), Column::COL_COMPRESSION}, - {tr("Tags"), Column::COL_TAGS}}; + {tr("Platform"), Column::Platform}, + {tr("Banner"), Column::Banner}, + {tr("Title"), Column::Title}, + {tr("Description"), Column::Description}, + {tr("Maker"), Column::Maker}, + {tr("File Name"), Column::FileName}, + {tr("File Path"), Column::FilePath}, + {tr("Game ID"), Column::ID}, + {tr("Region"), Column::Country}, + {tr("File Size"), Column::Size}, + {tr("File Format"), Column::FileFormat}, + {tr("Block Size"), Column::BlockSize}, + {tr("Compression"), Column::Compression}, + {tr("Tags"), Column::Tags}, + }; m_list->setColumnHidden(static_cast(rowname_to_column[row]), !visible); } @@ -982,7 +983,7 @@ void GameList::OnHeaderViewChanged() std::vector candidate_columns; // Iterate through all columns - for (int i = 0; i < static_cast(GameListModel::Column::NUM_COLS); i++) + for (int i = 0; i < static_cast(GameListModel::Column::Count); i++) { if (m_list->isColumnHidden(i)) continue; diff --git a/Source/Core/DolphinQt/GameList/GameListModel.cpp b/Source/Core/DolphinQt/GameList/GameListModel.cpp index c98a5994be..69908fef58 100644 --- a/Source/Core/DolphinQt/GameList/GameListModel.cpp +++ b/Source/Core/DolphinQt/GameList/GameListModel.cpp @@ -61,19 +61,19 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const switch (static_cast(index.column())) { - case Column::COL_PLATFORM: + case Column::Platform: if (role == Qt::DecorationRole) return Resources::GetPlatform(game.GetPlatform()); if (role == SORT_ROLE) return static_cast(game.GetPlatform()); break; - case Column::COL_COUNTRY: + case Column::Country: if (role == Qt::DecorationRole) return Resources::GetCountry(game.GetCountry()); if (role == SORT_ROLE) return static_cast(game.GetCountry()); break; - case Column::COL_BANNER: + case Column::Banner: if (role == Qt::DecorationRole) { // GameCube banners are 96x32, but Wii banners are 192x64. @@ -88,7 +88,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const return banner; } break; - case Column::COL_TITLE: + case Column::Title: if (role == Qt::DisplayRole || role == SORT_ROLE) { QString name = QString::fromStdString(game.GetName(m_title_database)); @@ -124,11 +124,11 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const return name; } break; - case Column::COL_ID: + case Column::ID: if (role == Qt::DisplayRole || role == SORT_ROLE) return QString::fromStdString(game.GetGameID()); break; - case Column::COL_DESCRIPTION: + case Column::Description: if (role == Qt::DisplayRole || role == SORT_ROLE) { return QString::fromStdString( @@ -136,18 +136,18 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const .replace(QLatin1Char('\n'), QLatin1Char(' ')); } break; - case Column::COL_MAKER: + case Column::Maker: if (role == Qt::DisplayRole || role == SORT_ROLE) { return QString::fromStdString( game.GetMaker(UICommon::GameFile::Variant::LongAndPossiblyCustom)); } break; - case Column::COL_FILE_NAME: + case Column::FileName: if (role == Qt::DisplayRole || role == SORT_ROLE) return QString::fromStdString(game.GetFileName()); break; - case Column::COL_FILE_PATH: + case Column::FilePath: if (role == Qt::DisplayRole || role == SORT_ROLE) { QString file_path = QDir::toNativeSeparators( @@ -157,7 +157,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const return file_path; } break; - case Column::COL_SIZE: + case Column::Size: if (role == Qt::DisplayRole) { std::string str = UICommon::FormatSize(game.GetFileSize()); @@ -171,24 +171,24 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const if (role == SORT_ROLE) return static_cast(game.GetFileSize()); break; - case Column::COL_FILE_FORMAT: + case Column::FileFormat: if (role == Qt::DisplayRole || role == SORT_ROLE) return QString::fromStdString(game.GetFileFormatName()); break; - case Column::COL_BLOCK_SIZE: + case Column::BlockSize: if (role == Qt::DisplayRole) return QString::fromStdString(UICommon::FormatSize(game.GetBlockSize())); if (role == SORT_ROLE) return static_cast(game.GetBlockSize()); break; - case Column::COL_COMPRESSION: + case Column::Compression: if (role == Qt::DisplayRole || role == SORT_ROLE) { const QString compression = QString::fromStdString(game.GetCompressionMethod()); return compression.isEmpty() ? tr("No Compression") : compression; } break; - case Column::COL_TAGS: + case Column::Tags: if (role == Qt::DisplayRole || role == SORT_ROLE) { auto tags = GetGameTags(game.GetFilePath()); @@ -208,29 +208,29 @@ QVariant GameListModel::headerData(int section, Qt::Orientation orientation, int switch (static_cast(section)) { - case Column::COL_TITLE: + case Column::Title: return tr("Title"); - case Column::COL_ID: + case Column::ID: return tr("ID"); - case Column::COL_BANNER: + case Column::Banner: return tr("Banner"); - case Column::COL_DESCRIPTION: + case Column::Description: return tr("Description"); - case Column::COL_MAKER: + case Column::Maker: return tr("Maker"); - case Column::COL_FILE_NAME: + case Column::FileName: return tr("File Name"); - case Column::COL_FILE_PATH: + case Column::FilePath: return tr("File Path"); - case Column::COL_SIZE: + case Column::Size: return tr("Size"); - case Column::COL_FILE_FORMAT: + case Column::FileFormat: return tr("File Format"); - case Column::COL_BLOCK_SIZE: + case Column::BlockSize: return tr("Block Size"); - case Column::COL_COMPRESSION: + case Column::Compression: return tr("Compression"); - case Column::COL_TAGS: + case Column::Tags: return tr("Tags"); } return QVariant(); @@ -247,7 +247,7 @@ int GameListModel::columnCount(const QModelIndex& parent) const { if (parent.isValid()) return 0; - return static_cast(Column::NUM_COLS); + return static_cast(Column::Count); } bool GameListModel::ShouldDisplayGameListItem(int index) const diff --git a/Source/Core/DolphinQt/GameList/GameListModel.h b/Source/Core/DolphinQt/GameList/GameListModel.h index cd726f26cd..be975cd7d7 100644 --- a/Source/Core/DolphinQt/GameList/GameListModel.h +++ b/Source/Core/DolphinQt/GameList/GameListModel.h @@ -46,21 +46,21 @@ public: enum class Column { - COL_PLATFORM = 0, - COL_BANNER, - COL_TITLE, - COL_DESCRIPTION, - COL_MAKER, - COL_ID, - COL_COUNTRY, - COL_SIZE, - COL_FILE_NAME, - COL_FILE_PATH, - COL_FILE_FORMAT, - COL_BLOCK_SIZE, - COL_COMPRESSION, - COL_TAGS, - NUM_COLS + Platform = 0, + Banner, + Title, + Description, + Maker, + ID, + Country, + Size, + FileName, + FilePath, + FileFormat, + BlockSize, + Compression, + Tags, + Count, }; void AddGame(const std::shared_ptr& game); diff --git a/Source/Core/DolphinQt/GameList/GridProxyModel.cpp b/Source/Core/DolphinQt/GameList/GridProxyModel.cpp index 504c398d1b..c29b4ee695 100644 --- a/Source/Core/DolphinQt/GameList/GridProxyModel.cpp +++ b/Source/Core/DolphinQt/GameList/GridProxyModel.cpp @@ -20,7 +20,7 @@ const QSize LARGE_BANNER_SIZE(144, 48); GridProxyModel::GridProxyModel(QObject* parent) : QSortFilterProxyModel(parent) { setSortCaseSensitivity(Qt::CaseInsensitive); - sort(static_cast(GameListModel::Column::COL_TITLE)); + sort(static_cast(GameListModel::Column::Title)); } QVariant GridProxyModel::data(const QModelIndex& i, int role) const @@ -29,8 +29,7 @@ QVariant GridProxyModel::data(const QModelIndex& i, int role) const if (role == Qt::DisplayRole) { return sourceModel()->data( - sourceModel()->index(source_index.row(), - static_cast(GameListModel::Column::COL_TITLE)), + sourceModel()->index(source_index.row(), static_cast(GameListModel::Column::Title)), Qt::DisplayRole); } else if (role == Qt::DecorationRole) @@ -46,7 +45,7 @@ QVariant GridProxyModel::data(const QModelIndex& i, int role) const { QPixmap banner = model ->data(model->index(source_index.row(), - static_cast(GameListModel::Column::COL_BANNER)), + static_cast(GameListModel::Column::Banner)), Qt::DecorationRole) .value(); diff --git a/Source/Core/DolphinQt/GameList/ListProxyModel.cpp b/Source/Core/DolphinQt/GameList/ListProxyModel.cpp index 812256bd14..00e46bcc03 100644 --- a/Source/Core/DolphinQt/GameList/ListProxyModel.cpp +++ b/Source/Core/DolphinQt/GameList/ListProxyModel.cpp @@ -22,16 +22,14 @@ bool ListProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right) return QSortFilterProxyModel::lessThan(left, right); // If two items are otherwise equal, compare them by their title - const auto right_title = - sourceModel() - ->index(right.row(), static_cast(GameListModel::Column::COL_TITLE)) - .data() - .toString(); - const auto left_title = - sourceModel() - ->index(left.row(), static_cast(GameListModel::Column::COL_TITLE)) - .data() - .toString(); + const auto right_title = sourceModel() + ->index(right.row(), static_cast(GameListModel::Column::Title)) + .data() + .toString(); + const auto left_title = sourceModel() + ->index(left.row(), static_cast(GameListModel::Column::Title)) + .data() + .toString(); if (sortOrder() == Qt::AscendingOrder) return left_title < right_title;