From 80f353f954519daefaa46b82184f4f7d723c05b2 Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Thu, 30 Oct 2025 00:41:39 +0300 Subject: [PATCH 1/2] [launcher] fix sorting mods by the Enabled column if both mods have the same Enabled status, then Install status is checked and the last fallback is to name sorting --- launcher/modManager/modstateitemmodel_moc.cpp | 25 +++++++++++++++++++ launcher/modManager/modstateitemmodel_moc.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/launcher/modManager/modstateitemmodel_moc.cpp b/launcher/modManager/modstateitemmodel_moc.cpp index 4ae93f6ec..abaebc7c8 100644 --- a/launcher/modManager/modstateitemmodel_moc.cpp +++ b/launcher/modManager/modstateitemmodel_moc.cpp @@ -320,6 +320,31 @@ bool CModFilterModel::filterAcceptsRow(int source_row, const QModelIndex & sourc return false; } +bool CModFilterModel::lessThan(const QModelIndex & source_left, const QModelIndex & source_right) const +{ + if(source_left.column() != ModFields::STATUS_ENABLED) + return QSortFilterProxyModel::lessThan(source_left, source_right); + + const auto leftMod = base->model->getMod(base->modIndexToName(source_left)); + const auto rightMod = base->model->getMod(base->modIndexToName(source_right)); + + const auto isLeftEnabled = base->model->isModEnabled(leftMod.getID()); + const auto isRightEnabled = base->model->isModEnabled(rightMod.getID()); + if(!isLeftEnabled && isRightEnabled) + return true; + if(isLeftEnabled && !isRightEnabled) + return false; + + const auto isLeftInstalled = leftMod.isInstalled(); + const auto isRightInstalled = rightMod.isInstalled(); + if(!isLeftInstalled && isRightInstalled) + return true; + if(isLeftInstalled && !isRightInstalled) + return false; + + return QSortFilterProxyModel::lessThan(source_left.siblingAtColumn(ModFields::NAME), source_right.siblingAtColumn(ModFields::NAME)); +} + CModFilterModel::CModFilterModel(ModStateItemModel * model, QObject * parent) : QSortFilterProxyModel(parent), base(model), filterMask(ModFilterMask::ALL) { diff --git a/launcher/modManager/modstateitemmodel_moc.h b/launcher/modManager/modstateitemmodel_moc.h index 6b0a64656..e009fa63d 100644 --- a/launcher/modManager/modstateitemmodel_moc.h +++ b/launcher/modManager/modstateitemmodel_moc.h @@ -97,6 +97,8 @@ class CModFilterModel final : public QSortFilterProxyModel bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override; + bool lessThan(const QModelIndex & source_left, const QModelIndex & source_right) const override; + public: void setTypeFilter(ModFilterMask filterMask); From 47d796b1af7bd871127f5731f162d741b00d1ac2 Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Thu, 30 Oct 2025 00:42:42 +0300 Subject: [PATCH 2/2] fix typo in enum case --- launcher/modManager/modstateitemmodel_moc.cpp | 2 +- launcher/modManager/modstateitemmodel_moc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/modManager/modstateitemmodel_moc.cpp b/launcher/modManager/modstateitemmodel_moc.cpp index abaebc7c8..7e1084983 100644 --- a/launcher/modManager/modstateitemmodel_moc.cpp +++ b/launcher/modManager/modstateitemmodel_moc.cpp @@ -276,7 +276,7 @@ bool CModFilterModel::filterMatchesCategory(const QModelIndex & source) const return !mod.isInstalled(); case ModFilterMask::INSTALLED: return mod.isInstalled(); - case ModFilterMask::UPDATEABLE: + case ModFilterMask::UPDATABLE: return mod.isUpdateAvailable(); case ModFilterMask::ENABLED: return mod.isInstalled() && base->model->isModEnabled(modID); diff --git a/launcher/modManager/modstateitemmodel_moc.h b/launcher/modManager/modstateitemmodel_moc.h index e009fa63d..29f778aa0 100644 --- a/launcher/modManager/modstateitemmodel_moc.h +++ b/launcher/modManager/modstateitemmodel_moc.h @@ -32,7 +32,7 @@ enum class ModFilterMask : uint8_t ALL, AVAILABLE, INSTALLED, - UPDATEABLE, + UPDATABLE, ENABLED, DISABLED };