]> git.lyx.org Git - features.git/commitdiff
Rename closeBufferAll to closeWorkAreaAll (because that's what we do). Add a new...
authorVincent van Ravesteijn <vfr@lyx.org>
Tue, 18 Aug 2009 20:12:34 +0000 (20:12 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Tue, 18 Aug 2009 20:12:34 +0000 (20:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31125 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h

index d44065f07c506500c1cf353fcd8754a2af812b84..36739dbc797abc3c13204543e25ce18896d966a5 100644 (file)
@@ -584,34 +584,6 @@ void GuiView::closeEvent(QCloseEvent * close_event)
 }
 
 
-bool GuiView::closeBufferAll(bool in_close_event)
-{
-       GuiWorkArea * active_wa = currentMainWorkArea();
-       setCurrentWorkArea(active_wa);
-
-       // We might be in a situation that there is still a tabWorkArea, but
-       // there are no tabs anymore. This can happen when we get here after a 
-       // TabWorkArea::lastWorkAreaRemoved() signal. Therefore we count how
-       // many TabWorkArea's have no documents anymore.
-       int empty_twa = 0;
-
-       // We have to call count() each time, because it can happen that
-       // more than one splitter will disappear in one iteration (bug 5998).
-       for (; d.splitter_->count() > empty_twa; ) {
-               TabWorkArea * twa = d.tabWorkArea(empty_twa);
-                               
-               if (twa->count() == 0)
-                       ++empty_twa;
-               else {
-                       setCurrentWorkArea(twa->currentWorkArea());
-                       if (!closeTabWorkArea(twa, true, active_wa))
-                               return false;
-               }
-       }
-       return true;
-}
-
-
 void GuiView::dragEnterEvent(QDragEnterEvent * event)
 {
        if (event->mimeData()->hasUrls())
@@ -1903,6 +1875,48 @@ bool GuiView::closeBuffer()
 }
 
 
+bool GuiView::closeBufferAll(bool in_close_event)
+{
+       // First close all workareas. This will make
+       // sure that dirty buffers are saved.
+       if (!closeWorkAreaAll(in_close_event))
+               return false;
+
+       // Now close the hidden buffers. We prevent hidden 
+       // buffers from being dirty, so we can just close them.
+       theBufferList().closeAll();
+       return true;
+}
+
+
+bool GuiView::closeWorkAreaAll(bool in_close_event)
+{
+       GuiWorkArea * active_wa = currentMainWorkArea();
+       setCurrentWorkArea(active_wa);
+
+       // We might be in a situation that there is still a tabWorkArea, but
+       // there are no tabs anymore. This can happen when we get here after a 
+       // TabWorkArea::lastWorkAreaRemoved() signal. Therefore we count how
+       // many TabWorkArea's have no documents anymore.
+       int empty_twa = 0;
+
+       // We have to call count() each time, because it can happen that
+       // more than one splitter will disappear in one iteration (bug 5998).
+       for (; d.splitter_->count() > empty_twa; ) {
+               TabWorkArea * twa = d.tabWorkArea(empty_twa);
+                               
+               if (twa->count() == 0)
+                       ++empty_twa;
+               else {
+                       setCurrentWorkArea(twa->currentWorkArea());
+                       if (!closeTabWorkArea(twa, true, active_wa))
+                               return false;
+               }
+       }
+       return true;
+}
+
+
 bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer,
        bool in_close_event, bool mark_active)
 {
index 140d494b7fc0ea680cce592d1a2a36571707bf44..e2a1d49bb6e7ba89e70e887466318efb33e6da39 100644 (file)
@@ -309,6 +309,8 @@ private:
        bool saveBufferIfNeeded(Buffer & buf, bool hiding);
        ///
        bool closeBufferAll(bool in_close_event = false);
+       ///
+       bool closeWorkAreaAll(bool in_close_event = false);
        /// is the buffer in this workarea also shown in another tab ?
        /// This tab can either be in the same view or in another one.
        bool inMultiTabs(GuiWorkArea * wa);