Le 12/05/11 14:12, [email protected] a écrit :
Fix bug #7916: Undo warning message when inserting plaintext file
LFUN_INSERT_PLAINTEXT is handled in GuiView because it might need to ask for a
filename. But if the filename is given as a paramater we can handle it in
BufferView immediately. Also, when we've asked for the filename in GuiView we
should dispatch the LFUN to BufferView in order to properly use the Undo
mechanism.
Very good move. This should be done for many of the lfuns handled in
GuiView.
--- lyx-devel/trunk/src/BufferView.cpp Mon Dec 5 13:40:22 2011 (r40376)
+++ lyx-devel/trunk/src/BufferView.cpp Mon Dec 5 14:12:57 2011 (r40377)
+ case LFUN_FILE_INSERT_PLAINTEXT: {
+ bool enabled = true;
This variable is not changed afterwards. What is it good for?
+ docstring const fname = cmd.argument();
+ if (!FileName::isAbsolute(to_utf8(fname))) {
+ flag.message(_("Absolute filename expected."));
+ return false;
+ }
+ case LFUN_FILE_INSERT_PLAINTEXT_PARA:
+ case LFUN_FILE_INSERT_PLAINTEXT: {
+ bool const as_paragraph = (act ==
LFUN_FILE_INSERT_PLAINTEXT_PARA);
+ string const fname = to_utf8(cmd.argument());
+ if (!FileName::isAbsolute(fname))
+ dr.setMessage(_("Absolute filename expected."));
Why not assert directly? This is not supposed to happen at all.
Modified: lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiView.cpp Mon Dec 5 13:40:22
2011 (r40376)
+++ lyx-devel/trunk/src/frontends/qt4/GuiView.cpp Mon Dec 5 14:12:57
2011 (r40377)
@@ -1867,6 +1867,15 @@
enable = !(lyxrc.forward_search_dvi.empty()&&
lyxrc.forward_search_pdf.empty());
break;
+ case LFUN_FILE_INSERT_PLAINTEXT:
+ case LFUN_FILE_INSERT_PLAINTEXT_PARA: {
+ if (BufferView const * bv = documentBufferView())
+ enable = bv->cursor().inTexted();
+ else
+ enable = false;
+ break;
Why not:
enable = documentBufferView() && documentBufferView()->cursor().inTexted();
?
+ case LFUN_FILE_INSERT_PLAINTEXT_PARA: {
+ bool const as_paragraph = (cmd.action() ==
LFUN_FILE_INSERT_PLAINTEXT_PARA);
+ string const fname = to_utf8(cmd.argument());
+ if (!fname.empty()&& !FileName::isAbsolute(fname)) {
+ dr.setMessage(_("Absolute filename expected."));
+ break;
+ }
Assertion again?
JMarc