summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modlistcontextmenu.cpp34
-rw-r--r--src/modlistview.cpp18
-rw-r--r--src/modlistview.h1
-rw-r--r--src/modlistviewactions.cpp25
-rw-r--r--src/modlistviewactions.h1
5 files changed, 72 insertions, 7 deletions
diff --git a/src/modlistcontextmenu.cpp b/src/modlistcontextmenu.cpp
index 97eef0eb..d8f31641 100644
--- a/src/modlistcontextmenu.cpp
+++ b/src/modlistcontextmenu.cpp
@@ -241,12 +241,38 @@ void ModListContextMenu::addMenuAsPushButton(QMenu* menu)
void ModListContextMenu::addSendToContextMenu()
{
+ static const std::vector overwritten_flags{
+ ModInfo::EConflictFlag::FLAG_CONFLICT_MIXED,
+ ModInfo::EConflictFlag::FLAG_CONFLICT_OVERWRITTEN,
+ ModInfo::EConflictFlag::FLAG_CONFLICT_REDUNDANT,
+ ModInfo::EConflictFlag::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITTEN,
+ ModInfo::EConflictFlag::FLAG_ARCHIVE_CONFLICT_OVERWRITTEN,
+ ModInfo::EConflictFlag::FLAG_ARCHIVE_CONFLICT_MIXED
+ };
+
+ bool overwritten = false;
+ for (auto& idx : m_selected) {
+ auto index = idx.data(ModList::IndexRole);
+ if (index.isValid()) {
+ auto info = ModInfo::getByIndex(index.toInt());
+ auto flags = info->getConflictFlags();
+ if (std::find_first_of(flags.begin(), flags.end(),
+ overwritten_flags.begin(), overwritten_flags.end()) != flags.end()) {
+ overwritten = true;
+ break;
+ }
+ }
+ }
+
QMenu* menu = new QMenu(m_view);
menu->setTitle(tr("Send to... "));
- menu->addAction(tr("Top"), [=]() { m_actions.sendModsToTop(m_selected); });
- menu->addAction(tr("Bottom"), [=]() { m_actions.sendModsToBottom(m_selected); });
- menu->addAction(tr("Priority..."), [=]() { m_actions.sendModsToPriority(m_selected); });
- menu->addAction(tr("Separator..."), [=]() { m_actions.sendModsToSeparator(m_selected); });
+ menu->addAction(tr("Highest priority"), [this] { m_actions.sendModsToTop(m_selected); });
+ menu->addAction(tr("Lowest priority"), [this] { m_actions.sendModsToBottom(m_selected); });
+ menu->addAction(tr("Priority..."), [this] { m_actions.sendModsToPriority(m_selected); });
+ menu->addAction(tr("Separator..."), [this] { m_actions.sendModsToSeparator(m_selected); });
+ if (overwritten) {
+ menu->addAction(tr("Last conflict"), [this] { m_actions.sendModsToLastConflict(m_selected); });
+ }
addMenu(menu);
}
diff --git a/src/modlistview.cpp b/src/modlistview.cpp
index ae905a6e..ad75631c 100644
--- a/src/modlistview.cpp
+++ b/src/modlistview.cpp
@@ -397,10 +397,22 @@ void ModListView::setSelected(const QModelIndex& current, const QModelIndexList&
void ModListView::scrollToAndSelect(const QModelIndex& index)
{
+ scrollToAndSelect(QModelIndexList{index});
+}
+
+void ModListView::scrollToAndSelect(const QModelIndexList& indexes, const QModelIndex& current)
+{
// focus, scroll to and select
- scrollTo(index);
- setCurrentIndex(index);
- selectionModel()->select(index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
+ if (!current.isValid() && indexes.isEmpty()) {
+ return;
+ }
+ scrollTo(current.isValid() ? current : indexes.first());
+ setCurrentIndex(current.isValid() ? current : indexes.first());
+ QItemSelection selection;
+ for (auto& idx : indexes) {
+ selection.select(idx, idx);
+ }
+ selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows);
QTimer::singleShot(50, [=] { setFocus(); });
}
diff --git a/src/modlistview.h b/src/modlistview.h
index 13f868c6..122bf2f1 100644
--- a/src/modlistview.h
+++ b/src/modlistview.h
@@ -89,6 +89,7 @@ public:
// focus the view, select the given index and scroll to it
//
void scrollToAndSelect(const QModelIndex& index);
+ void scrollToAndSelect(const QModelIndexList& indexes, const QModelIndex& current = QModelIndex());
// refresh the view (to call when settings have been changed)
//
diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp
index ed26faa8..ded43284 100644
--- a/src/modlistviewactions.cpp
+++ b/src/modlistviewactions.cpp
@@ -576,10 +576,35 @@ void ModListViewActions::sendModsToSeparator(const QModelIndexList& index) const
}
m_core.modList()->changeModsPriority(index, newPriority);
+ m_view->scrollToAndSelect(index.first());
}
}
}
+void ModListViewActions::sendModsToLastConflict(const QModelIndexList& indexes) const
+{
+ std::set<unsigned int> conflicts;
+
+ for (auto& idx : indexes) {
+ if (!idx.data(ModList::IndexRole).isValid()) {
+ continue;
+ }
+ auto info = ModInfo::getByIndex(idx.data(ModList::IndexRole).toInt());
+ conflicts.insert(info->getModOverwritten().begin(), info->getModOverwritten().end());
+ conflicts.insert(info->getModArchiveOverwritten().begin(), info->getModArchiveOverwritten().end());
+ conflicts.insert(info->getModArchiveLooseOverwritten().begin(), info->getModArchiveLooseOverwritten().end());
+ }
+
+ std::set<int> priorities;
+ std::transform(conflicts.begin(), conflicts.end(), std::inserter(priorities, priorities.end()), [=](auto index) {
+ return m_core.currentProfile()->getModPriority(index);
+ });
+
+ if (!priorities.empty()) {
+ m_core.modList()->changeModsPriority(indexes, *priorities.rbegin());
+ }
+}
+
void ModListViewActions::renameMod(const QModelIndex& index) const
{
try {
diff --git a/src/modlistviewactions.h b/src/modlistviewactions.h
index f1215cec..153d0d2b 100644
--- a/src/modlistviewactions.h
+++ b/src/modlistviewactions.h
@@ -62,6 +62,7 @@ public:
void sendModsToBottom(const QModelIndexList& index) const;
void sendModsToPriority(const QModelIndexList& index) const;
void sendModsToSeparator(const QModelIndexList& index) const;
+ void sendModsToLastConflict(const QModelIndexList& index) const;
// actions for most regular mods
//