summaryrefslogtreecommitdiff
path: root/src/modlistcontextmenu.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2021-01-16 13:22:20 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-16 13:29:36 +0100
commit8fafcce33f1d5633cf1cb1acbb067fd485869bbf (patch)
tree2fdcb2fc60767cf111b0dcc4d55c9e169b35c8ca /src/modlistcontextmenu.cpp
parent899308b31d541e78a3e4395bf33cd66c5ec4f769 (diff)
Add send to last conflict action for modlist.
Diffstat (limited to 'src/modlistcontextmenu.cpp')
-rw-r--r--src/modlistcontextmenu.cpp34
1 files changed, 30 insertions, 4 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);
}