Skip to content

Commit 4f65a68

Browse files
committed
GameList: Address review feedback for favorite indicator
1 parent d36b348 commit 4f65a68

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

pcsx2-qt/GameList/GameListModel.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <QtGui/QPainter>
1919

2020
static constexpr std::array<const char*, GameListModel::Column_Count> s_column_names = {
21-
{"Type", "Code", "Title", "File Title", "CRC", "Time Played", "Last Played", "Size", "Region", "Compatibility", "Cover", "Favorite"}};
21+
{"Type", "Code", "Favorite", "Title", "File Title", "CRC", "Time Played", "Last Played", "Size", "Region", "Compatibility", "Cover"}};
2222

2323
static constexpr int COVER_ART_WIDTH = 350;
2424
static constexpr int COVER_ART_HEIGHT = 512;
@@ -473,12 +473,7 @@ bool GameListModel::lessThan(const QModelIndex& left_index, const QModelIndex& r
473473
}
474474

475475
case Column_Favorite:
476-
{
477-
if (left->is_favorite == right->is_favorite)
478-
return titlesLessThan(left_row, right_row);
479-
480-
return left->is_favorite > right->is_favorite;
481-
}
476+
return titlesLessThan(left_row, right_row);
482477

483478
default:
484479
return false;

pcsx2-qt/GameList/GameListModel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class GameListModel final : public QAbstractTableModel
2424
{
2525
Column_Type,
2626
Column_Serial,
27+
Column_Favorite,
2728
Column_Title,
2829
Column_FileTitle,
2930
Column_CRC,
@@ -33,7 +34,6 @@ class GameListModel final : public QAbstractTableModel
3334
Column_Region,
3435
Column_Compatibility,
3536
Column_Cover,
36-
Column_Favorite,
3737

3838
Column_Count
3939
};

pcsx2-qt/GameList/GameListWidget.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static constexpr Qt::SortOrder DEFAULT_SORT_ORDER = Qt::AscendingOrder;
5252
static constexpr std::array<int, GameListModel::Column_Count> DEFAULT_COLUMN_WIDTHS = {{
5353
55, // type
5454
85, // code
55+
95, // favorite
5556
-1, // title
5657
-1, // file title
5758
75, // crc
@@ -61,7 +62,6 @@ static constexpr std::array<int, GameListModel::Column_Count> DEFAULT_COLUMN_WID
6162
60, // region
6263
120, // compatibility
6364
-1, // cover
64-
50 // favorite
6565
}};
6666
static_assert(static_cast<int>(DEFAULT_COLUMN_WIDTHS.size()) <= GameListModel::Column_Count,
6767
"Game List: More default column widths than column types.");
@@ -135,10 +135,13 @@ namespace
135135
class GameListIconStyleDelegate final : public QStyledItemDelegate
136136
{
137137
public:
138+
static constexpr int STAR_SIZE = 22;
139+
static constexpr int STAR_MARGIN = 4;
140+
138141
GameListIconStyleDelegate(QWidget* parent)
139142
: QStyledItemDelegate(parent)
140143
{
141-
m_star_pixmap = QIcon(QStringLiteral("%1/icons/star-fill.svg").arg(QtHost::GetResourcesBasePath())).pixmap(QSize(22, 22));
144+
m_star_pixmap = QIcon(QStringLiteral("%1/icons/star-fill.svg").arg(QtHost::GetResourcesBasePath())).pixmap(QSize(STAR_SIZE, STAR_SIZE));
142145
}
143146
~GameListIconStyleDelegate() = default;
144147

@@ -203,8 +206,6 @@ namespace
203206
const bool is_favorite = index.data(Qt::UserRole).toBool();
204207
if (is_favorite)
205208
{
206-
static constexpr int STAR_SIZE = 22;
207-
static constexpr int STAR_MARGIN = 4;
208209
const QPoint star_pos = rect.bottomRight() - QPoint(STAR_SIZE + STAR_MARGIN, STAR_SIZE + STAR_MARGIN);
209210
painter->drawPixmap(star_pos, m_star_pixmap);
210211
}
@@ -288,9 +289,9 @@ void GameListWidget::initialize()
288289
m_table_view->setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
289290

290291
// Custom painter to center-align DisplayRoles (icons)
291-
m_table_view->setItemDelegateForColumn(0, new GameListIconStyleDelegate(this));
292-
m_table_view->setItemDelegateForColumn(8, new GameListIconStyleDelegate(this));
293-
m_table_view->setItemDelegateForColumn(9, new GameListIconStyleDelegate(this));
292+
m_table_view->setItemDelegateForColumn(static_cast<int>(GameListModel::Column_Type), new GameListIconStyleDelegate(this));
293+
m_table_view->setItemDelegateForColumn(static_cast<int>(GameListModel::Column_Region), new GameListIconStyleDelegate(this));
294+
m_table_view->setItemDelegateForColumn(static_cast<int>(GameListModel::Column_Compatibility), new GameListIconStyleDelegate(this));
294295
m_table_view->setItemDelegateForColumn(static_cast<int>(GameListModel::Column_Favorite), new GameListIconStyleDelegate(this));
295296

296297
connect(m_table_view->selectionModel(), &QItemSelectionModel::currentChanged, this,
@@ -805,6 +806,7 @@ void GameListWidget::resizeTableViewColumnsToFit()
805806
QtUtils::ResizeColumnsForTableView(m_table_view, {
806807
DEFAULT_COLUMN_WIDTHS[GameListModel::Column_Type],
807808
DEFAULT_COLUMN_WIDTHS[GameListModel::Column_Serial],
809+
DEFAULT_COLUMN_WIDTHS[GameListModel::Column_Favorite],
808810
DEFAULT_COLUMN_WIDTHS[GameListModel::Column_Title],
809811
DEFAULT_COLUMN_WIDTHS[GameListModel::Column_FileTitle],
810812
DEFAULT_COLUMN_WIDTHS[GameListModel::Column_CRC],

0 commit comments

Comments
 (0)