mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +00:00
* 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
This commit is contained in:
parent
a55a0b8f2d
commit
c1696ccae3
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user