Restore current table and applied filters from project

Restoring the current table and applied filters from project was not
working due to some interference with other applied changes.

Now it is done at the end of the load project function and after having
processed events. applyBrowseTableSettings is also called, otherwise
filters are applied but not visible in their input boxes.

See issue #1573
This commit is contained in:
mgrojo
2019-08-17 20:48:00 +02:00
parent fefbe37c29
commit aae2d4dea5
+11 -11
View File
@@ -2883,6 +2883,7 @@ bool MainWindow::loadProject(QString filename, bool readOnly)
isProjectModified = false;
addToRecentFilesMenu(filename, readOnly);
QString currentTable;
while(!xml.atEnd() && !xml.hasError())
{
// Read next token
@@ -2974,7 +2975,7 @@ bool MainWindow::loadProject(QString filename, bool readOnly)
if(xml.name() == "current_table")
{
// Currently selected table
ui->comboBrowseTable->setCurrentIndex(ui->comboBrowseTable->findText(xml.attributes().value("name").toString()));
currentTable = xml.attributes().value("name").toString();
xml.skipCurrentElement();
} else if(xml.name() == "default_encoding") {
// Default text encoding
@@ -3020,16 +3021,6 @@ bool MainWindow::loadProject(QString filename, bool readOnly)
}
}
if(ui->mainTab->currentWidget() == ui->browser)
{
populateTable(); // Refresh view
sqlb::ObjectIdentifier current_table = currentlyBrowsedTableName();
ui->dataTable->sortByColumns(browseTableSettings[current_table].query.orderBy());
showRowidColumn(browseTableSettings[current_table].showRowid);
unlockViewEditing(!browseTableSettings[current_table].unlockViewPk.isEmpty(), browseTableSettings[current_table].unlockViewPk);
}
}
} else if(xml.name() == "tab_sql") {
// Close all open tabs first
@@ -3060,6 +3051,15 @@ bool MainWindow::loadProject(QString filename, bool readOnly)
file.close();
currentProjectFilename = filename;
if(ui->mainTab->currentWidget() == ui->browser) {
qApp->processEvents();
if (!currentTable.isEmpty())
switchToBrowseDataTab(currentTable);
populateTable(); // Refresh view
BrowseDataTableSettings& settings = browseTableSettings[currentlyBrowsedTableName()];
applyBrowseTableSettings(settings);
}
return !xml.hasError();
} else {
// No project was opened