mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
EditDialog: Allow opening dialog/updating dock in read-only mode for views
See #441.
This commit is contained in:
@@ -250,3 +250,10 @@ void EditDialog::setFocus()
|
||||
ui->editorText->selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
void EditDialog::allowEditing(bool on)
|
||||
{
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(on);
|
||||
ui->buttonClear->setEnabled(on);
|
||||
ui->buttomImport->setEnabled(on);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public slots:
|
||||
virtual void loadText(const QByteArray& data, int row, int col);
|
||||
virtual void setFocus();
|
||||
virtual void reject();
|
||||
virtual void allowEditing(bool on);
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* ev);
|
||||
|
||||
@@ -762,8 +762,9 @@ void MainWindow::doubleClickTable(const QModelIndex& index)
|
||||
return;
|
||||
|
||||
// Don't allow editing of other objects than tables
|
||||
if(db.getObjectByName(ui->comboBrowseTable->currentText()).gettype() != "table")
|
||||
return;
|
||||
bool allowEditing = db.getObjectByName(ui->comboBrowseTable->currentText()).gettype() == "table";
|
||||
editDock->allowEditing(allowEditing);
|
||||
editWin->allowEditing(allowEditing);
|
||||
|
||||
// Load the current value into both, edit window and edit dock
|
||||
editWin->loadText(index.data(Qt::EditRole).toByteArray(), index.row(), index.column());
|
||||
@@ -784,8 +785,7 @@ void MainWindow::dataTableSelectionChanged(const QModelIndex& index)
|
||||
return;
|
||||
|
||||
// Don't allow editing of other objects than tables
|
||||
if(db.getObjectByName(ui->comboBrowseTable->currentText()).gettype() != "table")
|
||||
return;
|
||||
editDock->allowEditing(db.getObjectByName(ui->comboBrowseTable->currentText()).gettype() == "table");
|
||||
|
||||
// Load the current value into the edit dock only
|
||||
editDock->loadText(index.data(Qt::EditRole).toByteArray(), index.row(), index.column());
|
||||
|
||||
Reference in New Issue
Block a user