diff options
| author | Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> | 2025-01-02 08:52:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-02 08:52:38 +0100 |
| commit | f8340e16201c214eef5327c4e810432e12b23805 (patch) | |
| tree | 88814d5d1d5d8413adc72e4e83990ed986e6a144 /src/pluginlistview.cpp | |
| parent | 110014bf5eb1df045790204836e8d0d44fcea1e2 (diff) | |
Highlight mods that contain selected files in data tab (#2179)
Diffstat (limited to 'src/pluginlistview.cpp')
| -rw-r--r-- | src/pluginlistview.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/src/pluginlistview.cpp b/src/pluginlistview.cpp index 5a4e7efa..371e742c 100644 --- a/src/pluginlistview.cpp +++ b/src/pluginlistview.cpp @@ -16,6 +16,9 @@ #include "organizercore.h" #include "pluginlistcontextmenu.h" #include "pluginlistsortproxy.h" +#include "shared/directoryentry.h" +#include "shared/fileentry.h" +#include "shared/filesorigin.h" #include "ui_mainwindow.h" using namespace MOBase; @@ -30,6 +33,12 @@ PluginListView::PluginListView(QWidget* parent) installEventFilter(new CopyEventFilter(this)); } +void PluginListView::activated() +{ + // update highlighted mods + selectionModel()->selectionChanged({}, {}); +} + int PluginListView::sortColumn() const { return m_sortProxy ? m_sortProxy->sortColumn() : -1; @@ -259,17 +268,26 @@ void PluginListView::setup(OrganizerCore& core, MainWindow* mw, Ui::MainWindow* &PluginListSortProxy::updateFilter); connect(ui.filter, &QLineEdit::textChanged, this, &PluginListView::onFilterChanged); - // highligth mod list when selected - connect(selectionModel(), &QItemSelectionModel::selectionChanged, - [=](auto&& selected) { - std::vector<unsigned int> pluginIndices; - for (auto& idx : indexViewToModel(selectionModel()->selectedRows())) { - pluginIndices.push_back(idx.row()); - } - mwui->modList->setHighlightedMods(pluginIndices); - m_core->pluginList()->highlightMasters(pluginIndices); - verticalScrollBar()->repaint(); - }); + // highlight mod list when selected + connect(selectionModel(), &QItemSelectionModel::selectionChanged, [=] { + std::set<QString> mods; + auto& directoryEntry = *m_core->directoryStructure(); + auto pluginIndices = indexViewToModel(selectionModel()->selectedRows()); + for (auto& idx : pluginIndices) { + QString pluginName = m_core->pluginList()->getName(idx.row()); + + const MOShared::FileEntryPtr fileEntry = + directoryEntry.findFile(pluginName.toStdWString()); + if (fileEntry.get() != nullptr) { + QString originName = QString::fromStdWString( + directoryEntry.getOriginByID(fileEntry->getOrigin()).getName()); + mods.insert(originName); + } + } + mwui->modList->setHighlightedMods(mods); + m_core->pluginList()->highlightMasters(pluginIndices); + verticalScrollBar()->repaint(); + }); // using a lambda here to avoid storing the mod list actions connect(this, &QTreeView::customContextMenuRequested, [=](auto&& pos) { |
