diff --git a/pgadmin/ctl/ctlSQLResult.cpp b/pgadmin/ctl/ctlSQLResult.cpp index 30b627f..7d9ecda 100644 --- a/pgadmin/ctl/ctlSQLResult.cpp +++ b/pgadmin/ctl/ctlSQLResult.cpp @@ -73,6 +73,15 @@ bool ctlSQLResult::ToFile() return false; } +bool ctlSQLResult::ToFile(frmExport *frm) +{ + if (NumRows() > 0) + { + return frm->Export(thread->DataSet()); + } + return false; +} + bool ctlSQLResult::IsColText(int col) { switch (colTypClasses.Item(col)) diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp index 1ed638f..1ceeed3 100644 --- a/pgadmin/frm/frmQuery.cpp +++ b/pgadmin/frm/frmQuery.cpp @@ -2224,11 +2224,24 @@ void frmQuery::execQuery(const wxString &query, int resultToRetrieve, bool singl QueryExecInfo *qi = new QueryExecInfo(); qi->queryOffset = queryOffset; - qi->toFile = toFile; + qi->toFileExportForm = NULL; qi->singleResult = singleResult; qi->explain = explain; qi->verbose = verbose; + if (toFile) + { + qi->toFileExportForm = new frmExport(this); + if (qi->toFileExportForm->ShowModal() != wxID_OK) + { + delete qi->toFileExportForm; + delete qi; + setTools(false); + aborted = true; + return; + } + } + // We must do this lot before the query starts, otherwise // it might not happen once the main thread gets busy with // other stuff. @@ -2383,7 +2396,7 @@ void frmQuery::OnQueryComplete(wxCommandEvent &ev) outputPane->SetSelection(0); long rowsTotal=sqlResult->NumRows(); - if (qi->toFile) + if (qi->toFileExportForm) { SetStatusText(wxString::Format(wxPLURAL("%d row.", "%d rows.", rowsTotal), rowsTotal), STATUSPOS_ROWS); @@ -2395,7 +2408,7 @@ void frmQuery::OnQueryComplete(wxCommandEvent &ev) queryMenu->Enable(MNU_CANCEL, false); SetCursor(*wxHOURGLASS_CURSOR); - if (sqlResult->ToFile()) + if (sqlResult->ToFile(qi->toFileExportForm)) SetStatusText(_("Data written to file."), STATUSPOS_MSGS); else SetStatusText(_("Data export aborted."), STATUSPOS_MSGS); diff --git a/pgadmin/include/ctl/ctlSQLResult.h b/pgadmin/include/ctl/ctlSQLResult.h index f4b8ba0..fbb8963 100644 --- a/pgadmin/include/ctl/ctlSQLResult.h +++ b/pgadmin/include/ctl/ctlSQLResult.h @@ -18,6 +18,7 @@ #include "db/pgSet.h" #include "db/pgConn.h" #include "ctlSQLGrid.h" +#include "frm/frmExport.h" #define CTLSQL_RUNNING 100 // must be greater than ExecStatusType PGRES_xxx values @@ -38,6 +39,7 @@ public: bool Export(); bool ToFile(); + bool ToFile(frmExport *frm); bool CanExport() { return NumRows() >0 && colNames.GetCount() > 0; } wxString OnGetItemText(long item, long col) const; diff --git a/pgadmin/include/frm/frmQuery.h b/pgadmin/include/frm/frmQuery.h index 5c7d580..0f75cc1 100644 --- a/pgadmin/include/frm/frmQuery.h +++ b/pgadmin/include/frm/frmQuery.h @@ -15,6 +15,7 @@ #include "dlg/dlgClasses.h" #include "gqb/gqbViewController.h" #include "gqb/gqbModel.h" +#include "frm/frmExport.h" #include "utils/factory.h" #include "utils/favourites.h" #include "utils/macros.h" @@ -50,7 +51,7 @@ class QueryExecInfo { public: int queryOffset; - bool toFile; + frmExport *toFileExportForm; bool singleResult; bool explain; bool verbose;