From 0e7fed0e32cf7cd6ff342493621287e0040e51ad Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Wed, 20 Jan 2021 21:01:49 +0100 Subject: Move backup and overwrite priority to ModList. --- src/modlist.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/modlist.h') diff --git a/src/modlist.h b/src/modlist.h index 5c7f28ee..8d0a2384 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -366,10 +366,15 @@ private: // int dropPriority(int row, const QModelIndex& parent) const; -private slots: - 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::max(); + struct TModInfo { TModInfo(unsigned int index, ModInfo::Ptr modInfo) : modInfo(modInfo), nameOrder(index), priorityOrder(0), modIDOrder(0), categoryOrder(0) {} -- cgit v1.3.1 From 7c9d3777c28f79b1ae7cdbda107493493ca1ba2a Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Wed, 20 Jan 2021 21:04:49 +0100 Subject: Remove unused/undefined ModList functions. --- src/modlist.cpp | 26 -------------------------- src/modlist.h | 7 ------- 2 files changed, 33 deletions(-) (limited to 'src/modlist.h') diff --git a/src/modlist.cpp b/src/modlist.cpp index 073dbfd3..a9a4781e 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -128,32 +128,6 @@ QString ModList::makeInternalName(ModInfo::Ptr info, QString name) const return name; } -QVariant ModList::getOverwriteData(int column, int role) const -{ - switch (role) { - case Qt::DisplayRole: { - if (column == 0) { - return "Overwrite"; - } else { - return QVariant(); - } - } break; - case Qt::CheckStateRole: { - if (column == 0) { - return Qt::Checked; - } else { - return QVariant(); - } - } break; - case Qt::TextAlignmentRole: return QVariant(Qt::AlignCenter | Qt::AlignVCenter); - case GroupingRole: return -1; - case Qt::ForegroundRole: return QBrush(Qt::red); - case Qt::ToolTipRole: return tr("This entry contains files that have been created inside the virtual data tree (i.e. by the construction kit)"); - default: return QVariant(); - } -} - - QString ModList::getFlagText(ModInfo::EFlag flag, ModInfo::Ptr modInfo) const { switch (flag) { diff --git a/src/modlist.h b/src/modlist.h index 8d0a2384..242d185f 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -341,19 +341,12 @@ private: QString getDisplayName(ModInfo::Ptr info) const; QString makeInternalName(ModInfo::Ptr info, QString name) const; - QVariant getOverwriteData(int column, int role) const; - QString getFlagText(ModInfo::EFlag flag, ModInfo::Ptr modInfo) const; QString getConflictFlagText(ModInfo::EConflictFlag flag, ModInfo::Ptr modInfo) const; QString getColumnToolTip(int column) const; - ModList::EColumn getEnabledColumn(int index) const; - - QVariant categoryData(int categoryID, int column, int role) const; - QVariant modData(int modID, int modelColumn, int role) const; - bool renameMod(int index, const QString &newName); MOBase::IModList::ModStates state(unsigned int modIndex) const; -- cgit v1.3.1 From 0803920486ff62cccd79374b9b68084b880f010c Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Thu, 21 Jan 2021 19:20:24 +0100 Subject: Add method to retrieve priority of mods in ModList. --- src/modlist.cpp | 34 ++++++++++++++++------------------ src/modlist.h | 22 +++++++++++++++------- 2 files changed, 31 insertions(+), 25 deletions(-) (limited to 'src/modlist.h') 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::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::max(); - struct TModInfo { TModInfo(unsigned int index, ModInfo::Ptr modInfo) : modInfo(modInfo), nameOrder(index), priorityOrder(0), modIDOrder(0), categoryOrder(0) {} -- cgit v1.3.1 From 0a069709900fe37c265d8645554ae19e25bea06a Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Thu, 21 Jan 2021 20:21:57 +0100 Subject: Expose proper priority in ModList and sort in the sort proxy. --- src/modlist.cpp | 22 +--------------------- src/modlist.h | 15 --------------- src/modlistsortproxy.cpp | 7 ++++++- 3 files changed, 7 insertions(+), 37 deletions(-) (limited to 'src/modlist.h') diff --git a/src/modlist.cpp b/src/modlist.cpp index 5cbc6c9f..6637f48a 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -168,20 +168,6 @@ 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(); @@ -323,9 +309,6 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const return QVariant(); } } - else if (column == COL_PRIORITY) { - return modPriority(modIndex); - } else { return modInfo->nexusId(); } @@ -346,7 +329,7 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const return modInfo->gameName(); } else if (role == PriorityRole) { - return modPriority(modIndex); + return m_Profile->getModPriority(modIndex); } else if (role == Qt::FontRole) { QFont result; @@ -580,9 +563,6 @@ bool ModList::setData(const QModelIndex &index, const QVariant &value, int role) case COL_PRIORITY: { bool ok = false; int newPriority = value.toInt(&ok); - if (ok && newPriority < 0) { - newPriority = 0; - } if (ok) { changeModPriority(modID, newPriority); result = true; diff --git a/src/modlist.h b/src/modlist.h index 68316613..e201de27 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -335,21 +335,6 @@ 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::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 // diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index 18e91e6e..fc7f3270 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -215,7 +215,12 @@ bool ModListSortProxy::lessThan(const QModelIndex &left, } } break; case ModList::COL_PRIORITY: { - // nop, already compared by priority + if (leftMod->isBackup() != rightMod->isBackup()) { + lt = leftMod->isBackup(); + } + else if (leftMod->isOverwrite() != rightMod->isOverwrite()) { + lt = rightMod->isOverwrite(); + } } break; default: { log::warn("Sorting is not defined for column {}", left.column()); -- cgit v1.3.1