Remove the valid flag from the SqliteTableModel class

Remove the valid flag from the SqliteTableModel class and remove its
usage in the Execute SQL tab of the main window. I believe this hasn't
been used for some time now because the main sources of error should
really be noticed before the query is even handed over to the model.
Additionally the valid flag wasn't as realible either anymore because of
the multi-threaded execution of the model queries.
This commit is contained in:
Martin Kleusberg
2017-10-22 18:36:51 +02:00
parent 9fd4ebe0e0
commit b9595b9b7e
3 changed files with 8 additions and 25 deletions

View File

@@ -1081,20 +1081,13 @@ void MainWindow::executeQuery()
case SQLITE_ROW:
{
sqlWidget->getModel()->setQuery(queryPart);
if(sqlWidget->getModel()->valid())
{
// The query takes the last placeholder as it may itself contain the sequence '%' + number
statusMessage = tr("%1 rows returned in %2ms from: %3").arg(
sqlWidget->getModel()->totalRowCount()).arg(timer.elapsed()).arg(queryPart.trimmed());
ui->actionSqlResultsSave->setEnabled(true);
ui->actionSqlResultsSaveAsView->setEnabled(!db.readOnly());
sql3status = SQLITE_OK;
}
else
{
statusMessage = tr("Error executing query: %1").arg(queryPart);
sql3status = SQLITE_ERROR;
}
// The query takes the last placeholder as it may itself contain the sequence '%' + number
statusMessage = tr("%1 rows returned in %2ms from: %3").arg(
sqlWidget->getModel()->totalRowCount()).arg(timer.elapsed()).arg(queryPart.trimmed());
ui->actionSqlResultsSave->setEnabled(true);
ui->actionSqlResultsSaveAsView->setEnabled(!db.readOnly());
sql3status = SQLITE_OK;
}
case SQLITE_DONE:
case SQLITE_OK:

View File

@@ -17,7 +17,6 @@ SqliteTableModel::SqliteTableModel(DBBrowserDB& db, QObject* parent, size_t chun
, m_db(db)
, m_rowCountAdjustment(0)
, m_chunkSize(chunkSize)
, m_valid(false)
, m_encoding(encoding)
{
reset();
@@ -132,11 +131,7 @@ void SqliteTableModel::setQuery(const QString& sQuery, bool dontClearHeaders)
// do a count query to get the full row count in a fast manner
m_rowCountAdjustment = 0;
m_rowCount = QtConcurrent::run([=]() {
int count = getQueryRowCount();
if(count == -1)
m_valid = false;
return count;
return getQueryRowCount();
});
// headers
@@ -148,7 +143,6 @@ void SqliteTableModel::setQuery(const QString& sQuery, bool dontClearHeaders)
// now fetch the first entries
clearCache();
fetchData(0, m_chunkSize);
m_valid = true;
emit layoutChanged();
}

View File

@@ -46,8 +46,6 @@ public:
Qt::ItemFlags flags(const QModelIndex& index) const;
bool valid() const { return m_valid; }
bool isBinary(const QModelIndex& index) const;
void setEncoding(const QString& encoding) { m_encoding = encoding; }
@@ -124,8 +122,6 @@ private:
*/
size_t m_chunkSize;
bool m_valid; //! tells if the current query is valid.
QString m_encoding;
/**