mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 23:09:40 +00:00
Move the call to Buffer::errors("Parse") from BufferView::insertLyXFile to GuiView::insertLyXFile.
Buffer::errors("Parse") is called 7 times in the whole project. 4 times from GuiView and three times from functions in other classes, but which are (almost) only called from the GuiView. Buffer::errors is used to signal the GUI that there might be an error occuring, but what sense does it make if it is only called from the Gui ? Isn't it better to let the function return wether it succeeded or not and let the GuiView take action in doing something with the possible errors. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35911 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c9a91c5474
commit
ef7ecea2b3
@ -2528,7 +2528,6 @@ void BufferView::insertLyXFile(FileName const & fname)
|
|||||||
buffer_.changed(true);
|
buffer_.changed(true);
|
||||||
// emit message signal.
|
// emit message signal.
|
||||||
message(bformat(res, disp_fn));
|
message(bformat(res, disp_fn));
|
||||||
buffer_.errors("Parse");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2100,44 +2100,41 @@ void GuiView::insertLyXFile(docstring const & fname)
|
|||||||
|
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
FileName filename(to_utf8(fname));
|
FileName filename(to_utf8(fname));
|
||||||
|
|
||||||
if (!filename.empty()) {
|
|
||||||
bv->insertLyXFile(filename);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Launch a file browser
|
|
||||||
// FIXME UNICODE
|
|
||||||
string initpath = lyxrc.document_path;
|
|
||||||
string const trypath = bv->buffer().filePath();
|
|
||||||
// If directory is writeable, use this as default.
|
|
||||||
if (FileName(trypath).isDirWritable())
|
|
||||||
initpath = trypath;
|
|
||||||
|
|
||||||
// FIXME UNICODE
|
|
||||||
FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
|
|
||||||
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
|
||||||
dlg.setButton2(qt_("Examples|#E#e"),
|
|
||||||
toqstr(addPath(package().system_support().absFileName(),
|
|
||||||
"examples")));
|
|
||||||
|
|
||||||
FileDialog::Result result = dlg.open(toqstr(initpath),
|
|
||||||
QStringList(qt_("LyX Documents (*.lyx)")));
|
|
||||||
|
|
||||||
if (result.first == FileDialog::Later)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// FIXME UNICODE
|
|
||||||
filename.set(fromqstr(result.second));
|
|
||||||
|
|
||||||
// check selected filename
|
|
||||||
if (filename.empty()) {
|
if (filename.empty()) {
|
||||||
// emit message signal.
|
// Launch a file browser
|
||||||
message(_("Canceled."));
|
// FIXME UNICODE
|
||||||
return;
|
string initpath = lyxrc.document_path;
|
||||||
|
string const trypath = bv->buffer().filePath();
|
||||||
|
// If directory is writeable, use this as default.
|
||||||
|
if (FileName(trypath).isDirWritable())
|
||||||
|
initpath = trypath;
|
||||||
|
|
||||||
|
// FIXME UNICODE
|
||||||
|
FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
|
||||||
|
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
||||||
|
dlg.setButton2(qt_("Examples|#E#e"),
|
||||||
|
toqstr(addPath(package().system_support().absFileName(),
|
||||||
|
"examples")));
|
||||||
|
|
||||||
|
FileDialog::Result result = dlg.open(toqstr(initpath),
|
||||||
|
QStringList(qt_("LyX Documents (*.lyx)")));
|
||||||
|
|
||||||
|
if (result.first == FileDialog::Later)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// FIXME UNICODE
|
||||||
|
filename.set(fromqstr(result.second));
|
||||||
|
|
||||||
|
// check selected filename
|
||||||
|
if (filename.empty()) {
|
||||||
|
// emit message signal.
|
||||||
|
message(_("Canceled."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bv->insertLyXFile(filename);
|
bv->insertLyXFile(filename);
|
||||||
|
bv->buffer().errors("Parse");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user