summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2020-12-29 13:27:29 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-02 15:38:16 +0100
commitf923de39e071b48bc1437fa4c79c22b3bc9b0583 (patch)
treed92bace851cb6198e5f5e6b48bf5249e234705cb /src
parent25d852f07564883f5a225eb0e00e883cae30cbd2 (diff)
Maintain selection while filtering.
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp14
-rw-r--r--src/modlistbypriorityproxy.cpp7
-rw-r--r--src/modlistbypriorityproxy.h9
3 files changed, 22 insertions, 8 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 7c72f132..69e2d989 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -422,10 +422,6 @@ MainWindow::MainWindow(Settings &settings
connect(&m_PluginContainer, SIGNAL(diagnosisUpdate()), this, SLOT(scheduleCheckForProblems()));
- connect(m_ModListSortProxy, SIGNAL(filterActive(bool)), this, SLOT(modFilterActive(bool)));
- connect(m_ModListSortProxy, SIGNAL(layoutChanged()), this, SLOT(updateModCount()));
- connect(ui->modFilterEdit, SIGNAL(textChanged(QString)), m_ModListSortProxy, SLOT(updateFilter(QString)));
-
connect(ui->espFilterEdit, SIGNAL(textChanged(QString)), m_PluginListSortProxy, SLOT(updateFilter(QString)));
connect(ui->espFilterEdit, SIGNAL(textChanged(QString)), this, SLOT(espFilterChanged(QString)));
@@ -659,6 +655,15 @@ void MainWindow::setupModList()
connect(m_OrganizerCore.modList(), &ModList::downloadArchiveDropped, this, [this](int row, int priority) {
m_OrganizerCore.installDownload(row, priority);
});
+
+ connect(m_ModListSortProxy, &ModListSortProxy::filterActive, this, &MainWindow::modFilterActive);
+ connect(ui->modFilterEdit, &QLineEdit::textChanged, m_ModListSortProxy, &ModListSortProxy::updateFilter);
+ connect(m_ModListSortProxy, &QAbstractItemModel::layoutChanged, this, &MainWindow::updateModCount);
+ connect(m_ModListSortProxy, &QAbstractItemModel::layoutChanged, this, [&]() {
+ if (m_ModListSortProxy->sourceModel() == m_ModListByPriorityProxy) {
+ m_ModListByPriorityProxy->refreshExpandedItems();
+ }
+ });
}
void MainWindow::resetActionIcons()
@@ -5835,7 +5840,6 @@ void MainWindow::onFiltersCriteria(const std::vector<ModListSortProxy::Criteria>
}
ui->currentCategoryLabel->setText(label);
- ui->modList->reset();
}
void MainWindow::onFiltersOptions(
diff --git a/src/modlistbypriorityproxy.cpp b/src/modlistbypriorityproxy.cpp
index 756d3bcf..86664213 100644
--- a/src/modlistbypriorityproxy.cpp
+++ b/src/modlistbypriorityproxy.cpp
@@ -82,7 +82,7 @@ void ModListByPriorityProxy::buildTree()
expandItems(QModelIndex());
}
-void ModListByPriorityProxy::expandItems(const QModelIndex& index)
+void ModListByPriorityProxy::expandItems(const QModelIndex& index) const
{
for (int row = 0; row < rowCount(index); row++) {
QModelIndex idx = this->index(row, 0, index);
@@ -298,6 +298,11 @@ void ModListByPriorityProxy::onDropEnter(const QMimeData*, ModListView::DropPosi
m_DropPosition = dropPosition;
}
+void ModListByPriorityProxy::refreshExpandedItems() const
+{
+ expandItems(QModelIndex());
+}
+
void ModListByPriorityProxy::expanded(const QModelIndex& index)
{
auto it = m_CollapsedItems.find(index.data(Qt::DisplayRole).toString());
diff --git a/src/modlistbypriorityproxy.h b/src/modlistbypriorityproxy.h
index cb50352f..26f60bc7 100644
--- a/src/modlistbypriorityproxy.h
+++ b/src/modlistbypriorityproxy.h
@@ -44,8 +44,13 @@ public:
QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override;
QModelIndex mapToSource(const QModelIndex& proxyIndex) const override;
+ // check the internal state for expanded/collapse items and emit a expandItem
+ // signal for each of the expanded item, useful to refresh the tree state after
+ // layout modification
+ void refreshExpandedItems() const;
+
signals:
- void expandItem(const QModelIndex& index);
+ void expandItem(const QModelIndex& index) const;
public slots:
@@ -56,7 +61,7 @@ public slots:
private:
void buildTree();
- void expandItems(const QModelIndex& index);
+ void expandItems(const QModelIndex& index) const;
struct TreeItem {
ModInfo::Ptr mod;