diff options
| author | Jeremy Rimpo <jeremy.rimpo@servermonkey.com> | 2017-11-30 20:55:00 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-30 20:55:00 -0600 |
| commit | c55a923bb8b9b66661f32beed8445602400ef318 (patch) | |
| tree | 850ead2730c8ab50babc865a505a513d8fba5f46 /src/pluginlist.cpp | |
| parent | 7ec0b79eb49a27a3516d799a80d57000cde344da (diff) | |
| parent | 797a007eab2695c231a00240225d77b3a9928992 (diff) | |
Merge pull request #132 from Silarn/mainline_dev
Numerous updates
Diffstat (limited to 'src/pluginlist.cpp')
| -rw-r--r-- | src/pluginlist.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 4420bf17..add34b3f 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -21,6 +21,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "settings.h"
#include "scopeguard.h"
#include "modinfo.h"
+#include "viewmarkingscrollbar.h"
#include <utility.h>
#include <iplugingame.h>
#include <espfile.h>
@@ -107,6 +108,35 @@ 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"); + MOShared::FilesOrigin origin = directoryEntry.getOriginByName(selectedMod->internalName().toStdWString()); + if (plugins.size() > 0) { + for (auto plugin : plugins) { + MOShared::FileEntry::Ptr file = directoryEntry.findFile(plugin.toStdWString());
+ if (file->getOrigin() != origin.getID()) {
+ const std::vector<int> alternatives = file->getAlternatives();
+ if (std::find(alternatives.begin(), alternatives.end(), origin.getID()) == alternatives.end())
+ continue;
+ }
+ std::map<QString, int>::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 +782,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 +1171,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));
|
