| 283 | } |
| 284 | |
| 285 | void ModListContextMenu::addSendToContextMenu() |
| 286 | { |
| 287 | static const std::vector overwritten_flags{ |
| 288 | ModInfo::EConflictFlag::FLAG_CONFLICT_MIXED, |
| 289 | ModInfo::EConflictFlag::FLAG_CONFLICT_OVERWRITTEN, |
| 290 | ModInfo::EConflictFlag::FLAG_CONFLICT_REDUNDANT}; |
| 291 | |
| 292 | static const std::vector overwrite_flags{ |
| 293 | ModInfo::EConflictFlag::FLAG_CONFLICT_MIXED, |
| 294 | ModInfo::EConflictFlag::FLAG_CONFLICT_OVERWRITE}; |
| 295 | |
| 296 | bool overwrite = false, overwritten = false; |
| 297 | for (auto& idx : m_selected) { |
| 298 | auto index = idx.data(ModList::IndexRole); |
| 299 | if (index.isValid()) { |
| 300 | auto info = ModInfo::getByIndex(index.toInt()); |
| 301 | auto flags = info->getConflictFlags(); |
| 302 | if (std::find_first_of(flags.begin(), flags.end(), overwritten_flags.begin(), |
| 303 | overwritten_flags.end()) != flags.end()) { |
| 304 | overwritten = true; |
| 305 | } |
| 306 | if (std::find_first_of(flags.begin(), flags.end(), overwrite_flags.begin(), |
| 307 | overwrite_flags.end()) != flags.end()) { |
| 308 | overwrite = true; |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | QMenu* menu = new QMenu(m_view); |
| 314 | menu->setTitle(tr("Send to... ")); |
| 315 | menu->addAction(tr("Lowest priority"), [this] { |
| 316 | m_actions.sendModsToTop(m_selected); |
| 317 | }); |
| 318 | menu->addAction(tr("Highest priority"), [this] { |
| 319 | m_actions.sendModsToBottom(m_selected); |
| 320 | }); |
| 321 | menu->addAction(tr("Priority..."), [this] { |
| 322 | m_actions.sendModsToPriority(m_selected); |
| 323 | }); |
| 324 | menu->addAction(tr("Separator..."), [this] { |
| 325 | m_actions.sendModsToSeparator(m_selected); |
| 326 | }); |
| 327 | if (overwrite) { |
| 328 | menu->addAction(tr("First conflict"), [this] { |
| 329 | m_actions.sendModsToFirstConflict(m_selected); |
| 330 | }); |
| 331 | } |
| 332 | if (overwritten) { |
| 333 | menu->addAction(tr("Last conflict"), [this] { |
| 334 | m_actions.sendModsToLastConflict(m_selected); |
| 335 | }); |
| 336 | } |
| 337 | addMenu(menu); |
| 338 | } |
| 339 | |
| 340 | void ModListContextMenu::addCategoryContextMenus(ModInfo::Ptr mod) |
| 341 | { |
nothing calls this directly
no test coverage detected