From 30cef84f09be4b98146d84103b2aaf0eb694c6bf Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Fri, 14 Feb 2014 16:40:44 +0100 Subject: [PATCH] Add CSV export to context menu of the Database Structure tab Add an entry for the CSV export to the context menu of the Database Structure tab of the main windows as well which preselects the currently selected table. When opening the CSV export dialog via the standard menu also preselect the currently selected table when the Database Structure tab is active. --- src/MainWindow.cpp | 8 ++++++-- src/MainWindow.ui | 29 ++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 566d33d7..e1899ad2 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -95,8 +95,9 @@ void MainWindow::init() // Create popup menus popupTableMenu = new QMenu(this); popupTableMenu->addAction(ui->editModifyTableAction); - popupTableMenu->addSeparator(); popupTableMenu->addAction(ui->editDeleteObjectAction); + popupTableMenu->addSeparator(); + popupTableMenu->addAction(ui->actionExportCsvPopup); // Set state of checkable menu actions ui->viewMenu->insertAction(ui->viewDBToolbarAction, ui->dockLog->toggleViewAction()); @@ -740,7 +741,9 @@ void MainWindow::exportTableToCSV() { // Get the current table name if we are in the Browse Data tab QString current_table; - if(ui->mainTab->currentIndex() == 1) + if(ui->mainTab->currentIndex() == 0) + current_table = ui->dbTreeWidget->model()->data(ui->dbTreeWidget->currentIndex().sibling(ui->dbTreeWidget->currentIndex().row(), 0)).toString(); + else if(ui->mainTab->currentIndex() == 1) current_table = ui->comboBrowseTable->currentText(); // Open dialog @@ -908,6 +911,7 @@ void MainWindow::changeTreeSelection() } else if(type == "view" || type == "trigger" || type == "index") { ui->editDeleteObjectAction->setEnabled(true); } + ui->actionExportCsvPopup->setEnabled(type == "table" || type == "view"); } void MainWindow::openRecentFile() diff --git a/src/MainWindow.ui b/src/MainWindow.ui index 9dee3a1f..479ec76b 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -272,7 +272,7 @@ 0 0 - 763 + 278 444 @@ -1267,6 +1267,17 @@ Ctrl+F5 + + + false + + + Export as CSV file + + + Export table as comma separated values file + + @@ -1983,6 +1994,22 @@ + + actionExportCsvPopup + triggered() + MainWindow + exportTableToCSV() + + + -1 + -1 + + + 399 + 299 + + + fileOpen()