diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-21 19:20:24 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-21 19:20:45 +0100 |
| commit | 0803920486ff62cccd79374b9b68084b880f010c (patch) | |
| tree | 4db2f8c2388cf0ce0d8f7275da5ba5abad8ea84b | |
| parent | 7c9d3777c28f79b1ae7cdbda107493493ca1ba2a (diff) | |
Add method to retrieve priority of mods in ModList.
| -rw-r--r-- | src/modlist.cpp | 34 | ||||
| -rw-r--r-- | src/modlist.h | 22 |
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) {}
|
