Add basic function for cancelling queries

This doesn't do all the work yet and isn't called anywhere. So don't
expect this to do anything useful.
This commit is contained in:
Martin Kleusberg
2017-10-22 18:34:33 +02:00
parent d126e86e81
commit 04e8119049
2 changed files with 19 additions and 0 deletions

View File

@@ -920,3 +920,18 @@ void SqliteTableModel::waitForFetchingFinished()
if(m_futureFetch.isRunning())
m_futureFetch.waitForFinished();
}
void SqliteTableModel::cancelQuery()
{
if(m_rowCount.isRunning())
{
m_rowCount.cancel();
m_rowCount = QtConcurrent::run([=]() {
// Make sure we report 0 rows if anybody asks
return 0;
});
}
if(m_futureFetch.isRunning())
m_futureFetch.cancel();
}

View File

@@ -75,6 +75,10 @@ public:
public slots:
void updateFilter(int column, const QString& value);
// This cancels the execution of the current query. It can't guarantee that the query is stopped immediately or after returning but it should
// stop soon afterwards. If some data has already been loaded into the model, that data is not deleted
void cancelQuery();
signals:
void finishedFetch();