From 7e549c7c4ccb387ac8acb8cea3c11423e8bcaa93 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sun, 9 Dec 2018 12:43:50 +0100 Subject: [PATCH] Don't show misleading "determining row count" message in empty db When no table is selected in the Browse Data tab, either because the current database is empty or because no database is opened, we would forever show the "determining row count" message even though nothing is to be determined at this point. This commit makes sure to show a better "0 - 0 of 0" message as we did before. See issue #1654. --- src/MainWindow.cpp | 9 ++++++++- src/sqlitetablemodel.cpp | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 36d4ac2d..8758db5a 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1028,9 +1028,16 @@ void MainWindow::setRecordsetLabel() // Update the validator of the goto row field gotoValidator->setRange(0, total); + // When there is no query for this table (i.e. no table is selected), there is no row count query either which in turn means + // that the row count query will never finish. And because of this the row count will be forever unknown. To avoid always showing + // a misleading "determining row count" text in the UI we set the row count status to complete here for empty queries. + auto row_count_available = m_browseTableModel->rowCountAvailable(); + if(m_browseTableModel->query().isEmpty()) + row_count_available = SqliteTableModel::RowCount::Complete; + // Update the label showing the current position QString txt; - switch(m_browseTableModel->rowCountAvailable()) + switch(row_count_available) { case SqliteTableModel::RowCount::Unknown: txt = tr("determining row count..."); diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index 187c586e..941b6a86 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -100,6 +100,7 @@ void SqliteTableModel::reset() beginResetModel(); clearCache(); + m_sQuery.clear(); m_query.clear(); m_headers.clear(); m_vDataTypes.clear();