Avoid unnecessary queries when populating filtered table

When a table is filtered and the browsed tabled is changed and then we
return to this filtered table, the table view shows several incorrect
disabled rows. The same may happen when refreshing this table. This seems
to be produced by a (yet unsolved) concurrency problem triggered by
several consecutive queries, that are signalled by setting the text of
the stored filters in the table header filter.

These unnecessary queries are avoided by setting the stored filter values
at the same time as the table in the SQL table model, making sure that
no intermediate queries are executed while the filters are set.

This seems to work around the concurrency problem and the symptom of the
invalid rows does not appear in those situations.
This commit is contained in:
mgrojo
2018-01-23 23:27:37 +01:00
committed by Martin Kleusberg
parent dd4a71e380
commit c78c03bf0b
3 changed files with 14 additions and 7 deletions

View File

@@ -649,9 +649,9 @@ void MainWindow::populateTable()
}
}
if(only_defaults)
m_browseTableModel->setTable(tablename, storedData.sortOrderIndex, storedData.sortOrderMode);
m_browseTableModel->setTable(tablename, storedData.sortOrderIndex, storedData.sortOrderMode, storedData.filterValues);
else
m_browseTableModel->setTable(tablename, storedData.sortOrderIndex, storedData.sortOrderMode, v);
m_browseTableModel->setTable(tablename, storedData.sortOrderIndex, storedData.sortOrderMode, storedData.filterValues, v);
// There is information stored for this table, so extract it and apply it
applyBrowseTableSettings(storedData);
@@ -708,9 +708,12 @@ void MainWindow::applyBrowseTableSettings(BrowseDataTableSettings storedData, bo
// Filters
if(!skipFilters)
{
// Set filters blocking signals, since the filter is already applied to the browse table model
FilterTableHeader* filterHeader = qobject_cast<FilterTableHeader*>(ui->dataTable->horizontalHeader());
bool oldState = filterHeader->blockSignals(true);
for(auto filterIt=storedData.filterValues.constBegin();filterIt!=storedData.filterValues.constEnd();++filterIt)
filterHeader->setFilter(filterIt.key(), filterIt.value());
filterHeader->blockSignals(oldState);
}
// Encoding