]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiView.cpp
Don't hide dialogs upon buffer switch. I've been wanting to do this for a looonnng...
[lyx.git] / src / frontends / qt4 / GuiView.cpp
index 2ff88433a7735ba35144079ed8067238fc1b6f60..215cdeb16057b5ea6f52b38dcaa8b94a2d03b8d7 100644 (file)
@@ -18,6 +18,7 @@
 #include "Dialog.h"
 #include "FileDialog.h"
 #include "GuiApplication.h"
+#include "GuiCompleter.h"
 #include "GuiWorkArea.h"
 #include "GuiKeySymbol.h"
 #include "GuiToolbar.h"
@@ -55,7 +56,6 @@
 
 #include "support/assert.h"
 #include "support/debug.h"
-#include "support/FileFilterList.h"
 #include "support/FileName.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
@@ -411,7 +411,7 @@ void GuiView::closeEvent(QCloseEvent * close_event)
                                break;
                        }
                }
-               if (b && !closeBuffer(*b)) {
+               if (b && !closeBuffer(*b, true)) {
                        close_event->ignore();
                        return;
                }
@@ -784,7 +784,6 @@ void GuiView::removeWorkArea(GuiWorkArea * wa)
        if (wa == d.current_work_area_) {
                disconnectBuffer();
                disconnectBufferView();
-               hideBufferDependent();
                d.current_work_area_ = 0;
        }
 
@@ -1117,9 +1116,8 @@ static FileName selectTemplateFile()
        dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
        dlg.setButton1(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
 
-       FileDialog::Result result =
-               dlg.open(toqstr(lyxrc.template_path),
-                            FileFilterList(_("LyX Documents (*.lyx)")));
+       FileDialog::Result result = dlg.open(toqstr(lyxrc.template_path),
+                            QStringList(qt_("LyX Documents (*.lyx)")));
 
        if (result.first == FileDialog::Later)
                return FileName();
@@ -1178,7 +1176,7 @@ void GuiView::openDocument(string const & fname)
                                toqstr(addPath(package().system_support().absFilename(), "examples")));
 
                FileDialog::Result result =
-                       dlg.open(toqstr(initpath), FileFilterList(_("LyX Documents (*.lyx)")));
+                       dlg.open(toqstr(initpath), QStringList(qt_("LyX Documents (*.lyx)")));
 
                if (result.first == FileDialog::Later)
                        return;
@@ -1317,7 +1315,7 @@ void GuiView::importDocument(string const & argument)
                filter += ')';
 
                FileDialog::Result result =
-                       dlg.open(toqstr(initpath), FileFilterList(filter));
+                       dlg.open(toqstr(initpath), fileFilters(toqstr(filter)));
 
                if (result.first == FileDialog::Later)
                        return;
@@ -1333,7 +1331,7 @@ void GuiView::importDocument(string const & argument)
                return;
 
        // get absolute path of file
-       FileName const fullname(makeAbsPath(filename));
+       FileName const fullname(support::makeAbsPath(filename));
 
        FileName const lyxfile(support::changeExtension(fullname.absFilename(), ".lyx"));
 
@@ -1430,9 +1428,8 @@ void GuiView::insertLyXFile(docstring const & fname)
                toqstr(addPath(package().system_support().absFilename(),
                "examples")));
 
-       FileDialog::Result result =
-               dlg.open(toqstr(initpath),
-                            FileFilterList(_("LyX Documents (*.lyx)")));
+       FileDialog::Result result = dlg.open(toqstr(initpath),
+                            QStringList(qt_("LyX Documents (*.lyx)")));
 
        if (result.first == FileDialog::Later)
                return;
@@ -1470,7 +1467,7 @@ void GuiView::insertPlaintextFile(docstring const & fname,
                LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
 
        FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
-               FileFilterList());
+               QStringList());
 
        if (result.first == FileDialog::Later)
                return;
@@ -1496,7 +1493,7 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
 
        if (!newname.empty()) {
                // FIXME UNICODE
-               fname = makeAbsPath(to_utf8(newname), oldname.onlyPath().absFilename());
+               fname = support::makeAbsPath(to_utf8(newname), oldname.onlyPath().absFilename());
        } else {
                // Switch to this Buffer.
                setBuffer(&b);
@@ -1511,11 +1508,9 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
                if (!isLyXFilename(fname.absFilename()))
                        fname.changeExtension(".lyx");
 
-               FileFilterList const filter(_("LyX Documents (*.lyx)"));
-
                FileDialog::Result result =
                        dlg.save(toqstr(fname.onlyPath().absFilename()),
-                                    filter,
+                              QStringList(qt_("LyX Documents (*.lyx)")),
                                     toqstr(fname.onlyFileName()));
 
                if (result.first == FileDialog::Later)
@@ -1605,7 +1600,7 @@ bool GuiView::closeBuffer()
 }
 
 
-bool GuiView::closeBuffer(Buffer & buf)
+bool GuiView::closeBuffer(Buffer & buf, bool tolastopened)
 {
        // goto bookmark to update bookmark pit.
        //FIXME: we should update only the bookmarks related to this buffer!
@@ -1613,7 +1608,7 @@ bool GuiView::closeBuffer(Buffer & buf)
                theLyXFunc().gotoBookmark(i+1, false, false);
 
        if (buf.isClean() || buf.paragraphs().empty()) {
-               if (buf.masterBuffer() == &buf)
+               if (buf.masterBuffer() == &buf && tolastopened)
                        LyX::ref().session().lastOpened().add(buf.fileName());
                theBufferList().release(&buf);
                return true;
@@ -1655,7 +1650,7 @@ bool GuiView::closeBuffer(Buffer & buf)
        // save file names to .lyx/session
        // if master/slave are both open, do not save slave since it
        // will be automatically loaded when the master is loaded
-       if (buf.masterBuffer() == &buf)
+       if (buf.masterBuffer() == &buf && tolastopened)
                LyX::ref().session().lastOpened().add(buf.fileName());
 
        theBufferList().release(&buf);
@@ -2152,19 +2147,6 @@ void GuiView::hideAll() const
 }
 
 
-void GuiView::hideBufferDependent() const
-{
-       map<string, DialogPtr>::const_iterator it  = d.dialogs_.begin();
-       map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
-
-       for(; it != end; ++it) {
-               Dialog * dialog = it->second.get();
-               if (dialog->isBufferDependent())
-                       dialog->hideView();
-       }
-}
-
-
 void GuiView::updateBufferDependent(bool switched) const
 {
        map<string, DialogPtr>::const_iterator it  = d.dialogs_.begin();