diff options
| author | Al <26797547+Al12rs@users.noreply.github.com> | 2021-01-16 23:06:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-16 23:06:04 +0100 |
| commit | 2b1f01cba2a50a17db69187a1b4cbecf5a0fb65d (patch) | |
| tree | 4853e003773aea7abe9ebbe9d893ec0758bdc190 /src/modlistcontextmenu.cpp | |
| parent | 19556bc968334d8b5526ed300e537c5f6a9a5117 (diff) | |
| parent | f46962686a0648abe06bea699365740546107a70 (diff) | |
Merge pull request #1363 from Holt59/modlist-improvements
Send to last conflict
Diffstat (limited to 'src/modlistcontextmenu.cpp')
| -rw-r--r-- | src/modlistcontextmenu.cpp | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/src/modlistcontextmenu.cpp b/src/modlistcontextmenu.cpp index 4a3278eb..f4aea109 100644 --- a/src/modlistcontextmenu.cpp +++ b/src/modlistcontextmenu.cpp @@ -253,12 +253,46 @@ 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 + }; + + static const std::vector overwrite_flags{ + ModInfo::EConflictFlag::FLAG_CONFLICT_MIXED, + ModInfo::EConflictFlag::FLAG_CONFLICT_OVERWRITE + }; + + bool overwrite = false, 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; + } + if (std::find_first_of(flags.begin(), flags.end(), + overwrite_flags.begin(), overwrite_flags.end()) != flags.end()) { + overwrite = true; + } + } + } + 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("Lowest priority"), [this] { m_actions.sendModsToTop(m_selected); }); + menu->addAction(tr("Highest 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 (overwrite) { + menu->addAction(tr("First conflict"), [this] { m_actions.sendModsToFirstConflict(m_selected); }); + } + if (overwritten) { + menu->addAction(tr("Last conflict"), [this] { m_actions.sendModsToLastConflict(m_selected); }); + } addMenu(menu); } |
