Add "Browse Table" action to the context menu of the DB Structure dock

Add a "Browse Table" action to the right-click menu of the table and
view items in the Database Structure dock.

See issue #1943.
This commit is contained in:
Martin Kleusberg
2019-07-26 14:45:43 +02:00
parent 6cfac1b0f1
commit 8a4e363483
2 changed files with 19 additions and 0 deletions

View File

@@ -267,6 +267,14 @@ void MainWindow::init()
popupTableMenu->addAction(ui->actionExportCsvPopup);
popupSchemaDockMenu = new QMenu(this);
actionPopupSchemaDockBrowseTable = popupSchemaDockMenu->addAction(QIcon(":icons/table"), tr("Browse Table"), [this]() {
sqlb::ObjectIdentifier obj(ui->treeSchemaDock->model()->data(ui->treeSchemaDock->currentIndex().sibling(ui->treeSchemaDock->currentIndex().row(), DbStructureModel::ColumnSchema), Qt::EditRole).toString().toStdString(),
ui->treeSchemaDock->model()->data(ui->treeSchemaDock->currentIndex().sibling(ui->treeSchemaDock->currentIndex().row(), DbStructureModel::ColumnName), Qt::EditRole).toString().toStdString());
QString tableToBrowse = QString::fromStdString(obj.toDisplayString());
switchToBrowseDataTab(tableToBrowse);
refresh(); // Required in case the Browse Data tab already was the active main tab
});
popupSchemaDockMenu->addSeparator();
popupSchemaDockMenu->addAction(ui->actionDropQualifiedCheck);
popupSchemaDockMenu->addAction(ui->actionEnquoteNamesCheck);
@@ -1848,6 +1856,15 @@ void MainWindow::createTreeContextMenu(const QPoint &qPoint)
//** DB Schema Dock Context Menu
void MainWindow::createSchemaDockContextMenu(const QPoint &qPoint)
{
bool enable_browse_table = false;
if(ui->treeSchemaDock->selectionModel()->hasSelection())
{
QString type = ui->treeSchemaDock->model()->data(ui->treeSchemaDock->currentIndex().sibling(ui->treeSchemaDock->currentIndex().row(), DbStructureModel::ColumnObjectType), Qt::EditRole).toString();
if(type == "table" || type == "view")
enable_browse_table = true;
}
actionPopupSchemaDockBrowseTable->setEnabled(enable_browse_table);
popupSchemaDockMenu->exec(ui->treeSchemaDock->mapToGlobal(qPoint));
}

View File

@@ -134,6 +134,8 @@ private:
QMenu* popupSaveFilterAsMenu;
QMenu* popupBrowseDataHeaderMenu;
QAction* actionPopupSchemaDockBrowseTable;
QLabel* statusEncodingLabel;
QLabel* statusEncryptionLabel;
QLabel* statusReadOnlyLabel;