From 4791569790e9695512248a9acdfbcd1c96f13967 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Wed, 27 May 2020 22:46:03 +0200 Subject: Ignore filter-only content when sorting. --- src/modlistsortproxy.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/modlistsortproxy.cpp') diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index 87db4fed..321722f5 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -22,6 +22,8 @@ along with Mod Organizer. If not, see . #include "profile.h" #include "messagedialog.h" #include "qtgroupingproxy.h" +#include "organizercore.h" + #include #include #include @@ -33,8 +35,9 @@ along with Mod Organizer. If not, see . using namespace MOBase; -ModListSortProxy::ModListSortProxy(Profile* profile, QObject *parent) - : QSortFilterProxyModel(parent) +ModListSortProxy::ModListSortProxy(Profile* profile, OrganizerCore * organizer) + : QSortFilterProxyModel(organizer) + , m_Organizer(organizer) , m_Profile(profile) , m_FilterActive(false) , m_FilterMode(FilterAnd) @@ -177,13 +180,19 @@ bool ModListSortProxy::lessThan(const QModelIndex &left, } } break; case ModList::COL_CONTENT: { + auto& lContents = leftMod->getContents(); + auto& rContents = rightMod->getContents(); unsigned int lValue = 0; unsigned int rValue = 0; - for (int content : leftMod->getContents()) { - lValue += 2U << static_cast(content); - } - for (int content : rightMod->getContents()) { - rValue += 2U << static_cast(content); + for (auto& content : m_Organizer->modDataContents()) { + if (!content.isOnlyForFilter()) { + if (std::find(std::begin(lContents), std::end(lContents), content.id()) != std::end(lContents)) { + lValue += 2U << static_cast(content.id()); + } + if (std::find(std::begin(rContents), std::end(rContents), content.id()) != std::end(rContents)) { + rValue += 2U << static_cast(content.id()); + } + } } lt = lValue < rValue; } break; -- cgit v1.3.1