From d7bc542b3d1a96a546d48850e61d3ecdc953c4cc Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Thu, 30 Nov 2017 16:37:14 -0600 Subject: Implement mod/plugin highlighting when pair is selected --- src/pluginlist.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 4420bf17..a215b9d3 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 "viewmarkingscrollbar.h" #include #include #include @@ -107,6 +108,28 @@ QString PluginList::getColumnToolTip(int column) } } +void PluginList::highlightPlugins(const QItemSelection &selected, const MOShared::DirectoryEntry &directoryEntry) +{ + 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()) { + QDir dir(selectedMod->absolutePath()); + QStringList plugins = dir.entryList(QStringList() << "*.esp" << "*.esm" << "*.esl"); + if (plugins.size() > 0) { + for (auto plugin : plugins) { + std::map::iterator iter = m_ESPsByName.find(plugin.toLower()); + if (iter != m_ESPsByName.end()) { + m_ESPs[iter->second].m_ModSelected = true; + } + } + } + } + } + emit dataChanged(this->index(0, 0), this->index(m_ESPs.size() - 1, this->columnCount() - 1)); +} void PluginList::refresh(const QString &profileName , const DirectoryEntry &baseDirectory @@ -752,9 +775,16 @@ QVariant PluginList::data(const QModelIndex &modelIndex, int role) const } } else if (role == Qt::ForegroundRole) { if ((modelIndex.column() == COL_NAME) && - m_ESPs[index].m_ForceEnabled) { + m_ESPs[index].m_ForceEnabled) { return QBrush(Qt::gray); } + } else if (role == Qt::BackgroundRole + || (role == ViewMarkingScrollBar::DEFAULT_ROLE)) { + if (m_ESPs[index].m_ModSelected) { + return QColor(0, 0, 255, 32); + } else { + return QVariant(); + } } else if (role == Qt::FontRole) { QFont result; if (m_ESPs[index].m_IsMaster) { @@ -1134,7 +1164,7 @@ PluginList::ESPInfo::ESPInfo(const QString &name, bool enabled, const QString &originName, const QString &fullPath, bool hasIni) : m_Name(name), m_FullPath(fullPath), m_Enabled(enabled), m_ForceEnabled(enabled), - m_Priority(0), m_LoadOrder(-1), m_OriginName(originName), m_HasIni(hasIni) + m_Priority(0), m_LoadOrder(-1), m_OriginName(originName), m_HasIni(hasIni), m_ModSelected(false) { try { ESP::File file(ToWString(fullPath)); -- cgit v1.3.1