@@ -134,7 +134,7 @@ const char* GameListModel::getColumnName(Column col)
134134
135135GameListModel::GameListModel (GameListWidget* parent)
136136 : QAbstractTableModel(parent), m_device_pixel_ratio(QtUtils::GetDevicePixelRatioForWidget(parent)),
137- m_memcard_pixmap_cache (MIN_COVER_CACHE_SIZE)
137+ m_icon_pixmap_cache (MIN_COVER_CACHE_SIZE)
138138{
139139 m_cover_scale = Host::GetBaseFloatSettingValue (" UI" , " GameListCoverArtScale" , 0 .45f );
140140 m_icon_size = Host::GetBaseFloatSettingValue (" UI" , " GameListIconSize" , MIN_ICON_SIZE);
@@ -171,10 +171,10 @@ void GameListModel::setShowCoverTitles(bool enabled)
171171 emit dataChanged (index (0 , Column_Cover), index (rowCount () - 1 , Column_Cover), {Qt::DisplayRole});
172172}
173173
174- int GameListModel::calculateRowHeight (const QWidget* const widget) const
174+ void GameListModel::updateRowHeight (const QWidget* const widget)
175175{
176- return m_icon_size + MEMORY_CARD_ICON_PADDING +
177- widget->style ()->pixelMetric (QStyle::PM_FocusFrameVMargin, nullptr , widget);
176+ m_row_height = m_icon_size + MEMORY_CARD_ICON_PADDING +
177+ widget->style ()->pixelMetric (QStyle::PM_FocusFrameVMargin, nullptr , widget);
178178}
179179
180180void GameListModel::setShowGameIcons (bool enabled)
@@ -188,7 +188,7 @@ void GameListModel::setShowGameIcons(bool enabled)
188188
189189void GameListModel::refreshIcons ()
190190{
191- m_memcard_pixmap_cache .Clear ();
191+ m_icon_pixmap_cache .Clear ();
192192 emit dataChanged (index (0 , Column_Icon), index (rowCount () - 1 , Column_Icon), {Qt::DecorationRole});
193193}
194194
@@ -212,6 +212,11 @@ void GameListModel::setIconSize(int size)
212212 refreshIcons ();
213213}
214214
215+ int GameListModel::getIconColumnWidth () const
216+ {
217+ return m_icon_size + MEMORY_CARD_ICON_PADDING * 2 ;
218+ }
219+
215220void GameListModel::setCoverScale (float scale)
216221{
217222 if (m_cover_scale == scale)
@@ -430,7 +435,7 @@ const QPixmap& GameListModel::getIconPixmapForEntry(const GameList::Entry* ge) c
430435 // We only do this for discs/disc sets for now.
431436 if (m_show_game_icons && (!ge->serial .empty () && (ge->IsDisc () || ge->IsDiscSet ())))
432437 {
433- QPixmap* item = m_memcard_pixmap_cache .Lookup (ge->serial );
438+ QPixmap* item = m_icon_pixmap_cache .Lookup (ge->serial );
434439 if (item)
435440 {
436441 if (!item->isNull ())
@@ -456,11 +461,11 @@ const QPixmap& GameListModel::getIconPixmapForEntry(const GameList::Entry* ge) c
456461
457462 pm.setDevicePixelRatio (m_device_pixel_ratio);
458463
459- return *m_memcard_pixmap_cache .Insert (ge->serial , std::move (pm));
464+ return *m_icon_pixmap_cache .Insert (ge->serial , std::move (pm));
460465 }
461466
462467 // Stop it trying again in the future.
463- m_memcard_pixmap_cache .Insert (ge->serial , {});
468+ m_icon_pixmap_cache .Insert (ge->serial , {});
464469 }
465470 }
466471
@@ -499,7 +504,7 @@ QIcon GameListModel::getIconForGame(const QString& path)
499504 // Provides a small performance boost when using default size icons.
500505 if (m_icon_size == MEMORY_CARD_ICON_SIZE)
501506 {
502- if (const QPixmap* pm = m_memcard_pixmap_cache .Lookup (entry->serial ))
507+ if (const QPixmap* pm = m_icon_pixmap_cache .Lookup (entry->serial ))
503508 {
504509 // If we already have the icon cached, return it.
505510 ret = QIcon (*pm);
@@ -679,6 +684,17 @@ QVariant GameListModel::data(const QModelIndex& index, int role, const GameList:
679684 return Qt::AscendingOrder;
680685 }
681686
687+ case Qt::SizeHintRole:
688+ {
689+ switch (index.column ())
690+ {
691+ case Column_Icon:
692+ return QSize (getIconColumnWidth (), m_row_height);
693+ default :
694+ return {};
695+ }
696+ }
697+
682698 case Qt::DecorationRole:
683699 {
684700 switch (index.column ())
@@ -812,7 +828,7 @@ void GameListModel::refresh()
812828 m_taken_entries.reset ();
813829
814830 // Invalidate memcard LRU cache, forcing a re-query of the memcard timestamps.
815- m_memcard_pixmap_cache .Clear ();
831+ m_icon_pixmap_cache .Clear ();
816832
817833 endResetModel ();
818834}
@@ -1695,7 +1711,9 @@ void GameListWidget::onScaleChanged()
16951711void GameListWidget::onIconSizeChanged (int size)
16961712{
16971713 // update size of rows
1698- m_list_view->verticalHeader ()->setDefaultSectionSize (m_model->calculateRowHeight (m_list_view));
1714+ m_model->updateRowHeight (m_list_view);
1715+ m_list_view->setFixedColumnWidth (GameListModel::Column_Icon, m_model->getIconColumnWidth ());
1716+ m_list_view->verticalHeader ()->setDefaultSectionSize (m_model->getRowHeight ());
16991717 onScaleChanged ();
17001718}
17011719
@@ -1760,7 +1778,6 @@ GameListListView::GameListListView(GameListModel* model, GameListSortModel* sort
17601778
17611779 horizontal_header->setSectionResizeMode (GameListModel::Column_Title, QHeaderView::Stretch);
17621780 horizontal_header->setSectionResizeMode (GameListModel::Column_FileTitle, QHeaderView::Stretch);
1763- horizontal_header->setSectionResizeMode (GameListModel::Column_Icon, QHeaderView::ResizeToContents);
17641781
17651782 verticalHeader ()->hide ();
17661783
@@ -1845,6 +1862,7 @@ void GameListListView::setFixedColumnWidths()
18451862 setFixedColumnWidth (fm, GameListModel::Column_FileSize, size_width);
18461863 setFixedColumnWidth (fm, GameListModel::Column_UncompressedSize, size_width);
18471864
1865+ setFixedColumnWidth (GameListModel::Column_Icon, m_model->getIconColumnWidth ());
18481866 setFixedColumnWidth (GameListModel::Column_Region, 55 );
18491867 setFixedColumnWidth (GameListModel::Column_Achievements, 100 );
18501868 setFixedColumnWidth (GameListModel::Column_Compatibility, 100 );
0 commit comments