From b6de58f2d348e89f0d75f10b9c84312cd0d3a6e5 Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> Date: Sat, 12 Oct 2024 13:37:58 +0200 Subject: Highlight masters of selected plugins (#2140) --- src/pluginlist.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index feb7afe1..04d4462a 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -161,6 +161,27 @@ void PluginList::highlightPlugins(const std::vector& modIndices, this->columnCount() - 1)); } +void PluginList::highlightMasters( + const std::vector& selectedPluginIndices) +{ + for (auto& esp : m_ESPs) { + esp.isMasterOfSelectedPlugin = false; + } + + for (const auto& pluginIndex : selectedPluginIndices) { + const ESPInfo& plugin = m_ESPs[pluginIndex]; + for (const auto& master : plugin.masters) { + const auto iter = m_ESPsByName.find(master); + if (iter != m_ESPsByName.end()) { + m_ESPs[iter->second].isMasterOfSelectedPlugin = true; + } + } + } + + emit dataChanged(this->index(0, 0), this->index(static_cast(m_ESPs.size()) - 1, + this->columnCount() - 1)); +} + void PluginList::refresh(const QString& profileName, const DirectoryEntry& baseDirectory, const QString& lockedOrderFile, bool force) @@ -1306,10 +1327,13 @@ QVariant PluginList::foregroundData(const QModelIndex& modelIndex) const QVariant PluginList::backgroundData(const QModelIndex& modelIndex) const { - const int index = modelIndex.row(); + const int index = modelIndex.row(); + const ESPInfo& plugin = m_ESPs[index]; - if (m_ESPs[index].modSelected) { + if (plugin.modSelected) { return Settings::instance().colors().pluginListContained(); + } else if (plugin.isMasterOfSelectedPlugin) { + return Settings::instance().colors().pluginListMaster(); } return {}; @@ -1921,7 +1945,8 @@ PluginList::ESPInfo::ESPInfo(const QString& name, bool forceLoaded, bool forceEn : name(name), fullPath(fullPath), enabled(forceLoaded), forceLoaded(forceLoaded), forceEnabled(forceEnabled), forceDisabled(forceDisabled), priority(0), loadOrder(-1), originName(originName), hasIni(hasIni), - archives(archives.begin(), archives.end()), modSelected(false) + archives(archives.begin(), archives.end()), modSelected(false), + isMasterOfSelectedPlugin(false) { try { ESP::File file(ToWString(fullPath)); -- cgit v1.3.1