From ae199112a541805c3b903e7add68768ea658654c Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Mon, 6 Oct 2014 15:23:55 +0200 Subject: [PATCH] MainWindow: Make sure the filters are applied before getting the row num First apply the new filter values and only when that is done get the number of rows in the current view. This fixes the issue that, when changing a filter, the number of rows shown under the table view is that of the last results, not the current. See issue #122. --- src/MainWindow.cpp | 9 +++++++-- src/MainWindow.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 450c1de6..f89b700b 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -134,7 +134,6 @@ void MainWindow::init() ui->statusbar->addPermanentWidget(statusEncodingLabel); // Connect some more signals and slots - connect(ui->dataTable->filterHeader(), SIGNAL(filterChanged(int,QString)), this, SLOT(setRecordsetLabel())); connect(ui->dataTable->filterHeader(), SIGNAL(sectionClicked(int)), this, SLOT(browseTableHeaderClicked(int))); connect(ui->dataTable->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(setRecordsetLabel())); connect(ui->dataTable->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(updateBrowseDataColumnWidth(int,int,int))); @@ -400,7 +399,7 @@ void MainWindow::fileClose() // Delete the model for the Browse tab and create a new one delete m_browseTableModel; m_browseTableModel = new SqliteTableModel(this, &db, PreferencesDialog::getSettingsValue("db", "prefetchsize").toInt()); - connect(ui->dataTable->filterHeader(), SIGNAL(filterChanged(int,QString)), m_browseTableModel, SLOT(updateFilter(int,QString))); + connect(ui->dataTable->filterHeader(), SIGNAL(filterChanged(int,QString)), this, SLOT(updateFilter(int,QString))); // Remove all stored column widths for the browse data table browseTableColumnWidths.clear(); @@ -1957,3 +1956,9 @@ void MainWindow::fileAttach() if(!db.executeSQL(QString("ATTACH '%1' AS `%2`").arg(file).arg(attachAs), false)) QMessageBox::warning(this, qApp->applicationName(), db.lastErrorMessage); } + +void MainWindow::updateFilter(int column, const QString& value) +{ + m_browseTableModel->updateFilter(column ,value); + setRecordsetLabel(); +} diff --git a/src/MainWindow.h b/src/MainWindow.h index 4a47f2dd..4e43f789 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -176,6 +176,7 @@ private slots: bool loadProject(QString filename = QString()); void saveProject(); void fileAttach(); + void updateFilter(int column, const QString& value); }; #endif