summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-10-17 19:21:22 +0200
committerTannin <devnull@localhost>2013-10-17 19:21:22 +0200
commitd73b1e38c8c4dd817fc833fee44216244c87da43 (patch)
tree99ae25f71e8722fd52f57b87bf14fe4430e2eadf /src
parentb47c89661e603336abd98d5ecd0a82f6743cab18 (diff)
- mod sorting now always uses priority as secondary sorting
- added missing ipluginlist.h
Diffstat (limited to 'src')
-rw-r--r--src/modinfo.h17
-rw-r--r--src/modlistsortproxy.cpp51
2 files changed, 38 insertions, 30 deletions
diff --git a/src/modinfo.h b/src/modinfo.h
index e408e812..59030350 100644
--- a/src/modinfo.h
+++ b/src/modinfo.h
@@ -80,23 +80,6 @@ public:
ENDORSED_UNKNOWN,
ENDORSED_NEVER
};
-/*
- struct NexusFileInfo {
- NexusFileInfo(const QString &data);
- NexusFileInfo(int id, const QString &name, const QString &url, const QString &version,
- const QString &description, int category, int size)
- : id(id), name(name), url(url), version(version), description(description),
- category(category), size(size) {}
- int id;
- QString name;
- QString url;
- QString version;
- QString description;
- int category;
- int size;
-
- QString toString() const;
- };*/
public:
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp
index c7c3ab28..888ecdb8 100644
--- a/src/modlistsortproxy.cpp
+++ b/src/modlistsortproxy.cpp
@@ -137,10 +137,30 @@ bool ModListSortProxy::lessThan(const QModelIndex &left,
ModInfo::Ptr rightMod = ModInfo::getByIndex(rightIndex);
bool lt = false;
+
+ {
+ QModelIndex leftPrioIdx = left.sibling(left.row(), ModList::COL_PRIORITY);
+ QVariant leftPrio = leftPrioIdx.data();
+ if (!leftPrio.isValid()) leftPrio = left.data(Qt::UserRole);
+ QModelIndex rightPrioIdx = right.sibling(right.row(), ModList::COL_PRIORITY);
+ QVariant rightPrio = rightPrioIdx.data();
+ if (!rightPrio.isValid()) rightPrio = right.data(Qt::UserRole);
+
+ lt = leftPrio.toInt() < rightPrio.toInt();
+ }
+
switch (left.column()) {
- case ModList::COL_FLAGS: lt = leftMod->getFlags().size() < rightMod->getFlags().size(); break;
- case ModList::COL_NAME: lt = QString::compare(leftMod->name(), rightMod->name(), Qt::CaseInsensitive) < 0; break;
+ case ModList::COL_FLAGS: {
+ if (leftMod->getFlags().size() != rightMod->getFlags().size())
+ lt = leftMod->getFlags().size() < rightMod->getFlags().size();
+ } break;
+ case ModList::COL_NAME: {
+ int comp = QString::compare(leftMod->name(), rightMod->name(), Qt::CaseInsensitive);
+ if (comp != 0)
+ lt = comp < 0;
+ } break;
case ModList::COL_CATEGORY: {
+ if (leftMod->getPrimaryCategory() != rightMod->getPrimaryCategory()) {
if (leftMod->getPrimaryCategory() < 0) lt = false;
else if (rightMod->getPrimaryCategory() < 0) lt = true;
else {
@@ -153,19 +173,24 @@ bool ModListSortProxy::lessThan(const QModelIndex &left,
qCritical("failed to compare categories: %s", e.what());
}
}
- } break;
- case ModList::COL_MODID: lt = leftMod->getNexusID() < rightMod->getNexusID(); break;
- case ModList::COL_VERSION: lt = leftMod->getVersion() < rightMod->getVersion(); break;
- case ModList::COL_PRIORITY: {
- QVariant leftPrio = left.data();
- if (!leftPrio.isValid()) leftPrio = left.data(Qt::UserRole);
- QVariant rightPrio = right.data();
- if (!rightPrio.isValid()) rightPrio = right.data(Qt::UserRole);
-
- return leftPrio.toInt() < rightPrio.toInt();
+ }
+ } break;
+ case ModList::COL_MODID: {
+ if (leftMod->getNexusID() != rightMod->getNexusID())
+ lt = leftMod->getNexusID() < rightMod->getNexusID();
+ } break;
+ case ModList::COL_VERSION: {
+ if (leftMod->getVersion() != rightMod->getVersion())
+ lt = leftMod->getVersion() < rightMod->getVersion();
} break;
case ModList::COL_INSTALLTIME: {
- return left.data().toDateTime() < right.data().toDateTime();
+ QDateTime leftTime = left.data().toDateTime();
+ QDateTime rightTime = right.data().toDateTime();
+ if (leftTime != rightTime)
+ return leftTime < rightTime;
+ } break;
+ case ModList::COL_PRIORITY: {
+ // nop, already compared by priority
} break;
}
return lt;