diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-05-27 22:46:03 +0200 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-05-27 22:46:03 +0200 |
| commit | 4791569790e9695512248a9acdfbcd1c96f13967 (patch) | |
| tree | 7b62a684d943c6ae133c95d1472e262d5e41a249 /src/modlistsortproxy.cpp | |
| parent | 700c5fb16c1c4e39fd757998e95ead4a25ecc6da (diff) | |
Ignore filter-only content when sorting.
Diffstat (limited to 'src/modlistsortproxy.cpp')
| -rw-r--r-- | src/modlistsortproxy.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
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 <http://www.gnu.org/licenses/>. #include "profile.h"
#include "messagedialog.h"
#include "qtgroupingproxy.h"
+#include "organizercore.h"
+
#include <log.h>
#include <QMenu>
#include <QCheckBox>
@@ -33,8 +35,9 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. 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<unsigned int>(content);
- }
- for (int content : rightMod->getContents()) {
- rValue += 2U << static_cast<unsigned int>(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<unsigned int>(content.id());
+ }
+ if (std::find(std::begin(rContents), std::end(rContents), content.id()) != std::end(rContents)) {
+ rValue += 2U << static_cast<unsigned int>(content.id());
+ }
+ }
}
lt = lValue < rValue;
} break;
|
