From e5dd27ff1a574613d80a1fe2abc377c7af3b450e Mon Sep 17 00:00:00 2001 From: eelke Date: Sun, 6 Jan 2019 16:34:50 +0100 Subject: [PATCH] Added several actions that were left out while switching to module. - save copy as - export - copy as c string - copy as raw cpp string --- pglab/QueryTool.cpp | 8 ++++++++ pglab/QueryTool.h | 10 +++++++--- pglab/QueryToolModule.cpp | 24 ++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/pglab/QueryTool.cpp b/pglab/QueryTool.cpp index b03dfdb..3e0ef23 100644 --- a/pglab/QueryTool.cpp +++ b/pglab/QueryTool.cpp @@ -629,3 +629,11 @@ void QueryTool::focusEditor() { ui->queryEdit->setFocus(); } + +void QueryTool::exportData() +{ + QString home_dir = QStandardPaths::locate(QStandardPaths::HomeLocation, "", QStandardPaths::LocateDirectory); + QString file_name = QFileDialog::getSaveFileName(this, + tr("Export data"), home_dir, tr("CSV file (*.csv)")); + exportData(file_name); +} diff --git a/pglab/QueryTool.h b/pglab/QueryTool.h index 8a30cb8..a711eb2 100644 --- a/pglab/QueryTool.h +++ b/pglab/QueryTool.h @@ -39,14 +39,11 @@ public: void newdoc(); bool load(const QString &filename); - void saveCopyAs(); void explain(bool analyze); bool canClose() override; - void copyQueryAsCString(); - void copyQueryAsRawCppString(); void generateCode(); void exportData(const QString &filename); @@ -57,11 +54,18 @@ public: public slots: void execute(); + /// Save the document under its current name, a file save dialog will be shown if this is a new document bool save(); + /// Saves the document under a new name and continue editing the document under this new name. bool saveAs(); + /// Save the document under a new name but continue editing the document under its old name. + void saveCopyAs(); + void copyQueryAsCString(); + void copyQueryAsRawCppString(); void explain(); void analyze(); void cancel(); + void exportData(); private: using ResultTabContainer = std::vector; diff --git a/pglab/QueryToolModule.cpp b/pglab/QueryToolModule.cpp index cc36d80..0cf0c4a 100644 --- a/pglab/QueryToolModule.cpp +++ b/pglab/QueryToolModule.cpp @@ -37,6 +37,30 @@ void QueryToolModule::init() wa.setIcon(":/icons/script_save.png"); registerWidgetAction(wa); } + { + LWidgetAction wa("Save copy of SQL as", SLOT(saveCopyAs())); + wa.setMenuLocation("File/Save"); + //wa.setIcon(":/icons/script_save.png"); + registerWidgetAction(wa); + } + { + LWidgetAction wa("&Export data", SLOT(exportData())); + wa.setMenuLocation("File/Export"); + wa.setIcon(":/icons/table_save.png"); + registerWidgetAction(wa); + } + { + LWidgetAction wa("Copy as C string", SLOT(copyQueryAsCString())); + wa.setMenuLocation("Edit/Copy"); + wa.setIcon(":/icons/token_shortland_character.png"); + registerWidgetAction(wa); + } + { + LWidgetAction wa("Copy as raw C++ string", SLOT(copyQueryAsRawCppString())); + wa.setMenuLocation("Edit/Copy"); + wa.setIcon(":/icons/token_shortland_character.png"); + registerWidgetAction(wa); + } { LWidgetAction wa("Execute", SLOT(execute())); wa.setMenuLocation("Query/1");