From f8340e16201c214eef5327c4e810432e12b23805 Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> Date: Thu, 2 Jan 2025 08:52:38 +0100 Subject: Highlight mods that contain selected files in data tab (#2179) --- src/modlistview.cpp | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'src/modlistview.cpp') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 81e87c5e..8cfd8b42 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -27,9 +27,6 @@ #include "modlistversiondelegate.h" #include "modlistviewactions.h" #include "organizercore.h" -#include "shared/directoryentry.h" -#include "shared/fileentry.h" -#include "shared/filesorigin.h" using namespace MOBase; using namespace MOShared; @@ -1101,7 +1098,7 @@ void ModListView::refreshMarkersAndPlugins() setOverwriteMarkers(indexes); - // highligth plugins + // highlight plugins std::vector modIndices; for (auto& idx : indexes) { modIndices.push_back(idx.data(ModList::IndexRole).toInt()); @@ -1110,22 +1107,13 @@ void ModListView::refreshMarkersAndPlugins() ui.pluginList->verticalScrollBar()->repaint(); } -void ModListView::setHighlightedMods(const std::vector& pluginIndices) +void ModListView::setHighlightedMods(const std::set& modNames) { m_markers.highlight.clear(); - auto& directoryEntry = *m_core->directoryStructure(); - for (auto idx : pluginIndices) { - QString pluginName = m_core->pluginList()->getName(idx); - - const MOShared::FileEntryPtr fileEntry = - directoryEntry.findFile(pluginName.toStdWString()); - if (fileEntry.get() != nullptr) { - QString originName = QString::fromStdWString( - directoryEntry.getOriginByID(fileEntry->getOrigin()).getName()); - const auto index = ModInfo::getIndex(originName); - if (index != UINT_MAX) { - m_markers.highlight.insert(index); - } + for (const auto& modName : modNames) { + const auto index = ModInfo::getIndex(modName); + if (index != UINT_MAX) { + m_markers.highlight.insert(index); } } dataChanged(model()->index(0, 0), @@ -1136,7 +1124,7 @@ void ModListView::setHighlightedMods(const std::vector& pluginIndi QColor ModListView::markerColor(const QModelIndex& index) const { unsigned int modIndex = index.data(ModList::IndexRole).toInt(); - bool highligth = m_markers.highlight.find(modIndex) != m_markers.highlight.end(); + bool highlight = 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(); @@ -1149,8 +1137,8 @@ QColor ModListView::markerColor(const QModelIndex& index) const bool archiveLooseOverwritten = m_markers.archiveLooseOverwritten.find(modIndex) != m_markers.archiveLooseOverwritten.end(); - if (highligth) { - return Settings::instance().colors().modlistContainsPlugin(); + if (highlight) { + return Settings::instance().colors().modlistContainsFile(); } else if (overwritten || archiveLooseOverwritten) { return Settings::instance().colors().modlistOverwritingLoose(); } else if (overwrite || archiveLooseOverwrite) { -- cgit v1.3.1