Tue, 16 Jul 2013 02:45:13 +0300
Finalized multi-file behavior. The future is here! :P
changelog.txt | file | annotate | diff | comparison | revisions | |
src/file.cpp | file | annotate | diff | comparison | revisions | |
src/file.h | file | annotate | diff | comparison | revisions | |
src/gui.cpp | file | annotate | diff | comparison | revisions | |
src/gui_actions.cpp | file | annotate | diff | comparison | revisions | |
src/ui/ldforge.ui | file | annotate | diff | comparison | revisions |
--- a/changelog.txt Tue Jul 16 02:09:22 2013 +0300 +++ b/changelog.txt Tue Jul 16 02:45:13 2013 +0300 @@ -3,6 +3,7 @@ ================================================= - Multiple files can now be kept open at the same time. A new list widget is on the left to contain the list of currently open files. + - Added close, close all and save all actions. - Color icon border now reflects the color's edge color. =================================================
--- a/src/file.cpp Tue Jul 16 02:09:22 2013 +0300 +++ b/src/file.cpp Tue Jul 16 02:45:13 2013 +0300 @@ -448,21 +448,12 @@ // Remove all loaded files and the objects they contain for (LDOpenFile* file : g_loadedFiles) delete file; - - // Clear the array - g_loadedFiles.clear(); - LDOpenFile::setCurrent (null); - - g_win->R()->setFile (null); - g_win->fullRefresh(); } // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void newFile () { - closeAll(); - // Create a new anonymous file and set it to our current LDOpenFile* f = new LDOpenFile; f->setName (""); @@ -470,6 +461,9 @@ g_loadedFiles << f; LDOpenFile::setCurrent (f); + if (g_loadedFiles.size() == 2) + LDOpenFile::closeInitialFile (0); + g_win->R()->setFile (f); g_win->fullRefresh(); g_win->updateTitle(); @@ -533,8 +527,8 @@ // If we have an anonymous, unchanged file open as the only open file // (aside of the one we just opened), close it now. - if (g_loadedFiles.size() == 2 && g_loadedFiles[0]->name() == "" && !g_loadedFiles[0]->hasUnsavedChanges()) - delete g_loadedFiles[0]; + if (g_loadedFiles.size() == 2) + LDOpenFile::closeInitialFile (0); // Rebuild the object tree view now. g_win->fullRefresh(); @@ -965,4 +959,9 @@ if (g_win && f) g_win->updateFileListItem (f); +} + +void LDOpenFile::closeInitialFile (ulong idx) { + if (g_loadedFiles.size() > idx && g_loadedFiles[idx]->name() == "" && !g_loadedFiles[idx]->hasUnsavedChanges()) + delete g_loadedFiles[idx]; } \ No newline at end of file
--- a/src/file.h Tue Jul 16 02:09:22 2013 +0300 +++ b/src/file.h Tue Jul 16 02:45:13 2013 +0300 @@ -127,6 +127,7 @@ static void closeUnused(); static LDOpenFile* current(); static void setCurrent (LDOpenFile* f); + static void closeInitialFile (ulong idx); private: static LDOpenFile* m_curfile;
--- a/src/gui.cpp Tue Jul 16 02:09:22 2013 +0300 +++ b/src/gui.cpp Tue Jul 16 02:45:13 2013 +0300 @@ -451,7 +451,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void ForgeWindow::slot_quickColor() { - LDOpenFile::current()->openHistory(); + beginAction (null); QToolButton* button = static_cast<QToolButton*> (sender()); LDColor* col = null; @@ -475,7 +475,7 @@ } fullRefresh(); - LDOpenFile::current()->closeHistory(); + endAction(); } // ============================================================================= @@ -897,7 +897,7 @@ } } - if (!f) + if (!f || f == LDOpenFile::current()) return; clearSelection();
--- a/src/gui_actions.cpp Tue Jul 16 02:09:22 2013 +0300 +++ b/src/gui_actions.cpp Tue Jul 16 02:45:13 2013 +0300 @@ -58,13 +58,11 @@ const LDBFCObject::Type BFCType = ui.rb_bfc_ccw->isChecked() ? LDBFCObject::CertifyCCW : - ui.rb_bfc_cw->isChecked() ? LDBFCObject::CertifyCW : - LDBFCObject::NoCertify; + ui.rb_bfc_cw->isChecked() ? LDBFCObject::CertifyCW : LDBFCObject::NoCertify; const str license = ui.rb_license_ca->isChecked() ? CALicense : - ui.rb_license_nonca->isChecked() ? NonCALicense : - ""; + ui.rb_license_nonca->isChecked() ? NonCALicense : ""; LDOpenFile* f = LDOpenFile::current(); *f << new LDCommentObject (ui.le_title->text());
--- a/src/ui/ldforge.ui Tue Jul 16 02:09:22 2013 +0300 +++ b/src/ui/ldforge.ui Tue Jul 16 02:45:13 2013 +0300 @@ -269,6 +269,9 @@ <addaction name="actionOpen"/> <addaction name="actionSave"/> <addaction name="actionSaveAs"/> + <addaction name="actionSaveAll"/> + <addaction name="actionClose"/> + <addaction name="actionCloseAll"/> </widget> <widget class="QToolBar" name="toolBar_2"> <property name="windowTitle">