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/modlistview.cpp') 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