Patch #3524 2013-11-15 21:36

bat

Enhance Autosave feature (with restore)
Download
3524-Enhance_Autosa.patch (48.3 KB)
Category
Application::Refinement
Status
Open
Close date
 
Assigned to
 
Index: include/cbeditor.h
===================================================================
--- include/cbeditor.h    (revision 9454)
+++ include/cbeditor.h    (working copy)
@@ -108,6 +108,12 @@
         /** Returns true if editor is modified, false otherwise */
         bool GetModified() const;
 
+        /** Returns true if an autosaved, unaltered file is open in editor, false otherwise */
+        bool GetAutoSaved() const;
+
+        /** Set autosaved flag externally  */
+        void SetAutoSaved(bool flag);
+
         /** Set the editor's modification state to \c modified. */
         void SetModified(bool modified = true);
 
@@ -187,8 +193,8 @@
         /** Sets the last modification time for the file to 'now'. Used to detect modifications outside the editor. */
         void Touch();
 
-        /** Reloads the file from disk. @return True on success, False on failure. */
-        bool Reload(bool detectEncoding = true);
+        /** Reloads the file (or another, a save) from disk. @return True on success, False on failure. */
+        bool Reload(bool detectEncoding = true,const wxString &AlternateFilename = _T(""));
 
         /** Print the file.
           * @param selectionOnly Should the selected text be printed only?
@@ -322,7 +328,7 @@
         void SetEditorStyleAfterFileOpen();
         static void InternalSetEditorStyleBeforeFileOpen(cbStyledTextCtrl* control);
         static void InternalSetEditorStyleAfterFileOpen(cbStyledTextCtrl* control);
-        bool Open(bool detectEncoding = true);
+        bool Open(bool detectEncoding = true,const wxString &SavedFilename = _T(""));
         void DoAskForCodeCompletion(); // relevant to code-completion plugins
         static wxColour GetOptionColour(const wxString& option, const wxColour _default);
         void NotifyPlugins(wxEventType type, int intArg = 0, const wxString& strArg = wxEmptyString, int xArg = 0, int yArg = 0);
Index: include/cbproject.h
===================================================================
--- include/cbproject.h    (revision 9454)
+++ include/cbproject.h    (working copy)
@@ -124,6 +124,16 @@
           */
         void SetModified(bool modified = true);
 
+        /** Mark the project as autosaved recovery.
+          * @param AutoSaved If true, the project is marked as autosaved. If false, as not-AutoSaved.
+          */
+        void SetAutoSaved(bool AutoSaved = true);
+
+        /** Get AutoSaved flag
+          * @return true if open from autosaved file and not modified, false otherwise.
+          */
+        bool GetAutoSaved(void);
+
         /** Access a file of the project.
           * @param index The index of the file. Must be greater or equal than zero and less than GetFilesCount().
           * @return A pointer to the file or NULL if not found.
@@ -336,6 +346,14 @@
           */
         bool Save();
 
+        /** Save the project. (autosave feature)
+          * @return True if successful, false otherwise.
+          * @param FileName Filename to autosave project
+          * @param FileNameLayout Filename to autosave layout file
+          * @note No update of modified flag of project
+          */
+        bool SaveFullAuto(wxString &FileNamePrj,wxString &FileNameLayout);
+
         /** Save the project under a different name.
           * A dialog pops up for the user to choose a new filename for the project.
           * @return True if successful, false otherwise.
@@ -355,6 +373,13 @@
           */
         bool LoadLayout();
 
+        /** Load the project's layout.
+          * @see SaveLayout() for info.
+          * @param Filename filename for reading layout (if empty, take projet filename)
+          * @return True if successful, false otherwise.
+          */
+        bool LoadLayoutFile(wxString Filename);
+
         /** Notify that file(s) will be added shortly.
           * This function should be called before calling AddFile().
           * When done calling AddFile() as many times as needed, call
@@ -672,8 +697,13 @@
           */
         virtual FilesList& GetFilesList(){ return m_Files; }
 
+        /** Permit to force reopen of a project
+          * @param Filename : optional filename for reading layout (if empty, take projet filename)
+          */
+        void Open(wxString Filename = _(""));
+
     private:
-        void Open();
+
         void ExpandVirtualBuildTargetGroup(const wxString& alias, wxArrayString& result) const;
         ProjectBuildTarget* AddDefaultBuildTarget();
         int IndexOfBuildTargetName(const wxString& targetName) const;
@@ -696,6 +726,7 @@
         wxArrayString     m_ExpandedNodes;
         wxArrayString     m_SelectedNodes;
         bool              m_Loaded;
+        bool              m_AutoSaved;
         wxTreeItemId      m_ProjectNode;
 
         wxArrayString m_VirtualFolders; // not saved, just used throughout cbProject's lifetime
Index: include/cbworkspace.h
===================================================================
-
download for full patch...
bat 2013-11-16 18:15

-correction of _(" => _T(" where needed

-correction of one test missing to impact only ".save" and ".save" (logrotate)

alpha0010 2013-11-20 21:34