Make text selectable in Edit dock even if db is opened as read only

Instead of disabling the entire edit dock when the database is opened in
read only mode, only disable all buttons for making changes to the
field. This way the data can still be read using the edit dock.

See issue #1123.
This commit is contained in:
Martin Kleusberg
2017-09-10 15:19:03 +02:00
parent f28bb151b3
commit fb6ea5ac60
2 changed files with 8 additions and 3 deletions

View File

@@ -464,6 +464,8 @@ void EditDialog::setReadOnly(bool ro)
ui->buttonApply->setEnabled(!ro);
ui->buttonNull->setEnabled(!ro);
ui->buttonImport->setEnabled(!ro);
ui->editorText->setReadOnly(ro);
ui->editorBinary->setEnabled(!ro); // We disable the entire hex editor here instead of setting it to read only because it doesn't have a setReadOnly() method
}
// Update the information labels in the bottom left corner of the dialog

View File

@@ -113,6 +113,9 @@ void MainWindow::init()
ui->dockPlot->setWidget(plotDock);
ui->dockRemote->setWidget(remoteDock);
// Set up edit dock
editDock->setReadOnly(true);
// Restore window geometry
restoreGeometry(Settings::getValue("MainWindow", "geometry").toByteArray());
restoreState(Settings::getValue("MainWindow", "windowState").toByteArray());
@@ -863,7 +866,7 @@ void MainWindow::doubleClickTable(const QModelIndex& index)
}
// * Don't allow editing of other objects than tables (on the browse table) *
bool isEditingAllowed = (m_currentTabTableModel == m_browseTableModel) &&
bool isEditingAllowed = !db.readOnly() && m_currentTabTableModel == m_browseTableModel &&
(db.getObjectByName(currentlyBrowsedTableName())->type() == sqlb::Object::Types::Table);
// Enable or disable the Apply, Null, & Import buttons in the Edit Cell
@@ -887,7 +890,7 @@ void MainWindow::dataTableSelectionChanged(const QModelIndex& index)
return;
}
bool editingAllowed = (m_currentTabTableModel == m_browseTableModel) &&
bool editingAllowed = !db.readOnly() && (m_currentTabTableModel == m_browseTableModel) &&
(db.getObjectByName(currentlyBrowsedTableName())->type() == sqlb::Object::Types::Table);
// Don't allow editing of other objects than tables
@@ -1509,7 +1512,7 @@ void MainWindow::activateFields(bool enable)
ui->actionSaveProject->setEnabled(enable);
ui->actionEncryption->setEnabled(enable && write);
ui->buttonClearFilters->setEnabled(enable);
ui->dockEdit->setEnabled(enable && write);
ui->dockEdit->setEnabled(enable);
ui->dockPlot->setEnabled(enable);
if(!enable)