From 2c57899cf611056a8c5bae1f7f27c9a157df6f41 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Thu, 1 Nov 2018 17:58:49 -0500 Subject: Fix matching highlights for mod and plugin selections The selectionChanged event used before requires subtractive/additive logic to work correctly. A separate event is fired for each row and each column for each row that is selected or deselected. The previous logic assumed all of the selection was passed in at once. The logic has been changed to recalculate all highlights each time the event is fired. This is poorly optimized in regards to performance but makes the function work. --- src/pluginlist.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index d56a4bde..21e716d3 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -21,6 +21,7 @@ along with Mod Organizer. If not, see . #include "settings.h" #include "scopeguard.h" #include "modinfo.h" +#include "modlist.h" #include "viewmarkingscrollbar.h" #include #include @@ -119,14 +120,16 @@ QString PluginList::getColumnToolTip(int column) } } -void PluginList::highlightPlugins(const QItemSelection &selected, const MOShared::DirectoryEntry &directoryEntry, const Profile &profile) +void PluginList::highlightPlugins(const QItemSelectionModel *selection, const MOShared::DirectoryEntry &directoryEntry, const Profile &profile) { for (auto &esp : m_ESPs) { esp.m_ModSelected = false; } - for (QModelIndex idx : selected.indexes()) { - ModInfo::Ptr selectedMod = ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt()); - if (!selectedMod.isNull() && profile.modEnabled(idx.data(Qt::UserRole + 1).toInt())) { + for (QModelIndex idx : selection->selectedRows(ModList::COL_PRIORITY)) { + int modPriority = idx.data().toInt(); + int modIndex = profile.modIndexByPriority(modPriority); + ModInfo::Ptr selectedMod = ModInfo::getByIndex(modIndex); + if (!selectedMod.isNull() && profile.modEnabled(modIndex)) { QDir dir(selectedMod->absolutePath()); QStringList plugins = dir.entryList(QStringList() << "*.esp" << "*.esm" << "*.esl"); MOShared::FilesOrigin origin = directoryEntry.getOriginByName(selectedMod->internalName().toStdWString()); -- cgit v1.3.1