Unlock view status was lost after switching view or refresh (#1565)

This solves these two problems that seem to have being introduced in
d5a049062d

- The unlocked-view status was not applied again when switching back to the
view (you cannot edit and the Delete Record button is not reenabled) or
after refreshing.

- The 'Unlock view editing' check state persisted when switching between
views.

See issue #141.
This commit is contained in:
Manuel
2018-10-19 22:04:08 +02:00
committed by Martin Kleusberg
parent 92295a3e94
commit eab31b69ee

View File

@@ -3182,11 +3182,6 @@ void MainWindow::unlockViewEditing(bool unlock, QString pk)
return;
}
// If the settings didn't change, do nothing. This avoids an infinite loop
BrowseDataTableSettings& settings = browseTableSettings[currentTable];
if(unlock != settings.unlockViewPk.isEmpty() && settings.unlockViewPk == pk)
return;
sqlb::ViewPtr obj = db.getObjectByName<sqlb::View>(currentTable);
// If the view gets unlocked for editing and we don't have a 'primary key' for this view yet, then ask for one
@@ -3230,11 +3225,16 @@ void MainWindow::unlockViewEditing(bool unlock, QString pk)
ui->actionUnlockViewEditing->setChecked(unlock);
ui->actionUnlockViewEditing->blockSignals(false);
// Save settings for this table
settings.unlockViewPk = pk;
// If the settings didn't change, do not try to reapply them.
// This avoids an infinite mutual recursion.
BrowseDataTableSettings& settings = browseTableSettings[currentTable];
// Reapply the view settings. This seems to be necessary as a workaround for newer Qt versions.
applyBrowseTableSettings(settings);
if(settings.unlockViewPk != pk) {
// Save settings for this table
settings.unlockViewPk = pk;
// Reapply the view settings. This seems to be necessary as a workaround for newer Qt versions.
applyBrowseTableSettings(settings);
}
}
sqlb::ObjectIdentifier MainWindow::currentlyBrowsedTableName() const