diff --git a/src/duckstation-qt/gamelistmodel.cpp b/src/duckstation-qt/gamelistmodel.cpp index 0c59e4875..cd6664165 100644 --- a/src/duckstation-qt/gamelistmodel.cpp +++ b/src/duckstation-qt/gamelistmodel.cpp @@ -637,6 +637,11 @@ QVariant GameListModel::headerData(int section, Qt::Orientation orientation, int return m_column_display_names[section]; } +const GameList::Entry* GameListModel::getTakenGameListEntry(u32 index) const +{ + return (m_taken_entries.has_value() && index < m_taken_entries->size()) ? &m_taken_entries.value()[index] : nullptr; +} + bool GameListModel::hasTakenGameList() const { return m_taken_entries.has_value(); diff --git a/src/duckstation-qt/gamelistmodel.h b/src/duckstation-qt/gamelistmodel.h index cecce9675..4064ab40e 100644 --- a/src/duckstation-qt/gamelistmodel.h +++ b/src/duckstation-qt/gamelistmodel.h @@ -62,6 +62,7 @@ public: ALWAYS_INLINE const QPixmap& getHasAchievementsPixmap() const { return m_has_achievements_pixmap; } ALWAYS_INLINE const QPixmap& getMasteredAchievementsPixmap() const { return m_mastered_achievements_pixmap; } + const GameList::Entry* getTakenGameListEntry(u32 index) const; bool hasTakenGameList() const; void takeGameList(); diff --git a/src/duckstation-qt/gamelistwidget.cpp b/src/duckstation-qt/gamelistwidget.cpp index af062aa50..574ca531d 100644 --- a/src/duckstation-qt/gamelistwidget.cpp +++ b/src/duckstation-qt/gamelistwidget.cpp @@ -69,7 +69,11 @@ public: bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override { const auto lock = GameList::GetLock(); - const GameList::Entry* entry = GameList::GetEntryByIndex(source_row); + const GameList::Entry* entry = m_model->hasTakenGameList() ? + m_model->getTakenGameListEntry(static_cast(source_row)) : + GameList::GetEntryByIndex(static_cast(source_row)); + if (!entry) + return false; if (m_merge_disc_sets) { @@ -147,10 +151,8 @@ public: u32 num_unlocked_hardcore = 0; bool mastered = false; - { - const QModelIndex source_index = m_sort_model->mapToSource(index); - const auto lock = GameList::GetLock(); - const GameList::Entry* entry = GameList::GetEntryByIndex(static_cast(source_index.row())); + const auto get_data_from_entry = [&num_achievements, &num_unlocked, &num_unlocked_hardcore, + &mastered](const GameList::Entry* entry) { if (!entry) return; @@ -158,6 +160,17 @@ public: num_unlocked = entry->unlocked_achievements; num_unlocked_hardcore = entry->unlocked_achievements_hc; mastered = entry->AreAchievementsMastered(); + }; + + const QModelIndex source_index = m_sort_model->mapToSource(index); + if (m_model->hasTakenGameList()) [[unlikely]] + { + get_data_from_entry(m_model->getTakenGameListEntry(static_cast(source_index.row()))); + } + else + { + const auto lock = GameList::GetLock(); + get_data_from_entry(GameList::GetEntryByIndex(static_cast(source_index.row()))); } QRect r = option.rect;