diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 81d7f8fb5..25feb9223 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -185,6 +185,12 @@ void MainWindow::init() ui->actionSqlResultsSave->setMenu(popupSaveSqlResultsMenu); qobject_cast(ui->toolbarSql->widgetForAction(ui->actionSqlResultsSave))->setPopupMode(QToolButton::InstantPopup); + popupSaveFilterAsMenu = new QMenu(this); + popupSaveFilterAsMenu->addAction(ui->actionFilteredTableExportCsv); + popupSaveFilterAsMenu->addAction(ui->actionFilterSaveAsView); + ui->buttonSaveFilterAsPopup->setMenu(popupSaveFilterAsMenu); + ui->buttonSaveFilterAsPopup->setPopupMode(QToolButton::InstantPopup); + popupBrowseDataHeaderMenu = new QMenu(this); popupBrowseDataHeaderMenu->addAction(ui->actionShowRowidColumn); popupBrowseDataHeaderMenu->addAction(ui->actionUnlockViewEditing); @@ -1600,7 +1606,7 @@ void MainWindow::activateFields(bool enable) ui->actionSaveProject->setEnabled(enable); ui->actionEncryption->setEnabled(enable && write); ui->buttonClearFilters->setEnabled(enable); - ui->buttonSaveFilterAsView->setEnabled(enable); + ui->buttonSaveFilterAsPopup->setEnabled(enable); ui->dockEdit->setEnabled(enable); ui->dockPlot->setEnabled(enable); @@ -2954,6 +2960,11 @@ void MainWindow::saveAsView(QString query) QMessageBox::warning(this, qApp->applicationName(), tr("Error creating view: %1").arg(db.lastError())); } +void MainWindow::exportFilteredTable() +{ + ExportDataDialog dialog(db, ExportDataDialog::ExportFormatCsv, this, m_browseTableModel->customQuery(false)); + dialog.exec(); +} void MainWindow::saveFilterAsView() { diff --git a/src/MainWindow.h b/src/MainWindow.h index 3341ffcc7..fc0568a98 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -142,6 +142,7 @@ class MainWindow : public QMainWindow QMenu* recentFilesMenu; QMenu* popupSaveSqlFileMenu; QMenu* popupSaveSqlResultsMenu; + QMenu* popupSaveFilterAsMenu; QMenu* popupBrowseDataHeaderMenu; QLabel* statusEncodingLabel; @@ -281,6 +282,7 @@ private slots: void setFindFrameVisibility(bool show); void openFindReplaceDialog(); void saveFilterAsView(); + void exportFilteredTable(); }; #endif diff --git a/src/MainWindow.ui b/src/MainWindow.ui index 0206c3cf0..57efc2a4e 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -167,12 +167,12 @@ You can drag SQL statements from an object row and drop them into other applicat - + - Save the current filter, sort column and display formats as a view + Save the table as currently displayed - This button saves the current setting of the browsed table (filters, display formats and order column) as an SQL view that you can later browse or use in SQL statements. + <html><head/><body><p>This popup menu provides the following options applying to the currently browsed and filtered table:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Export to CSV: this option exports the data of the browsed table as currently displayed (after filters, display formats and order column) to a CSV file.</li><li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Save as view: this option saves the current setting of the browsed table (filters, display formats and order column) as an SQL view that you can later browse or use in SQL statements.</li></ul></body></html> ... @@ -396,8 +396,8 @@ You can drag SQL statements from an object row and drop them into other applicat 0 0 - 566 - 531 + 601 + 484 @@ -887,7 +887,7 @@ You can drag SQL statements from an object row and drop them into other applicat 0 0 1037 - 25 + 20 @@ -2041,6 +2041,34 @@ You can drag SQL statements from the Schema column and drop them into the SQL ed Extra DB Toolbar + + + Export to &CSV + + + Export the filtered data to CSV + + + Export the filtered data to CSV + + + This button exports the data of the browsed table as currently displayed (after filters, display formats and order column) as a CSV file. + + + + + Save as &view + + + Save the current filter, sort column and display formats as a view + + + Save the current filter, sort column and display formats as a view + + + This button saves the current setting of the browsed table (filters, display formats and order column) as an SQL view that you can later browse or use in SQL statements. + + @@ -3206,7 +3234,7 @@ You can drag SQL statements from the Schema column and drop them into the SQL ed - buttonSaveFilterAsView + buttonSaveFilterAsPopup clicked() MainWindow saveFilterAsView() @@ -3301,6 +3329,38 @@ You can drag SQL statements from the Schema column and drop them into the SQL ed + + actionFilteredTableExportCsv + triggered() + MainWindow + exportFilteredTable() + + + -1 + -1 + + + 518 + 314 + + + + + actionFilterSaveAsView + triggered() + MainWindow + saveFilterAsView() + + + -1 + -1 + + + 518 + 314 + + + fileOpen()