From dd8dd4852d97a92d6f9772dc788aaf1591d0ff19 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Thu, 23 Apr 2015 22:32:23 +0200 Subject: [PATCH] Add Browse Table popop action to Database Structure tab In the Database Structure tab of the main window, add a new action to the popup menu which open upon right clicking the tree view to allow directly changing to the Browse Data tab with the current table being selected automatically. See issue #246. --- src/MainWindow.cpp | 20 +++++++++++++++++++- src/MainWindow.h | 1 + src/MainWindow.ui | 30 ++++++++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index b7df318ff..0a07d7f00 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -103,6 +103,7 @@ void MainWindow::init() // Create popup menus popupTableMenu = new QMenu(this); + popupTableMenu->addAction(ui->actionEditBrowseTable); popupTableMenu->addAction(ui->editModifyTableAction); popupTableMenu->addAction(ui->editDeleteObjectAction); popupTableMenu->addSeparator(); @@ -980,6 +981,7 @@ void MainWindow::changeTreeSelection() // Just assume first that something's selected that can not be edited at all ui->editDeleteObjectAction->setEnabled(false); ui->editModifyTableAction->setEnabled(false); + ui->actionEditBrowseTable->setEnabled(false); if(!ui->dbTreeWidget->currentIndex().isValid()) return; @@ -1004,7 +1006,11 @@ void MainWindow::changeTreeSelection() } else if(type == "view" || type == "trigger" || type == "index") { ui->editDeleteObjectAction->setEnabled(true); } - ui->actionExportCsvPopup->setEnabled(type == "table" || type == "view"); + if(type == "table" || type == "view") + { + ui->actionEditBrowseTable->setEnabled(true); + ui->actionExportCsvPopup->setEnabled(true); + } } void MainWindow::openRecentFile() @@ -2082,3 +2088,15 @@ void MainWindow::editEncryption() } #endif } + +void MainWindow::switchToBrowseDataTab() +{ + if(!ui->dbTreeWidget->selectionModel()->hasSelection()) + return; + + QString tableToBrowse = ui->dbTreeWidget->model()->data(ui->dbTreeWidget->currentIndex().sibling(ui->dbTreeWidget->currentIndex().row(), 0)).toString(); + + ui->mainTab->setCurrentIndex(1); + ui->comboBrowseTable->setCurrentText(tableToBrowse); + ui->comboBrowseTable->activated(tableToBrowse); +} diff --git a/src/MainWindow.h b/src/MainWindow.h index 1ccb87ce5..23516e484 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -174,6 +174,7 @@ private slots: void fileAttach(); void updateFilter(int column, const QString& value); void editEncryption(); + void switchToBrowseDataTab(); }; #endif diff --git a/src/MainWindow.ui b/src/MainWindow.ui index ccc4ab02d..f5c06fd9f 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -310,8 +310,8 @@ 0 0 - 294 - 444 + 575 + 458 @@ -1598,6 +1598,15 @@ Save SQL file + + + + :/icons/table:/icons/table + + + &Browse Table + + @@ -2469,6 +2478,22 @@ + + actionEditBrowseTable + triggered() + MainWindow + switchToBrowseDataTab() + + + -1 + -1 + + + 499 + 314 + + + fileOpen() @@ -2522,5 +2547,6 @@ fileAttach() editEncryption() saveSqlFileAs() + switchToBrowseDataTab()