summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/project.cpp65
-rw-r--r--common/project.h21
2 files changed, 38 insertions, 48 deletions
diff --git a/common/project.cpp b/common/project.cpp
index 8bb36c5..b478600 100644
--- a/common/project.cpp
+++ b/common/project.cpp
@@ -1597,6 +1597,31 @@ bool Project::OnNewDocument()
return true;
}
+bool Project::OpenProject(const char* FileName)
+{
+ if (!SaveModified())
+ return false; // Leave the original one
+
+// CWaitCursor wait;
+ bool WasModified = IsModified();
+ SetModifiedFlag(false); // Not dirty for open
+
+ if (!OnOpenDocument(FileName))
+ {
+ // Check if we corrupted the original document
+ if (!IsModified())
+ SetModifiedFlag(WasModified);
+ else
+ OnNewDocument();
+
+ return false; // Open failed
+ }
+
+ SetPathName(FileName, true);
+
+ return true;
+}
+
bool Project::OnOpenDocument (const char* lpszPathName)
{
FileDisk file;
@@ -3626,24 +3651,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
if (SystemDoDialog(LC_DLG_FILE_OPEN_PROJECT, filename))
{
- if (!SaveModified())
- return; // leave the original one
-
-// CWaitCursor wait;
- bool bWasModified = IsModified();
- SetModifiedFlag(false); // not dirty for open
-
- if (!OnOpenDocument(filename))
- {
- // check if we corrupted the original document
- if (!IsModified())
- SetModifiedFlag(bWasModified);
- else
- OnNewDocument();
-
- return; // open failed
- }
- SetPathName(filename, true);
+ OpenProject(filename);
}
} break;
@@ -4573,26 +4581,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
case LC_FILE_RECENT:
{
- if (!SaveModified())
- break; // leave the original one
-
-// CWaitCursor wait;
- bool bWasModified = IsModified();
- SetModifiedFlag(false); // not dirty for open
- String filename = main_window->GetMRU (nParam);
-
- if (!OnOpenDocument (filename))
- {
- // check if we corrupted the original document
- if (!IsModified ())
- SetModifiedFlag (bWasModified);
- else
- OnNewDocument ();
-
- main_window->RemoveFromMRU (nParam);
- return; // open failed
- }
- SetPathName (filename, true);
+ OpenProject(main_window->GetMRU(nParam));
} break;
case LC_EDIT_UNDO:
diff --git a/common/project.h b/common/project.h
index 8c57eb7..42529ae 100644
--- a/common/project.h
+++ b/common/project.h
@@ -283,19 +283,20 @@ protected:
Texture* m_pBackground;
protected:
- // File load/save implementation.
- bool DoSave(char* lpszPathName, bool bReplace);
- bool DoFileSave();
- bool FileLoad(File* file, bool bUndo, bool bMerge);
- void FileSave(File* file, bool bUndo);
- void FileReadLDraw(File* file, Matrix* prevmat, int* nOk, int DefColor, int* nStep, PtrArray<File>& FileArray);
- void FileReadMPD(File& MPD, PtrArray<File>& FileArray) const;
+ // File load/save implementation.
+ bool DoSave(char* lpszPathName, bool bReplace);
+ bool DoFileSave();
+ bool FileLoad(File* file, bool bUndo, bool bMerge);
+ void FileSave(File* file, bool bUndo);
+ void FileReadLDraw(File* file, Matrix* prevmat, int* nOk, int DefColor, int* nStep, PtrArray<File>& FileArray);
+ void FileReadMPD(File& MPD, PtrArray<File>& FileArray) const;
public:
// File helpers
- bool OnNewDocument ();
- bool OnOpenDocument (const char* lpszPathName);
- bool SaveModified ();
+ bool OnNewDocument();
+ bool OnOpenDocument(const char* FileName);
+ bool OpenProject(const char* FileName);
+ bool SaveModified();
protected:
// mail enabling