From b58ec8985409653f92028b72a82fcc59d7fcf794 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Thu, 25 Jun 2020 18:34:46 -0500 Subject: [PATCH] Properly filter the map search results when switching sort types --- include/mainwindow.h | 1 + src/mainwindow.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/mainwindow.h b/include/mainwindow.h index 33573857..af9266d1 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -295,6 +295,7 @@ private: void initMapSortOrder(); void setProjectSpecificUIVisibility(); void loadUserSettings(); + void applyMapListFilter(QString filterText); void restoreWindowState(); void setTheme(QString); bool openRecentProject(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6d3ae075..9f698931 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -240,14 +240,20 @@ void MainWindow::mapSortOrder_changed(QAction *action) if (isProjectOpen()) { sortMapList(); + applyMapListFilter(ui->lineEdit_filterBox->text()); } } } void MainWindow::on_lineEdit_filterBox_textChanged(const QString &arg1) { - mapListProxyModel->setFilterRegExp(QRegExp(arg1, Qt::CaseInsensitive, QRegExp::FixedString)); - if (arg1.isEmpty()) { + this->applyMapListFilter(arg1); +} + +void MainWindow::applyMapListFilter(QString filterText) +{ + mapListProxyModel->setFilterRegExp(QRegExp(filterText, Qt::CaseInsensitive, QRegExp::FixedString)); + if (filterText.isEmpty()) { ui->mapList->collapseAll(); } else { ui->mapList->expandToDepth(0);