Date Dev Ver Change details
---------- --- ------ --------------
+2009-11-19 GL 1.12.0 Support for drag-and-drop of a file in the query tool.
2009-11-16 GL 1.10.1 Fix an issue with the ordering of the mappings in a
text search configuration.
2009-10-28 DP 1.12.0 Extend the branding code to allow the vendor-specific
#include <wx/busyinfo.h>
#include <wx/clipbrd.h>
#include <wx/dcbuffer.h>
+#include <wx/dnd.h>
#include <wx/filename.h>
#include <wx/regex.h>
#include <wx/textctrl.h>
EVT_SPLITTER_SASH_POS_CHANGED(GQB_HORZ_SASH, frmQuery::OnResizeHorizontally)
END_EVENT_TABLE()
+class DnDFile : public wxFileDropTarget
+{
+ public:
+ DnDFile(frmQuery * fquery) { m_fquery = fquery; }
+
+ virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames)
+ {
+ size_t nFiles = filenames.GetCount();
+ if ((int) nFiles > 1)
+ wxLogError(wxT("Drag one file at a time"));
+ else if ((int) nFiles == 1)
+ {
+ wxString str;
+ bool modeUnicode = settings->GetUnicodeFile();
+ wxUtfFile file(filenames[0], wxFile::read, modeUnicode ? wxFONTENCODING_UTF8:wxFONTENCODING_DEFAULT);
+
+ if (file.IsOpened())
+ file.Read(str);
+
+ if (!str.IsEmpty() && !m_fquery->CheckChanged(true))
+ {
+ m_fquery->SetLastPath(filenames[0]);
+ m_fquery->SetQueryText(str);
+ m_fquery->ColouriseQuery(0, str.Length());
+ wxSafeYield(); // needed to process sqlQuery modify event
+ m_fquery->SetChanged(false);
+ m_fquery->setExtendedTitle();
+ m_fquery->SetLineEndingStyle();
+ m_fquery->UpdateRecentFiles();
+ }
+ }
+ return true;
+ }
+
+ private:
+ frmQuery * m_fquery;
+};
+
+
frmQuery::frmQuery(frmMain *form, const wxString& _title, pgConn *_conn, const wxString& query, const wxString& file)
: pgFrame(NULL, _title),
timer(this,CTL_TIMERFRM),
sqlQuery = new ctlSQLBox(sqlNotebook, CTL_SQLQUERY, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxSIMPLE_BORDER | wxTE_RICH2);
sqlQuery->SetDatabase(conn);
sqlQuery->SetMarginWidth(1, 16);
+ sqlQuery->SetDropTarget(new DnDFile(this));
SetEOLModeDisplay(sqlQuery->GetEOLMode());
// Results pane
void RestorePosition(int defaultX=-1, int defaultY=-1, int defaultW=-1, int defaultH=-1, int minW=100, int minH=70);
void SavePosition();
void OnAction(wxCommandEvent& event);
+
+ void UpdateRecentFiles();
+
menuFactoryList *GetMenuFactories() { return menuFactories; }
protected:
virtual bool CheckChanged(bool canVeto) { return false; }
virtual wxString GetHelpPage() const { return wxEmptyString; }
- void UpdateRecentFiles();
-
windowList frames;
menuFactoryList *menuFactories;
wxString dlgName;
void Go();
void writeScriptOutput();
+ void setExtendedTitle();
+ void SetLineEndingStyle();
+
+ void SetQueryText(wxString str) { sqlQuery->SetText(str); }
+ void ColouriseQuery(int start, int stop) { sqlQuery->Colourise(start, stop); }
+ void SetChanged(bool p_changed) { changed = p_changed; }
+ void SetLastPath(wxString p_lastpath) { lastPath = p_lastpath; }
+ bool CheckChanged(bool canVeto);
private:
frmMain *mainForm;
void OnTimer(wxTimerEvent & event);
- bool CheckChanged(bool canVeto);
void OpenLastFile();
void updateMenu(wxObject *obj=0);
void execQuery(const wxString &query, int resultToRetrieve=0, bool singleResult=false, const int queryOffset=0, bool toFile=false, bool explain=false, bool verbose=false);
void OnScriptComplete(wxCommandEvent &ev);
void setTools(const bool running);
void showMessage(const wxString& msg, const wxString &msgShort=wxT(""));
- void setExtendedTitle();
void UpdateFavouritesList();
- void SetLineEndingStyle();
int GetLineEndingStyle();
void OnSetEOLMode(wxCommandEvent& event);
void SetEOLModeDisplay(int mode);