Improvements for drag and drop of items from the DB Schema dock to editor

Two new options editable from a new context menu of the dock:
- Drag & Drop Qualified Names: add table name to fields and schema name
to other objects (except for "main" schema)
- Drag & Drop Enquoted Names: whether to surround the identifiers by the
configured quoting characters for identifiers.

Support for dragging & dropping of attached databases names.

Add "." as separator for multiple dropped objects other than fields (since
they are not usually used in SQL as a list). This allows to compose
qualified names by dropping the parent and the child items together. This
is only generally useful when the "Qualified Names" option is disabled.

See related issue #1433
This commit is contained in:
mgrojo
2018-09-09 19:52:36 +02:00
parent 04bc7da6e7
commit f33943f4cf
6 changed files with 127 additions and 12 deletions

View File

@@ -176,6 +176,10 @@ void MainWindow::init()
popupTableMenu->addAction(ui->actionEditCopyCreateStatement);
popupTableMenu->addAction(ui->actionExportCsvPopup);
popupSchemaDockMenu = new QMenu(this);
popupSchemaDockMenu->addAction(ui->actionDropQualifiedCheck);
popupSchemaDockMenu->addAction(ui->actionEnquoteNamesCheck);
popupOpenDbMenu = new QMenu(this);
popupOpenDbMenu->addAction(ui->fileOpenAction);
popupOpenDbMenu->addAction(ui->fileOpenReadOnlyAction);
@@ -303,6 +307,10 @@ void MainWindow::init()
connect(m_remoteDb, &RemoteDatabase::gotCurrentVersion, this, &MainWindow::checkNewVersion);
connect(m_browseTableModel, &SqliteTableModel::finishedFetch, this, &MainWindow::setRecordsetLabel);
connect(ui->dataTable, &ExtendedTableWidget::selectedRowsToBeDeleted, this, &MainWindow::deleteRecord);
connect(ui->actionDropQualifiedCheck, &QAction::toggled, dbStructureModel, &DbStructureModel::setDropQualifiedNames);
connect(ui->actionEnquoteNamesCheck, &QAction::toggled, dbStructureModel, &DbStructureModel::setDropEnquotedNames);
ui->actionDropQualifiedCheck->setChecked(Settings::getValue("SchemaDock", "dropQualifiedNames").toBool());
ui->actionEnquoteNamesCheck->setChecked(Settings::getValue("SchemaDock", "dropEnquotedNames").toBool());
connect(m_browseTableModel, &SqliteTableModel::finishedFetch, [this](){
auto & settings = browseTableSettings[currentlyBrowsedTableName()];
@@ -715,6 +723,9 @@ void MainWindow::closeEvent( QCloseEvent* event )
Settings::setValue("MainWindow", "geometry", saveGeometry());
Settings::setValue("MainWindow", "windowState", saveState());
Settings::setValue("SQLLogDock", "Log", ui->comboLogSubmittedBy->currentText());
Settings::setValue("SchemaDock", "dropQualifiedNames", ui->actionDropQualifiedCheck->isChecked());
Settings::setValue("SchemaDock", "dropEnquotedNames", ui->actionEnquoteNamesCheck->isChecked());
QMainWindow::closeEvent(event);
} else {
event->ignore();
@@ -1652,6 +1663,12 @@ void MainWindow::createTreeContextMenu(const QPoint &qPoint)
popupTableMenu->exec(ui->dbTreeWidget->mapToGlobal(qPoint));
}
//** DB Schema Dock Context Menu
void MainWindow::createSchemaDockContextMenu(const QPoint &qPoint)
{
popupSchemaDockMenu->exec(ui->treeSchemaDock->mapToGlobal(qPoint));
}
void MainWindow::changeTreeSelection()
{
// Just assume first that something's selected that can not be edited at all