diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-22 21:18:54 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-22 21:18:54 +0100 |
| commit | 7864fc0950729621c0297389f5b47d27e4d41d8f (patch) | |
| tree | 9917895115a735af45086d52e005363f9c7a8726 /src | |
| parent | d94b7c444d02e070875026d8c037fbd9700d2ca8 (diff) | |
Use constant for minimum/maximum priorities.
Diffstat (limited to 'src')
| -rw-r--r-- | src/modlist.cpp | 5 | ||||
| -rw-r--r-- | src/modlistbypriorityproxy.cpp | 2 | ||||
| -rw-r--r-- | src/modlistviewactions.cpp | 6 | ||||
| -rw-r--r-- | src/profile.h | 12 |
4 files changed, 15 insertions, 10 deletions
diff --git a/src/modlist.cpp b/src/modlist.cpp index 13b2298f..81dc91bf 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -1023,14 +1023,11 @@ int ModList::dropPriority(int row, const QModelIndex& parent) const int newPriority = 0; { if (row < 0 || row >= rowCount()) { - newPriority = std::numeric_limits<int>::max(); + newPriority = Profile::MaximumPriority; } else { newPriority = m_Profile->getModPriority(row); } - if (newPriority == -1) { - newPriority = std::numeric_limits<int>::max(); - } } return newPriority; diff --git a/src/modlistbypriorityproxy.cpp b/src/modlistbypriorityproxy.cpp index d1d045fc..24e58ed0 100644 --- a/src/modlistbypriorityproxy.cpp +++ b/src/modlistbypriorityproxy.cpp @@ -234,7 +234,7 @@ bool ModListByPriorityProxy::canDropMimeData(const QMimeData* data, Qt::DropActi bool hasSeparator = false; unsigned int firstRowIndex = -1; - int firstRowPriority = std::numeric_limits<int>::max(); + int firstRowPriority = Profile::MaximumPriority; for (auto sourceRow : dropInfo.rows()) { hasSeparator = hasSeparator || ModInfo::getByIndex(sourceRow)->isSeparator(); if (m_sortOrder == Qt::AscendingOrder && m_profile->getModPriority(sourceRow) < firstRowPriority diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index e7e74b16..647aac0b 100644 --- a/src/modlistviewactions.cpp +++ b/src/modlistviewactions.cpp @@ -539,12 +539,12 @@ void ModListViewActions::displayModInformation(ModInfo::Ptr modInfo, unsigned in void ModListViewActions::sendModsToTop(const QModelIndexList& indexes) const { - m_core.modList()->changeModsPriority(indexes, 0); + m_core.modList()->changeModsPriority(indexes, Profile::MinimumPriority); } void ModListViewActions::sendModsToBottom(const QModelIndexList& indexes) const { - m_core.modList()->changeModsPriority(indexes, std::numeric_limits<int>::max()); + m_core.modList()->changeModsPriority(indexes, Profile::MaximumPriority); } void ModListViewActions::sendModsToPriority(const QModelIndexList& indexes) const @@ -580,7 +580,7 @@ void ModListViewActions::sendModsToSeparator(const QModelIndexList& indexes) con if (!result.isEmpty()) { result += "_separator"; - int newPriority = std::numeric_limits<int>::max(); + int newPriority = Profile::MaximumPriority; bool foundSection = false; for (auto mod : m_core.modList()->allModsByProfilePriority()) { unsigned int modIndex = ModInfo::getIndex(mod); diff --git a/src/profile.h b/src/profile.h index d1e3f104..672a2c13 100644 --- a/src/profile.h +++ b/src/profile.h @@ -52,7 +52,14 @@ class Profile : public QObject, public MOBase::IProfile public: - typedef boost::shared_ptr<Profile> Ptr; + using Ptr = boost::shared_ptr<Profile>; + +public: + + // the minimum and maximum priority achievable by mods + // + static constexpr int MinimumPriority = 0; + static constexpr int MaximumPriority = std::numeric_limits<int>::max(); public: @@ -283,7 +290,8 @@ public: // [old priority, new priority] such that no gaps are possible // // the priority is clamped in the range of valid priority (>= 0, and lower than - // the number of "regular" mods) + // the number of "regular" mods), you should use MinimumPriority or MaximumPriority + // to send a mod to the "top" or "bottom" of the priority list // // the function returns true if the priority was changed, or false if the mod // was already at the given priority (or if the priority of the mod cannot be |
