diff --git a/ctl/ctlSQLBox.cpp b/ctl/ctlSQLBox.cpp index 9a75edb..ccecc5d 100644 --- a/ctl/ctlSQLBox.cpp +++ b/ctl/ctlSQLBox.cpp @@ -68,6 +68,7 @@ ctlSQLBox::ctlSQLBox() m_autocompDisabled = false; process = 0; processID = 0; + m_filename = wxEmptyString; } @@ -238,10 +239,18 @@ int ctlSQLBox::GetOrigin() { return m_origin; } +bool ctlSQLBox::IsFileModification() +{ + if (!m_filename.IsEmpty()) { + return time_file_mod != wxFileModificationTime(m_filename); + } + return false; +} void ctlSQLBox::SetFilename(wxString &filename) { m_filename = filename; + time_file_mod = wxFileModificationTime(filename); UpdateTitle(); } diff --git a/frm/frmQuery.cpp b/frm/frmQuery.cpp index 261069c..767513e 100644 --- a/frm/frmQuery.cpp +++ b/frm/frmQuery.cpp @@ -2441,6 +2441,7 @@ void frmQuery::OnSave(wxCommandEvent &event) setExtendedTitle(); UpdateRecentFiles(); SqlBookUpdatePageTitle(); + sqlQuery->SetFilename(filename); } else { @@ -2942,6 +2943,7 @@ void frmQuery::OnExecute(wxCommandEvent &event) if (!updateFromGqb(true)) return; } + CheckModificationFile(); SaveTempFile(); wxString query = sqlQuery->GetSelectedText(); if (query.IsNull()) @@ -4307,6 +4309,15 @@ void frmQuery::fileMarkerActive(bool addOrRemove, const wxString &sqlTabName) { if (wxFileName::FileExists(fn)) wxRemoveFile(fn); } +void frmQuery::CheckModificationFile() { + if (sqlQuery!=NULL && sqlQuery->IsFileModification()) { + if (wxMessageBox("File " + sqlQuery->GetFilename() + " has been changed.\nReload file?", + "Reload sql file", + wxICON_EXCLAMATION | wxYES_NO) == wxYES) + OpenLastFile(); + + } +} void frmQuery::OnSqlBookPageChanged(wxAuiNotebookEvent &event) { // Try to always keep sqlQuery variable pointing to the currently selected SQLBox. @@ -4347,6 +4358,9 @@ void frmQuery::OnSqlBookPageChanged(wxAuiNotebookEvent &event) sqlQuery->SetFocus(); if (sqlQueryBook->GetPageCount() > 1) fileMarkerActive(true, sqlQueryBook->GetPageText(sqlQueryBook->GetSelection())); //wxMessageBox(wxT("OnSqlBookPageChanged ")); + + CheckModificationFile(); + updateMenu(false); wxTheApp->Yield(true); } diff --git a/include/ctl/ctlSQLBox.h b/include/ctl/ctlSQLBox.h index 5d8b2d5..558b7cc 100644 --- a/include/ctl/ctlSQLBox.h +++ b/include/ctl/ctlSQLBox.h @@ -91,6 +91,7 @@ public: void SetOrigin(int origin); int GetOrigin(); void SetFilename(wxString &filename); + bool IsFileModification(); wxString GetFilename(); void SetTitle(wxString &title); wxString GetTitle(bool withChangeInd = true); @@ -125,6 +126,7 @@ private: // Variables to track info per SQL box wxString m_filename; + time_t time_file_mod; wxString m_title; wxString m_changestr; bool m_changed; diff --git a/include/frm/frmQuery.h b/include/frm/frmQuery.h index a9f2338..f6e7ee8 100644 --- a/include/frm/frmQuery.h +++ b/include/frm/frmQuery.h @@ -311,6 +311,7 @@ private: void OnSqlBookPageClose(wxAuiNotebookEvent &event); void OnSqlBookPageClosed(wxAuiNotebookEvent &event); void OnSqlBookPageChanged(wxAuiNotebookEvent &event); + void CheckModificationFile(); void OnSqlBookPageChanging(wxAuiNotebookEvent &event); void OnSqlBookTabRDown(wxAuiNotebookEvent &event); void OnNotebookOutpaneTabRDown(wxAuiNotebookEvent &event); diff --git a/x64/Release_(3.0)/pgAdmin3.exe b/x64/Release_(3.0)/pgAdmin3.exe index 70a9775..b90d300 100644 Binary files a/x64/Release_(3.0)/pgAdmin3.exe and b/x64/Release_(3.0)/pgAdmin3.exe differ