summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modlist.cpp34
-rw-r--r--src/modlist.h22
2 files changed, 31 insertions, 25 deletions
diff --git a/src/modlist.cpp b/src/modlist.cpp
index a9a4781e..c82aa802 100644
--- a/src/modlist.cpp
+++ b/src/modlist.cpp
@@ -168,6 +168,20 @@ QString ModList::getConflictFlagText(ModInfo::EConflictFlag flag, ModInfo::Ptr m
}
}
+int ModList::modPriority(unsigned int index) const
+{
+ auto info = ModInfo::getByIndex(index);
+ if (info->isBackup()) {
+ return BACKUP_PRIORITY;
+ }
+ else if (info->isOverwrite()) {
+ return OVERWRITE_PRIORITY;
+ }
+ else {
+ return m_Profile->getModPriority(index);
+ }
+}
+
QVariant ModList::data(const QModelIndex &modelIndex, int role) const
{
if (m_Profile == nullptr) return QVariant();
@@ -310,15 +324,7 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const
}
}
else if (column == COL_PRIORITY) {
- if (modInfo->isBackup()) {
- return BACKUP_PRIORITY;
- }
- else if (modInfo->isOverwrite()) {
- return OVERWRITE_PRIORITY;
- }
- else {
- return m_Profile->getModPriority(modIndex);
- }
+ return modPriority(modIndex);
}
else {
return modInfo->nexusId();
@@ -340,15 +346,7 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const
return modInfo->gameName();
}
else if (role == PriorityRole) {
- if (modInfo->isBackup()) {
- return BACKUP_PRIORITY;
- }
- else if (modInfo->isOverwrite()) {
- return OVERWRITE_PRIORITY;
- }
- else {
- return m_Profile->getModPriority(modIndex);
- }
+ return modPriority(modIndex);
}
else if (role == Qt::FontRole) {
QFont result;
diff --git a/src/modlist.h b/src/modlist.h
index 242d185f..68316613 100644
--- a/src/modlist.h
+++ b/src/modlist.h
@@ -335,6 +335,21 @@ signals:
private:
+ // the priority of backups and overwrite for sorting (and display, although
+ // those are not displayed), these do not correspond to the actual priority
+ // in the mod list
+ //
+ static constexpr int BACKUP_PRIORITY = -1;
+ static constexpr int OVERWRITE_PRIORITY = std::numeric_limits<int>::max();
+
+ // retrieve the priority of a mod for the purpose of display (i.e. sorting
+ // or grouping)
+ //
+ // this can be different from the priority in the profile (e.g. for backups
+ // or overwrite)
+ //
+ int modPriority(unsigned int index) const;
+
// retrieve the display name of a mod or convert from a user-provided
// name to internal name
//
@@ -361,13 +376,6 @@ private:
private:
- // the priority of backups and overwrite for sorting (and display, although
- // those are not displayed), these do not correspond to the actual priority
- // in the mod list
- //
- static constexpr int BACKUP_PRIORITY = -1;
- static constexpr int OVERWRITE_PRIORITY = std::numeric_limits<int>::max();
-
struct TModInfo {
TModInfo(unsigned int index, ModInfo::Ptr modInfo)
: modInfo(modInfo), nameOrder(index), priorityOrder(0), modIDOrder(0), categoryOrder(0) {}