GameList: Rename Column enum members

Remove COL_ prefix and change to TitleCase
This commit is contained in:
Dentomologist 2021-03-31 17:42:05 -07:00
parent b8bd877a41
commit 601dcfaefd
5 changed files with 103 additions and 105 deletions

View File

@ -145,7 +145,7 @@ void GameList::MakeListView()
connect(hor_header, &QHeaderView::sectionResized, this, &GameList::OnSectionResized); connect(hor_header, &QHeaderView::sectionResized, this, &GameList::OnSectionResized);
if (!Settings::GetQSettings().contains(QStringLiteral("tableheader/state"))) if (!Settings::GetQSettings().contains(QStringLiteral("tableheader/state")))
m_list->sortByColumn(static_cast<int>(GameListModel::Column::COL_TITLE), Qt::AscendingOrder); m_list->sortByColumn(static_cast<int>(GameListModel::Column::Title), Qt::AscendingOrder);
const auto SetResizeMode = [&hor_header](const GameListModel::Column column, const auto SetResizeMode = [&hor_header](const GameListModel::Column column,
const QHeaderView::ResizeMode mode) { const QHeaderView::ResizeMode mode) {
@ -154,28 +154,28 @@ void GameList::MakeListView()
{ {
using Column = GameListModel::Column; using Column = GameListModel::Column;
using Mode = QHeaderView::ResizeMode; using Mode = QHeaderView::ResizeMode;
SetResizeMode(Column::COL_PLATFORM, Mode::Fixed); SetResizeMode(Column::Platform, Mode::Fixed);
SetResizeMode(Column::COL_BANNER, Mode::Fixed); SetResizeMode(Column::Banner, Mode::Fixed);
SetResizeMode(Column::COL_TITLE, Mode::Interactive); SetResizeMode(Column::Title, Mode::Interactive);
SetResizeMode(Column::COL_DESCRIPTION, Mode::Interactive); SetResizeMode(Column::Description, Mode::Interactive);
SetResizeMode(Column::COL_MAKER, Mode::Interactive); SetResizeMode(Column::Maker, Mode::Interactive);
SetResizeMode(Column::COL_ID, Mode::Fixed); SetResizeMode(Column::ID, Mode::Fixed);
SetResizeMode(Column::COL_COUNTRY, Mode::Fixed); SetResizeMode(Column::Country, Mode::Fixed);
SetResizeMode(Column::COL_SIZE, Mode::Fixed); SetResizeMode(Column::Size, Mode::Fixed);
SetResizeMode(Column::COL_FILE_NAME, Mode::Interactive); SetResizeMode(Column::FileName, Mode::Interactive);
SetResizeMode(Column::COL_FILE_PATH, Mode::Interactive); SetResizeMode(Column::FilePath, Mode::Interactive);
SetResizeMode(Column::COL_FILE_FORMAT, Mode::Fixed); SetResizeMode(Column::FileFormat, Mode::Fixed);
SetResizeMode(Column::COL_BLOCK_SIZE, Mode::Fixed); SetResizeMode(Column::BlockSize, Mode::Fixed);
SetResizeMode(Column::COL_COMPRESSION, Mode::Fixed); SetResizeMode(Column::Compression, Mode::Fixed);
SetResizeMode(Column::COL_TAGS, Mode::Interactive); SetResizeMode(Column::Tags, Mode::Interactive);
// Cells have 3 pixels of padding, so the width of these needs to be image width + 6. Banners // 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. // are 96 pixels wide, platform and country icons are 32 pixels wide.
m_list->setColumnWidth(static_cast<int>(Column::COL_BANNER), 102); m_list->setColumnWidth(static_cast<int>(Column::Banner), 102);
m_list->setColumnWidth(static_cast<int>(Column::COL_PLATFORM), 38); m_list->setColumnWidth(static_cast<int>(Column::Platform), 38);
m_list->setColumnWidth(static_cast<int>(Column::COL_COUNTRY), 38); m_list->setColumnWidth(static_cast<int>(Column::Country), 38);
m_list->setColumnWidth(static_cast<int>(Column::COL_SIZE), 85); m_list->setColumnWidth(static_cast<int>(Column::Size), 85);
m_list->setColumnWidth(static_cast<int>(Column::COL_ID), 70); m_list->setColumnWidth(static_cast<int>(Column::ID), 70);
} }
// There's some odd platform-specific behavior with default minimum section size // There's some odd platform-specific behavior with default minimum section size
@ -206,20 +206,20 @@ void GameList::UpdateColumnVisibility()
}; };
using Column = GameListModel::Column; using Column = GameListModel::Column;
SetVisiblity(Column::COL_PLATFORM, config.m_showSystemColumn); SetVisiblity(Column::Platform, config.m_showSystemColumn);
SetVisiblity(Column::COL_BANNER, config.m_showBannerColumn); SetVisiblity(Column::Banner, config.m_showBannerColumn);
SetVisiblity(Column::COL_TITLE, config.m_showTitleColumn); SetVisiblity(Column::Title, config.m_showTitleColumn);
SetVisiblity(Column::COL_DESCRIPTION, config.m_showDescriptionColumn); SetVisiblity(Column::Description, config.m_showDescriptionColumn);
SetVisiblity(Column::COL_MAKER, config.m_showMakerColumn); SetVisiblity(Column::Maker, config.m_showMakerColumn);
SetVisiblity(Column::COL_ID, config.m_showIDColumn); SetVisiblity(Column::ID, config.m_showIDColumn);
SetVisiblity(Column::COL_COUNTRY, config.m_showRegionColumn); SetVisiblity(Column::Country, config.m_showRegionColumn);
SetVisiblity(Column::COL_SIZE, config.m_showSizeColumn); SetVisiblity(Column::Size, config.m_showSizeColumn);
SetVisiblity(Column::COL_FILE_NAME, config.m_showFileNameColumn); SetVisiblity(Column::FileName, config.m_showFileNameColumn);
SetVisiblity(Column::COL_FILE_PATH, config.m_showFilePathColumn); SetVisiblity(Column::FilePath, config.m_showFilePathColumn);
SetVisiblity(Column::COL_FILE_FORMAT, config.m_showFileFormatColumn); SetVisiblity(Column::FileFormat, config.m_showFileFormatColumn);
SetVisiblity(Column::COL_BLOCK_SIZE, config.m_showBlockSizeColumn); SetVisiblity(Column::BlockSize, config.m_showBlockSizeColumn);
SetVisiblity(Column::COL_COMPRESSION, config.m_showCompressionColumn); SetVisiblity(Column::Compression, config.m_showCompressionColumn);
SetVisiblity(Column::COL_TAGS, config.m_showTagsColumn); SetVisiblity(Column::Tags, config.m_showTagsColumn);
} }
void GameList::MakeEmptyView() void GameList::MakeEmptyView()
@ -891,20 +891,21 @@ void GameList::OnColumnVisibilityToggled(const QString& row, bool visible)
{ {
using Column = GameListModel::Column; using Column = GameListModel::Column;
static const QMap<QString, Column> rowname_to_column = { static const QMap<QString, Column> rowname_to_column = {
{tr("Platform"), Column::COL_PLATFORM}, {tr("Platform"), Column::Platform},
{tr("Banner"), Column::COL_BANNER}, {tr("Banner"), Column::Banner},
{tr("Title"), Column::COL_TITLE}, {tr("Title"), Column::Title},
{tr("Description"), Column::COL_DESCRIPTION}, {tr("Description"), Column::Description},
{tr("Maker"), Column::COL_MAKER}, {tr("Maker"), Column::Maker},
{tr("File Name"), Column::COL_FILE_NAME}, {tr("File Name"), Column::FileName},
{tr("File Path"), Column::COL_FILE_PATH}, {tr("File Path"), Column::FilePath},
{tr("Game ID"), Column::COL_ID}, {tr("Game ID"), Column::ID},
{tr("Region"), Column::COL_COUNTRY}, {tr("Region"), Column::Country},
{tr("File Size"), Column::COL_SIZE}, {tr("File Size"), Column::Size},
{tr("File Format"), Column::COL_FILE_FORMAT}, {tr("File Format"), Column::FileFormat},
{tr("Block Size"), Column::COL_BLOCK_SIZE}, {tr("Block Size"), Column::BlockSize},
{tr("Compression"), Column::COL_COMPRESSION}, {tr("Compression"), Column::Compression},
{tr("Tags"), Column::COL_TAGS}}; {tr("Tags"), Column::Tags},
};
m_list->setColumnHidden(static_cast<int>(rowname_to_column[row]), !visible); m_list->setColumnHidden(static_cast<int>(rowname_to_column[row]), !visible);
} }
@ -982,7 +983,7 @@ void GameList::OnHeaderViewChanged()
std::vector<int> candidate_columns; std::vector<int> candidate_columns;
// Iterate through all columns // Iterate through all columns
for (int i = 0; i < static_cast<int>(GameListModel::Column::NUM_COLS); i++) for (int i = 0; i < static_cast<int>(GameListModel::Column::Count); i++)
{ {
if (m_list->isColumnHidden(i)) if (m_list->isColumnHidden(i))
continue; continue;

View File

@ -61,19 +61,19 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
switch (static_cast<Column>(index.column())) switch (static_cast<Column>(index.column()))
{ {
case Column::COL_PLATFORM: case Column::Platform:
if (role == Qt::DecorationRole) if (role == Qt::DecorationRole)
return Resources::GetPlatform(game.GetPlatform()); return Resources::GetPlatform(game.GetPlatform());
if (role == SORT_ROLE) if (role == SORT_ROLE)
return static_cast<int>(game.GetPlatform()); return static_cast<int>(game.GetPlatform());
break; break;
case Column::COL_COUNTRY: case Column::Country:
if (role == Qt::DecorationRole) if (role == Qt::DecorationRole)
return Resources::GetCountry(game.GetCountry()); return Resources::GetCountry(game.GetCountry());
if (role == SORT_ROLE) if (role == SORT_ROLE)
return static_cast<int>(game.GetCountry()); return static_cast<int>(game.GetCountry());
break; break;
case Column::COL_BANNER: case Column::Banner:
if (role == Qt::DecorationRole) if (role == Qt::DecorationRole)
{ {
// GameCube banners are 96x32, but Wii banners are 192x64. // GameCube banners are 96x32, but Wii banners are 192x64.
@ -88,7 +88,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
return banner; return banner;
} }
break; break;
case Column::COL_TITLE: case Column::Title:
if (role == Qt::DisplayRole || role == SORT_ROLE) if (role == Qt::DisplayRole || role == SORT_ROLE)
{ {
QString name = QString::fromStdString(game.GetName(m_title_database)); QString name = QString::fromStdString(game.GetName(m_title_database));
@ -124,11 +124,11 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
return name; return name;
} }
break; break;
case Column::COL_ID: case Column::ID:
if (role == Qt::DisplayRole || role == SORT_ROLE) if (role == Qt::DisplayRole || role == SORT_ROLE)
return QString::fromStdString(game.GetGameID()); return QString::fromStdString(game.GetGameID());
break; break;
case Column::COL_DESCRIPTION: case Column::Description:
if (role == Qt::DisplayRole || role == SORT_ROLE) if (role == Qt::DisplayRole || role == SORT_ROLE)
{ {
return QString::fromStdString( return QString::fromStdString(
@ -136,18 +136,18 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
.replace(QLatin1Char('\n'), QLatin1Char(' ')); .replace(QLatin1Char('\n'), QLatin1Char(' '));
} }
break; break;
case Column::COL_MAKER: case Column::Maker:
if (role == Qt::DisplayRole || role == SORT_ROLE) if (role == Qt::DisplayRole || role == SORT_ROLE)
{ {
return QString::fromStdString( return QString::fromStdString(
game.GetMaker(UICommon::GameFile::Variant::LongAndPossiblyCustom)); game.GetMaker(UICommon::GameFile::Variant::LongAndPossiblyCustom));
} }
break; break;
case Column::COL_FILE_NAME: case Column::FileName:
if (role == Qt::DisplayRole || role == SORT_ROLE) if (role == Qt::DisplayRole || role == SORT_ROLE)
return QString::fromStdString(game.GetFileName()); return QString::fromStdString(game.GetFileName());
break; break;
case Column::COL_FILE_PATH: case Column::FilePath:
if (role == Qt::DisplayRole || role == SORT_ROLE) if (role == Qt::DisplayRole || role == SORT_ROLE)
{ {
QString file_path = QDir::toNativeSeparators( QString file_path = QDir::toNativeSeparators(
@ -157,7 +157,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
return file_path; return file_path;
} }
break; break;
case Column::COL_SIZE: case Column::Size:
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
{ {
std::string str = UICommon::FormatSize(game.GetFileSize()); std::string str = UICommon::FormatSize(game.GetFileSize());
@ -171,24 +171,24 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
if (role == SORT_ROLE) if (role == SORT_ROLE)
return static_cast<quint64>(game.GetFileSize()); return static_cast<quint64>(game.GetFileSize());
break; break;
case Column::COL_FILE_FORMAT: case Column::FileFormat:
if (role == Qt::DisplayRole || role == SORT_ROLE) if (role == Qt::DisplayRole || role == SORT_ROLE)
return QString::fromStdString(game.GetFileFormatName()); return QString::fromStdString(game.GetFileFormatName());
break; break;
case Column::COL_BLOCK_SIZE: case Column::BlockSize:
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
return QString::fromStdString(UICommon::FormatSize(game.GetBlockSize())); return QString::fromStdString(UICommon::FormatSize(game.GetBlockSize()));
if (role == SORT_ROLE) if (role == SORT_ROLE)
return static_cast<quint64>(game.GetBlockSize()); return static_cast<quint64>(game.GetBlockSize());
break; break;
case Column::COL_COMPRESSION: case Column::Compression:
if (role == Qt::DisplayRole || role == SORT_ROLE) if (role == Qt::DisplayRole || role == SORT_ROLE)
{ {
const QString compression = QString::fromStdString(game.GetCompressionMethod()); const QString compression = QString::fromStdString(game.GetCompressionMethod());
return compression.isEmpty() ? tr("No Compression") : compression; return compression.isEmpty() ? tr("No Compression") : compression;
} }
break; break;
case Column::COL_TAGS: case Column::Tags:
if (role == Qt::DisplayRole || role == SORT_ROLE) if (role == Qt::DisplayRole || role == SORT_ROLE)
{ {
auto tags = GetGameTags(game.GetFilePath()); auto tags = GetGameTags(game.GetFilePath());
@ -208,29 +208,29 @@ QVariant GameListModel::headerData(int section, Qt::Orientation orientation, int
switch (static_cast<Column>(section)) switch (static_cast<Column>(section))
{ {
case Column::COL_TITLE: case Column::Title:
return tr("Title"); return tr("Title");
case Column::COL_ID: case Column::ID:
return tr("ID"); return tr("ID");
case Column::COL_BANNER: case Column::Banner:
return tr("Banner"); return tr("Banner");
case Column::COL_DESCRIPTION: case Column::Description:
return tr("Description"); return tr("Description");
case Column::COL_MAKER: case Column::Maker:
return tr("Maker"); return tr("Maker");
case Column::COL_FILE_NAME: case Column::FileName:
return tr("File Name"); return tr("File Name");
case Column::COL_FILE_PATH: case Column::FilePath:
return tr("File Path"); return tr("File Path");
case Column::COL_SIZE: case Column::Size:
return tr("Size"); return tr("Size");
case Column::COL_FILE_FORMAT: case Column::FileFormat:
return tr("File Format"); return tr("File Format");
case Column::COL_BLOCK_SIZE: case Column::BlockSize:
return tr("Block Size"); return tr("Block Size");
case Column::COL_COMPRESSION: case Column::Compression:
return tr("Compression"); return tr("Compression");
case Column::COL_TAGS: case Column::Tags:
return tr("Tags"); return tr("Tags");
} }
return QVariant(); return QVariant();
@ -247,7 +247,7 @@ int GameListModel::columnCount(const QModelIndex& parent) const
{ {
if (parent.isValid()) if (parent.isValid())
return 0; return 0;
return static_cast<int>(Column::NUM_COLS); return static_cast<int>(Column::Count);
} }
bool GameListModel::ShouldDisplayGameListItem(int index) const bool GameListModel::ShouldDisplayGameListItem(int index) const

View File

@ -46,21 +46,21 @@ public:
enum class Column enum class Column
{ {
COL_PLATFORM = 0, Platform = 0,
COL_BANNER, Banner,
COL_TITLE, Title,
COL_DESCRIPTION, Description,
COL_MAKER, Maker,
COL_ID, ID,
COL_COUNTRY, Country,
COL_SIZE, Size,
COL_FILE_NAME, FileName,
COL_FILE_PATH, FilePath,
COL_FILE_FORMAT, FileFormat,
COL_BLOCK_SIZE, BlockSize,
COL_COMPRESSION, Compression,
COL_TAGS, Tags,
NUM_COLS Count,
}; };
void AddGame(const std::shared_ptr<const UICommon::GameFile>& game); void AddGame(const std::shared_ptr<const UICommon::GameFile>& game);

View File

@ -20,7 +20,7 @@ const QSize LARGE_BANNER_SIZE(144, 48);
GridProxyModel::GridProxyModel(QObject* parent) : QSortFilterProxyModel(parent) GridProxyModel::GridProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
{ {
setSortCaseSensitivity(Qt::CaseInsensitive); setSortCaseSensitivity(Qt::CaseInsensitive);
sort(static_cast<int>(GameListModel::Column::COL_TITLE)); sort(static_cast<int>(GameListModel::Column::Title));
} }
QVariant GridProxyModel::data(const QModelIndex& i, int role) const 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) if (role == Qt::DisplayRole)
{ {
return sourceModel()->data( return sourceModel()->data(
sourceModel()->index(source_index.row(), sourceModel()->index(source_index.row(), static_cast<int>(GameListModel::Column::Title)),
static_cast<int>(GameListModel::Column::COL_TITLE)),
Qt::DisplayRole); Qt::DisplayRole);
} }
else if (role == Qt::DecorationRole) else if (role == Qt::DecorationRole)
@ -46,7 +45,7 @@ QVariant GridProxyModel::data(const QModelIndex& i, int role) const
{ {
QPixmap banner = model QPixmap banner = model
->data(model->index(source_index.row(), ->data(model->index(source_index.row(),
static_cast<int>(GameListModel::Column::COL_BANNER)), static_cast<int>(GameListModel::Column::Banner)),
Qt::DecorationRole) Qt::DecorationRole)
.value<QPixmap>(); .value<QPixmap>();

View File

@ -22,14 +22,12 @@ bool ListProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right)
return QSortFilterProxyModel::lessThan(left, right); return QSortFilterProxyModel::lessThan(left, right);
// If two items are otherwise equal, compare them by their title // If two items are otherwise equal, compare them by their title
const auto right_title = const auto right_title = sourceModel()
sourceModel() ->index(right.row(), static_cast<int>(GameListModel::Column::Title))
->index(right.row(), static_cast<int>(GameListModel::Column::COL_TITLE))
.data() .data()
.toString(); .toString();
const auto left_title = const auto left_title = sourceModel()
sourceModel() ->index(left.row(), static_cast<int>(GameListModel::Column::Title))
->index(left.row(), static_cast<int>(GameListModel::Column::COL_TITLE))
.data() .data()
.toString(); .toString();