]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiView.cpp
File->Close All now really closes all buffers. That is, all visible buffers in all...
[lyx.git] / src / frontends / qt4 / GuiView.cpp
index 6821bbdd59acdac74d885c33be45b34826f7606c..c92103062a2825b8e5ac76032da303c7e8ca9d83 100644 (file)
@@ -544,6 +544,8 @@ void GuiView::closeEvent(QCloseEvent * close_event)
        LYXERR(Debug::DEBUG, "GuiView::closeEvent()");
        closing_ = true;
 
+       writeSession();
+
        // it can happen that this event arrives without selecting the view,
        // e.g. when clicking the close button on a background window.
        setFocus();
@@ -1080,7 +1082,7 @@ void GuiView::connectBuffer(Buffer & buf)
 void GuiView::disconnectBuffer()
 {
        if (d.current_work_area_)
-               d.current_work_area_->bufferView().setGuiDelegate(0);
+               d.current_work_area_->bufferView().buffer().setGuiDelegate(0);
 }
 
 
@@ -1186,21 +1188,9 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                enable = buf;
                break;
 
-       case LFUN_BUFFER_CLOSE_ALL: {
-               enable = false;
-               BufferList::iterator it = theBufferList().begin();
-               BufferList::iterator end = theBufferList().end();
-               int visible_buffers = 0;
-               for (; it != end; ++it) {
-                       if (workArea(**it))
-                               ++visible_buffers;
-                       if (visible_buffers > 1) {
-                               enable = true;
-                               break;
-                       }
-               }
+       case LFUN_BUFFER_CLOSE_ALL:
+               enable = theBufferList().last() != theBufferList().first();
                break;
-       }
 
        case LFUN_SPLIT_VIEW:
                if (cmd.getArg(0) == "vertical")
@@ -1875,10 +1865,29 @@ bool GuiView::closeBuffer()
 }
 
 
+void GuiView::writeSession() const {
+       GuiWorkArea const * active_wa = currentMainWorkArea();
+       for (int i = 0; i < d.splitter_->count(); ++i) {
+               TabWorkArea * twa = d.tabWorkArea(i);
+               for (int j = 0; j < twa->count(); ++j) {
+                       GuiWorkArea * wa = static_cast<GuiWorkArea *>(twa->widget(j));
+                       Buffer & buf = wa->bufferView().buffer();
+                       theSession().lastOpened().add(buf.fileName(), wa == active_wa);
+               }
+       }
+}
+
+
 bool GuiView::closeBufferAll()
 {
-       // First close all workareas. This will make
-       // sure that dirty buffers are saved.
+       // Close the workareas in all other views
+       QList<int> const ids = guiApp->viewIds();
+       for (int i = 0; i != ids.size(); ++i) {
+               if (id_ != ids[i] && !guiApp->view(ids[i]).closeWorkAreaAll())
+                       return false;
+       }
+
+       // Close our own workareas
        if (!closeWorkAreaAll())
                return false;