From dd98b630ea64e823c8ed717c5f8440af74a9fdb9 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 23 May 2024 12:42:50 +1000 Subject: [PATCH] GameList: Treat disc sets and discs equally when sorting --- src/core/fullscreen_ui.cpp | 6 ++++-- src/core/game_list.h | 1 + src/duckstation-qt/gamelistmodel.cpp | 8 +++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index c1b4013e7..3cd80adff 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -6085,8 +6085,10 @@ void FullscreenUI::PopulateGameListEntryList() { case 0: // Type { - if (lhs->type != rhs->type) - return reverse ? (lhs->type > rhs->type) : (lhs->type < rhs->type); + const GameList::EntryType lst = lhs->GetSortType(); + const GameList::EntryType rst = rhs->GetSortType(); + if (lst != rst) + return reverse ? (lst > rst) : (lst < rst); } break; diff --git a/src/core/game_list.h b/src/core/game_list.h index da885b5a4..f596c34ff 100644 --- a/src/core/game_list.h +++ b/src/core/game_list.h @@ -66,6 +66,7 @@ struct Entry ALWAYS_INLINE bool IsDisc() const { return (type == EntryType::Disc); } ALWAYS_INLINE bool IsDiscSet() const { return (type == EntryType::DiscSet); } + ALWAYS_INLINE EntryType GetSortType() const { return (type == EntryType::DiscSet) ? EntryType::Disc : type; } }; const char* GetEntryTypeName(EntryType type); diff --git a/src/duckstation-qt/gamelistmodel.cpp b/src/duckstation-qt/gamelistmodel.cpp index 075c3eb38..d77ef974d 100644 --- a/src/duckstation-qt/gamelistmodel.cpp +++ b/src/duckstation-qt/gamelistmodel.cpp @@ -351,7 +351,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const switch (index.column()) { case Column_Type: - return static_cast(ge->type); + return static_cast(ge->GetSortType()); case Column_Serial: return QString::fromStdString(ge->serial); @@ -494,10 +494,12 @@ bool GameListModel::lessThan(const QModelIndex& left_index, const QModelIndex& r { case Column_Type: { - if (left->type == right->type) + const GameList::EntryType lst = left->GetSortType(); + const GameList::EntryType rst = right->GetSortType(); + if (lst == rst) return titlesLessThan(left_row, right_row); - return (static_cast(left->type) < static_cast(right->type)); + return (static_cast(lst) < static_cast(rst)); } case Column_Serial: