From 8fafcce33f1d5633cf1cb1acbb067fd485869bbf Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 13:22:20 +0100 Subject: Add send to last conflict action for modlist. --- src/modlistcontextmenu.cpp | 34 ++++++++++++++++++++++++++++++---- src/modlistview.cpp | 18 +++++++++++++++--- src/modlistview.h | 1 + src/modlistviewactions.cpp | 25 +++++++++++++++++++++++++ src/modlistviewactions.h | 1 + 5 files changed, 72 insertions(+), 7 deletions(-) (limited to 'src') 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 @@ -396,11 +396,23 @@ 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 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 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 // -- cgit v1.3.1 From 65c9c695685b005656fd4d89b457b4d964dcf65e Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 13:29:55 +0100 Subject: Fix priority foreground color on colored separators. --- src/modlistview.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index ad75631c..3c32d02a 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -89,14 +89,13 @@ public: // but the mod list view uses alternate color so we need to find the // right color auto bg = opt.palette.base().color(); - auto vrow = (opt.rect.y() - m_view->verticalOffset()) / opt.rect.height(); - if (vrow % 2 == 1) { + if (opt.features & QStyleOptionViewItem::Alternate) { bg = opt.palette.alternateBase().color(); } // compute ideal foreground color for some rows if (color.isValid()) { - if ((index.column() == ModList::COL_NAME + if (((index.column() == ModList::COL_NAME || index.column() == ModList::COL_PRIORITY) && ModInfo::getByIndex(index.data(ModList::IndexRole).toInt())->isSeparator()) || index.column() == ModList::COL_NOTES) { -- cgit v1.3.1 From 253b5e9f3f8e544c83add9530ce5dddab0b00a9c Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 13:36:12 +0100 Subject: Fix entry names. --- src/modlistcontextmenu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/modlistcontextmenu.cpp b/src/modlistcontextmenu.cpp index d8f31641..dafffbff 100644 --- a/src/modlistcontextmenu.cpp +++ b/src/modlistcontextmenu.cpp @@ -266,8 +266,8 @@ void ModListContextMenu::addSendToContextMenu() QMenu* menu = new QMenu(m_view); menu->setTitle(tr("Send to... ")); - 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("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 (overwritten) { -- cgit v1.3.1 From a2ed9b9ba924672093f6f620cb59a54920b89c57 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 14:57:15 +0100 Subject: Fix archive overwritten marker. --- src/modlistview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 3c32d02a..94f55098 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -1095,7 +1095,7 @@ QColor ModListView::markerColor(const QModelIndex& index) const bool highligth = m_markers.highlight.find(modIndex) != m_markers.highlight.end(); bool overwrite = m_markers.overwrite.find(modIndex) != m_markers.overwrite.end(); bool archiveOverwrite = m_markers.archiveOverwrite.find(modIndex) != m_markers.archiveOverwrite.end(); - bool archiveLooseOverwrite = m_markers.archiveOverwritten.find(modIndex) != m_markers.archiveOverwritten.end(); + bool archiveLooseOverwrite = m_markers.archiveLooseOverwrite.find(modIndex) != m_markers.archiveLooseOverwrite.end(); bool overwritten = m_markers.overwritten.find(modIndex) != m_markers.overwritten.end(); bool archiveOverwritten = m_markers.archiveOverwritten.find(modIndex) != m_markers.archiveOverwritten.end(); bool archiveLooseOverwritten = m_markers.archiveLooseOverwritten.find(modIndex) != m_markers.archiveLooseOverwritten.end(); -- cgit v1.3.1 From 56d039274776078cfff0565cf66fbb0b4852f90e Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 15:01:33 +0100 Subject: Only consider loose files vs. loose files conflicts for 'Send to last conflict' entry. --- src/modlistcontextmenu.cpp | 5 +---- src/modlistviewactions.cpp | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'src') diff --git a/src/modlistcontextmenu.cpp b/src/modlistcontextmenu.cpp index dafffbff..cdadbf8a 100644 --- a/src/modlistcontextmenu.cpp +++ b/src/modlistcontextmenu.cpp @@ -244,10 +244,7 @@ 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 + ModInfo::EConflictFlag::FLAG_CONFLICT_REDUNDANT }; bool overwritten = false; diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index ded43284..097c2538 100644 --- a/src/modlistviewactions.cpp +++ b/src/modlistviewactions.cpp @@ -591,8 +591,6 @@ void ModListViewActions::sendModsToLastConflict(const QModelIndexList& indexes) } 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 priorities; -- cgit v1.3.1 From 89a735d6e11b8339b5b350d15ddd8fbfdf7998f5 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 15:55:56 +0100 Subject: Maintain selection after 'Send to... ' and add send to first conflict. --- src/modlistcontextmenu.cpp | 15 +++++++++++-- src/modlistviewactions.cpp | 52 +++++++++++++++++++++++++++++++++++----------- src/modlistviewactions.h | 6 ++++++ 3 files changed, 59 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/modlistcontextmenu.cpp b/src/modlistcontextmenu.cpp index cdadbf8a..8bc73e40 100644 --- a/src/modlistcontextmenu.cpp +++ b/src/modlistcontextmenu.cpp @@ -247,7 +247,12 @@ void ModListContextMenu::addSendToContextMenu() ModInfo::EConflictFlag::FLAG_CONFLICT_REDUNDANT }; - bool overwritten = false; + 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()) { @@ -256,7 +261,10 @@ void ModListContextMenu::addSendToContextMenu() if (std::find_first_of(flags.begin(), flags.end(), overwritten_flags.begin(), overwritten_flags.end()) != flags.end()) { overwritten = true; - break; + } + if (std::find_first_of(flags.begin(), flags.end(), + overwrite_flags.begin(), overwrite_flags.end()) != flags.end()) { + overwrite = true; } } } @@ -267,6 +275,9 @@ void ModListContextMenu::addSendToContextMenu() 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); }); } diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index 097c2538..03afa587 100644 --- a/src/modlistviewactions.cpp +++ b/src/modlistviewactions.cpp @@ -513,17 +513,24 @@ void ModListViewActions::displayModInformation(ModInfo::Ptr modInfo, unsigned in } } -void ModListViewActions::sendModsToTop(const QModelIndexList& index) const +void ModListViewActions::setModsPriority(const QModelIndexList& indexes, int priority) const { - m_core.modList()->changeModsPriority(index, 0); + auto [current, selected] = m_view->selected(); + m_core.modList()->changeModsPriority(indexes, priority); + m_view->setSelected(current, selected); } -void ModListViewActions::sendModsToBottom(const QModelIndexList& index) const +void ModListViewActions::sendModsToTop(const QModelIndexList& indexes) const { - m_core.modList()->changeModsPriority(index, std::numeric_limits::max()); + setModsPriority(indexes, 0); } -void ModListViewActions::sendModsToPriority(const QModelIndexList& index) const +void ModListViewActions::sendModsToBottom(const QModelIndexList& indexes) const +{ + setModsPriority(indexes, std::numeric_limits::max()); +} + +void ModListViewActions::sendModsToPriority(const QModelIndexList& indexes) const { bool ok; int priority = QInputDialog::getInt(m_parent, @@ -531,10 +538,10 @@ void ModListViewActions::sendModsToPriority(const QModelIndexList& index) const 0, 0, std::numeric_limits::max(), 1, &ok); if (!ok) return; - m_core.modList()->changeModsPriority(index, priority); + setModsPriority(indexes, priority); } -void ModListViewActions::sendModsToSeparator(const QModelIndexList& index) const +void ModListViewActions::sendModsToSeparator(const QModelIndexList& indexes) const { QStringList separators; auto indexesByPriority = m_core.currentProfile()->getAllIndexesByPriority(); @@ -570,14 +577,35 @@ void ModListViewActions::sendModsToSeparator(const QModelIndexList& index) const } } - if (index.size() == 1 - && m_core.currentProfile()->getModPriority(index[0].data(ModList::IndexRole).toInt()) < newPriority) { + if (indexes.size() == 1 + && m_core.currentProfile()->getModPriority(indexes[0].data(ModList::IndexRole).toInt()) < newPriority) { --newPriority; } - m_core.modList()->changeModsPriority(index, newPriority); - m_view->scrollToAndSelect(index.first()); + setModsPriority(indexes, newPriority); + } + } +} + +void ModListViewActions::sendModsToFirstConflict(const QModelIndexList& indexes) const +{ + std::set conflicts; + + for (auto& idx : indexes) { + if (!idx.data(ModList::IndexRole).isValid()) { + continue; } + auto info = ModInfo::getByIndex(idx.data(ModList::IndexRole).toInt()); + conflicts.insert(info->getModOverwrite().begin(), info->getModOverwrite().end()); + } + + std::set priorities; + std::transform(conflicts.begin(), conflicts.end(), std::inserter(priorities, priorities.end()), [=](auto index) { + return m_core.currentProfile()->getModPriority(index); + }); + + if (!priorities.empty()) { + setModsPriority(indexes, *priorities.begin()); } } @@ -599,7 +627,7 @@ void ModListViewActions::sendModsToLastConflict(const QModelIndexList& indexes) }); if (!priorities.empty()) { - m_core.modList()->changeModsPriority(indexes, *priorities.rbegin()); + setModsPriority(indexes, *priorities.rbegin()); } } diff --git a/src/modlistviewactions.h b/src/modlistviewactions.h index 153d0d2b..a3ae1b1a 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 sendModsToFirstConflict(const QModelIndexList& index) const; void sendModsToLastConflict(const QModelIndexList& index) const; // actions for most regular mods @@ -145,6 +146,11 @@ private: // void checkModsForUpdates(std::multimap const& IDs) const; + // set the priorities of the given mods while maintaining the + // mod list selection (which may be different from the list of mods) + // + void setModsPriority(const QModelIndexList& indexes, int priority) const; + private: OrganizerCore& m_core; -- cgit v1.3.1 From 54f7df9fbd8946626b974ed212b5f12dd5c28e93 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 16:14:46 +0100 Subject: Maintain selection after drag&drop. Fix update of conflicts (visual) after priority change. --- src/modlistview.cpp | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 94f55098..c40b4752 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -451,34 +451,31 @@ void ModListView::onModPrioritiesChanged(const QModelIndexList& indices) m_core->currentProfile()->writeModlist(); m_core->directoryStructure()->getFileRegister()->sortOrigins(); - { // refresh selection - QModelIndex current = currentIndex(); - if (current.isValid()) { - ModInfo::Ptr modInfo = ModInfo::getByIndex(current.data(ModList::IndexRole).toInt()); - // clear caches on all mods conflicting with the moved mod - for (int i : modInfo->getModOverwrite()) { - ModInfo::getByIndex(i)->clearCaches(); - } - for (int i : modInfo->getModOverwritten()) { - ModInfo::getByIndex(i)->clearCaches(); - } - for (int i : modInfo->getModArchiveOverwrite()) { - ModInfo::getByIndex(i)->clearCaches(); - } - for (int i : modInfo->getModArchiveOverwritten()) { - ModInfo::getByIndex(i)->clearCaches(); - } - for (int i : modInfo->getModArchiveLooseOverwrite()) { - ModInfo::getByIndex(i)->clearCaches(); - } - for (int i : modInfo->getModArchiveLooseOverwritten()) { - ModInfo::getByIndex(i)->clearCaches(); - } - // update conflict check on the moved mod - modInfo->doConflictCheck(); - setOverwriteMarkers(selectionModel()->selectedRows()); + for (auto& idx : indices) { + ModInfo::Ptr modInfo = ModInfo::getByIndex(idx.data(ModList::IndexRole).toInt()); + // clear caches on all mods conflicting with the moved mod + for (int i : modInfo->getModOverwrite()) { + ModInfo::getByIndex(i)->clearCaches(); + } + for (int i : modInfo->getModOverwritten()) { + ModInfo::getByIndex(i)->clearCaches(); + } + for (int i : modInfo->getModArchiveOverwrite()) { + ModInfo::getByIndex(i)->clearCaches(); + } + for (int i : modInfo->getModArchiveOverwritten()) { + ModInfo::getByIndex(i)->clearCaches(); + } + for (int i : modInfo->getModArchiveLooseOverwrite()) { + ModInfo::getByIndex(i)->clearCaches(); + } + for (int i : modInfo->getModArchiveLooseOverwritten()) { + ModInfo::getByIndex(i)->clearCaches(); } + // update conflict check on the moved mod + modInfo->doConflictCheck(); } + setOverwriteMarkers(selectionModel()->selectedRows()); } void ModListView::onModInstalled(const QString& modName) @@ -1349,9 +1346,11 @@ void ModListView::dropEvent(QDropEvent* event) emit dropEntered(event->mimeData(), isExpanded(index), static_cast(dropIndicatorPosition())); // see selectedIndexes() + auto [current, selected] = this->selected(); m_inDragMoveEvent = true; QTreeView::dropEvent(event); m_inDragMoveEvent = false; + setSelected(current, selected); } void ModListView::timerEvent(QTimerEvent* event) -- cgit v1.3.1 From d73d9307035ce751da442484cd6e23c8167393b7 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 16:21:59 +0100 Subject: Maintain selection when changing priority manually. --- src/modlistview.cpp | 13 +++++++++++++ src/modlistview.h | 2 ++ 2 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index c40b4752..243e78a4 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -906,6 +906,19 @@ void ModListView::drawBranches(QPainter* painter, const QRect& rect, const QMode QTreeView::drawBranches(painter, r, index); } +void ModListView::commitData(QWidget* editor) +{ + // maintain the selection when changing priority + if (currentIndex().column() == ModList::COL_PRIORITY) { + auto [current, selected] = this->selected(); + QTreeView::commitData(editor); + setSelected(current, selected); + } + else { + QTreeView::commitData(editor); + } +} + QModelIndexList ModListView::selectedIndexes() const { // during drag&drop events, we fake the return value of selectedIndexes() diff --git a/src/modlistview.h b/src/modlistview.h index 122bf2f1..39099cf7 100644 --- a/src/modlistview.h +++ b/src/modlistview.h @@ -182,6 +182,8 @@ protected slots: void onFiltersCriteria(const std::vector& filters); void onProfileChanged(Profile* oldProfile, Profile* newProfile); + void commitData(QWidget* editor) override; + private: friend class ModConflictIconDelegate; -- cgit v1.3.1 From e6d1f5500bfa41e20f12d88ab0c6d7d4717c8465 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 21:52:52 +0100 Subject: Only maintain selection after drag&drop of mods. --- src/modlistview.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 243e78a4..cb1d2842 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -1358,12 +1358,17 @@ void ModListView::dropEvent(QDropEvent* event) // is no way to deduce this except using dropIndicatorPosition()) emit dropEntered(event->mimeData(), isExpanded(index), static_cast(dropIndicatorPosition())); + ModListDropInfo dropInfo(event->mimeData(), *m_core); + // see selectedIndexes() auto [current, selected] = this->selected(); m_inDragMoveEvent = true; QTreeView::dropEvent(event); m_inDragMoveEvent = false; - setSelected(current, selected); + + if (dropInfo.isModDrop()) { + setSelected(current, selected); + } } void ModListView::timerEvent(QTimerEvent* event) -- cgit v1.3.1 From f46962686a0648abe06bea699365740546107a70 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sat, 16 Jan 2021 22:06:20 +0100 Subject: Fix drag&drop in manual installer after drag&drop of download/external archive in mod list. --- src/modlistview.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index cb1d2842..526e9c33 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -829,13 +829,16 @@ void ModListView::setup(OrganizerCore& core, CategoryFactory& factory, MainWindo // prevent the name-column from being hidden header()->setSectionHidden(ModList::COL_NAME, false); - connect(m_core->modList(), &ModList::downloadArchiveDropped, [=](int row, int priority) { + // we need QueuedConnection for the download/archive dropped otherwise the + // installation starts within the drop-event and it's not possible to drag&drop + // in the manual installer + connect(m_core->modList(), &ModList::downloadArchiveDropped, this, [=](int row, int priority) { m_core->installDownload(row, priority); - }); - connect(m_core->modList(), &ModList::externalArchiveDropped, [=](const QUrl& url, int priority) { + }, Qt::QueuedConnection); + connect(m_core->modList(), &ModList::externalArchiveDropped, this, [=](const QUrl& url, int priority) { setWindowState(Qt::WindowActive); m_core->installArchive(url.toLocalFile(), priority, false, nullptr); - }); + }, Qt::QueuedConnection); connect(m_core->modList(), &ModList::externalFolderDropped, this, &ModListView::onExternalFolderDropped); connect(selectionModel(), &QItemSelectionModel::selectionChanged, [=] { m_refreshMarkersTimer.start(); }); -- cgit v1.3.1