Il 28/07/2011 17:29, Edwin Leuven ha scritto:
Tommaso Cucinotta<tomm...@lyx.org> wrote:
This patch allows one to quickly insert new images
and other type of external material into a LyX document.
fwiw, i'd rather be able to drag-n-drop
Please, try the attached (preliminary) patch.
If you drag'n'drop at least .eps, .fig, .dia, .png files, then they get
automatically inserted as InsetGraphics, and immediately previewed in
LyX. If you drag'n'drop a .lyx file, then it is regularly opened.
Is this that you meant ?
And, the funny part, is that the patch was *mainly a removal of code*.
Comments ?
T.
Index: src/frontends/qt4/GuiView.cpp
===================================================================
--- src/frontends/qt4/GuiView.cpp (revisione 39381)
+++ src/frontends/qt4/GuiView.cpp (copia locale)
@@ -893,12 +893,10 @@
vector<const Format *> found_formats;
// Find all formats that have the correct extension.
- vector<const Format *> const & import_formats
- = theConverters().importableFormats();
- vector<const Format *>::const_iterator it = import_formats.begin();
- for (; it != import_formats.end(); ++it)
- if ((*it)->extension() == ext)
- found_formats.push_back(*it);
+ Formats::const_iterator it = formats.begin();
+ for (; it != formats.end(); ++it)
+ if (it->extension() == ext && it->name() != "lyx")
+ found_formats.push_back(&(*it));
FuncRequest cmd;
if (found_formats.size() >= 1) {
@@ -2087,6 +2085,19 @@
if (filename.empty())
return;
+ FileName fname(filename);
+ if (formats.getFormatFromFile(fname) != "lyx") {
+ if (!currentBufferView()) {
+ Alert::warning(_("Error"), _("Need an open document where to insert"));
+ return;
+ }
+ string args = string("graphics filename ") + filename;
+ FuncRequest cmd(LFUN_INSET_INSERT, args);
+ LYXERR(Debug::DEBUG, "Dispatching: " << cmd);
+ lyx::dispatch(cmd);
+ return;
+ }
+
// get absolute path of file
FileName const fullname(support::makeAbsPath(filename));