summaryrefslogtreecommitdiff
path: root/src/modlistviewactions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modlistviewactions.cpp')
-rw-r--r--src/modlistviewactions.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp
index 6faebc15..0d556e64 100644
--- a/src/modlistviewactions.cpp
+++ b/src/modlistviewactions.cpp
@@ -11,6 +11,7 @@
#include "categories.h"
#include "filedialogmemory.h"
#include "filterlist.h"
+#include "listdialog.h"
#include "modinfodialog.h"
#include "modlist.h"
#include "modlistview.h"
@@ -430,3 +431,70 @@ void ModListViewActions::displayModInformation(ModInfo::Ptr modInfo, unsigned in
}
}
}
+
+void ModListViewActions::sendModsToTop(const QModelIndexList& index) const
+{
+ m_core.modList()->changeModsPriority(index, 0);
+}
+
+void ModListViewActions::sendModsToBottom(const QModelIndexList& index) const
+{
+ m_core.modList()->changeModsPriority(index, std::numeric_limits<int>::max());
+}
+
+void ModListViewActions::sendModsToPriority(const QModelIndexList& index) const
+{
+ bool ok;
+ int priority = QInputDialog::getInt(m_view,
+ tr("Set Priority"), tr("Set the priority of the selected mods"),
+ 0, 0, std::numeric_limits<int>::max(), 1, &ok);
+ if (!ok) return;
+
+ m_core.modList()->changeModsPriority(index, priority);
+}
+
+void ModListViewActions::sendModsToSeparator(const QModelIndexList& index) const
+{
+ QStringList separators;
+ auto indexesByPriority = m_core.currentProfile()->getAllIndexesByPriority();
+ for (auto iter = indexesByPriority.begin(); iter != indexesByPriority.end(); iter++) {
+ if ((iter->second != UINT_MAX)) {
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(iter->second);
+ if (modInfo->hasFlag(ModInfo::FLAG_SEPARATOR)) {
+ separators << modInfo->name().chopped(10); // Chops the "_separator" away from the name
+ }
+ }
+ }
+
+ ListDialog dialog(m_view);
+ dialog.setWindowTitle("Select a separator...");
+ dialog.setChoices(separators);
+
+ if (dialog.exec() == QDialog::Accepted) {
+ QString result = dialog.getChoice();
+ if (!result.isEmpty()) {
+ result += "_separator";
+
+ int newPriority = std::numeric_limits<int>::max();
+ bool foundSection = false;
+ for (auto mod : m_core.modsSortedByProfilePriority(m_core.currentProfile())) {
+ unsigned int modIndex = ModInfo::getIndex(mod);
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex);
+ if (!foundSection && result.compare(mod) == 0) {
+ foundSection = true;
+ }
+ else if (foundSection && modInfo->isSeparator()) {
+ newPriority = m_core.currentProfile()->getModPriority(modIndex);
+ break;
+ }
+ }
+
+ if (index.size() == 1
+ && m_core.currentProfile()->getModPriority(index[0].data(ModList::IndexRole).toInt()) < newPriority) {
+ --newPriority;
+ }
+
+ m_core.modList()->changeModsPriority(index, newPriority);
+ }
+ }
+}