From c1696ccae3c94252ffde788377c8c2d20429c858 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sat, 19 Sep 2009 16:49:31 +0000 Subject: [PATCH] * Move LFUN_BUFFER_CHILD_OPEN to GuiView. * GuiView:openChildDocument(): New helper method, I removed the comment about bug 3970 because it doesn't apply anymore with this change. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31409 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 34 ------------------------------ src/frontends/qt4/GuiView.cpp | 39 +++++++++++++++++++++++++++++++++++ src/frontends/qt4/GuiView.h | 2 ++ 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index bf893e8984..05c8d471f4 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -563,7 +563,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const case LFUN_SERVER_GET_FILENAME: case LFUN_SERVER_NOTIFY: case LFUN_SERVER_GOTO_FILE_ROW: - case LFUN_BUFFER_CHILD_OPEN: case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE: case LFUN_KEYMAP_OFF: case LFUN_KEYMAP_PRIMARY: @@ -964,39 +963,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd) break; } - case LFUN_BUFFER_CHILD_OPEN: { - LASSERT(lyx_view_ && buffer, /**/); - FileName filename = makeAbsPath(argument, buffer->filePath()); - lyx_view_->documentBufferView()->saveBookmark(false); - Buffer * child = 0; - bool parsed = false; - if (theBufferList().exists(filename)) { - child = theBufferList().getBuffer(filename); - } else { - setMessage(bformat(_("Opening child document %1$s..."), - makeDisplayPath(filename.absFilename()))); - child = lyx_view_->loadDocument(filename, false); - parsed = true; - } - if (child) { - // Set the parent name of the child document. - // This makes insertion of citations and references in the child work, - // when the target is in the parent or another child document. - child->setParent(buffer); - child->masterBuffer()->updateLabels(); - lyx_view_->setBuffer(child); - if (parsed) - child->errors("Parse"); - } - - // If a screen update is required (in case where auto_open is false), - // setBuffer() would have taken care of it already. Otherwise we shall - // reset the update flag because it can cause a circular problem. - // See bug 3970. - updateFlags = Update::None; - break; - } - case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE: LASSERT(lyx_view_, /**/); lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index ee10e3d692..d5be28d86c 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -66,6 +66,7 @@ #include "support/FileName.h" #include "support/filetools.h" #include "support/gettext.h" +#include "support/filetools.h" #include "support/ForkedCalls.h" #include "support/lassert.h" #include "support/lstrings.h" @@ -1201,6 +1202,10 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag) || doc_buffer->isExternallyModified(Buffer::timestamp_method)); break; + case LFUN_BUFFER_CHILD_OPEN: + enable = doc_buffer; + break; + case LFUN_BUFFER_WRITE: enable = doc_buffer && (doc_buffer->isUnnamed() || !doc_buffer->isClean()); break; @@ -2343,6 +2348,36 @@ void GuiView::dispatchVC(FuncRequest const & cmd) } +void GuiView::openChildDocument(string const & fname) +{ + LASSERT(documentBufferView(), return); + Buffer & buffer = documentBufferView()->buffer(); + FileName const filename = support::makeAbsPath(fname, buffer.filePath()); + documentBufferView()->saveBookmark(false); + Buffer * child = 0; + bool parsed = false; + if (theBufferList().exists(filename)) { + child = theBufferList().getBuffer(filename); + } else { + message(bformat(_("Opening child document %1$s..."), + makeDisplayPath(filename.absFilename()))); + child = loadDocument(filename, false); + parsed = true; + } + if (!child) + return; + + // Set the parent name of the child document. + // This makes insertion of citations and references in the child work, + // when the target is in the parent or another child document. + child->setParent(&buffer); + child->masterBuffer()->updateLabels(); + setBuffer(child); + if (parsed) + child->errors("Parse"); +} + + bool GuiView::dispatch(FuncRequest const & cmd) { BufferView * bv = currentBufferView(); @@ -2362,6 +2397,10 @@ bool GuiView::dispatch(FuncRequest const & cmd) } switch(cmd.action) { + case LFUN_BUFFER_CHILD_OPEN: + openChildDocument(to_utf8(cmd.argument())); + break; + case LFUN_BUFFER_IMPORT: importDocument(to_utf8(cmd.argument())); break; diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index 080e46e34b..65059c63b2 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -171,6 +171,8 @@ private Q_SLOTS: void bigSizedIcons(); private: + /// Open given child document in current buffer directory. + void openChildDocument(std::string const & filename); /// Close current document buffer. bool closeBuffer(); /// Close all document buffers. -- 2.39.2