Patch #3260 2012-03-20 16:34

ranras

Move QueryClose() functionality to EditorBase
Download
3260-Move_QueryClos.patch (2.3 KB)
Category
Application::Refinement
Status
Accepted
Close date
2012-09-04 14:37
Assigned to
mortenmacfly
Index: src/sdk/editorbase.cpp
===================================================================
--- src/sdk/editorbase.cpp    (Revision 7905)
+++ src/sdk/editorbase.cpp    (Arbeitskopie)
@@ -175,6 +175,28 @@
     Manager::Get()->GetEditorManager()->SetActiveEditor(this);
 }
 
+bool EditorBase::QueryClose()
+{
+    if (GetModified())
+    {
+        wxString msg;
+        msg.Printf(_("File %s is modified...\nDo you want to save the changes?"), GetFilename().c_str());
+        switch (cbMessageBox(msg, _("Save file"), wxICON_QUESTION | wxYES_NO | wxCANCEL))
+        {
+        case wxID_YES:
+            if (!Save())
+                return false;
+            break;
+        case wxID_NO:
+            break;
+        case wxID_CANCEL:
+            return false;
+        }
+        SetModified(false);
+    }
+    return true;
+}
+
 bool EditorBase::Close()
 {
     Destroy();
Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp    (Revision 7905)
+++ src/sdk/editormanager.cpp    (Arbeitskopie)
@@ -747,29 +747,7 @@
 {
     if (!ed)
         return true;
-    if (ed->GetModified())
-    {
-        // TODO (mandrav#1#): Move this in EditorBase
-        wxString msg;
-        msg.Printf(_("File %s is modified...\nDo you want to save the changes?"), ed->GetFilename().c_str());
-        switch (cbMessageBox(msg, _("Save file"), wxICON_QUESTION | wxYES_NO | wxCANCEL))
-        {
-        case wxID_YES:
-            if (!ed->Save())
-                return false;
-            break;
-        case wxID_NO:
-            break;
-        case wxID_CANCEL:
-            return false;
-        }
-        ed->SetModified(false);
-    }
-    else
-    {
-        return ed->QueryClose();
-    }
-    return true;
+    return ed->QueryClose();
 }
 
 int EditorManager::FindPageFromEditor(EditorBase* eb)
Index: src/include/editorbase.h
===================================================================
--- src/include/editorbase.h    (Revision 7905)
+++ src/include/editorbase.h    (Arbeitskopie)
@@ -92,7 +92,7 @@
           * close it (i.e. it is not modified).
           * @return True if this editor can be closed.
           */
-        virtual bool QueryClose(){ return true; }
+        virtual bool QueryClose();
 
         /** @brief Close this editor.
           *
ranras 2012-03-20 16:37

This patch moves the QueryClose() functionality from EditorManager to EditorBase. It makes it possible to override this function by other non standard editors

mortenmacfly 2012-07-07 14:42

Applied in SVN. Thank you!

ranras 2012-08-26 17:45

The patch isn't applied in SVN, at least not at berlios.

Could you please apply it. Thank you!