mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-24 02:35:20 +00:00
Fix bug #2948: Drag and drop support for all importable file types.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32492 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
472b09d735
commit
2ab7e25b05
@ -608,15 +608,44 @@ void GuiView::dropEvent(QDropEvent * event)
|
|||||||
for (int i = 0; i != files.size(); ++i) {
|
for (int i = 0; i != files.size(); ++i) {
|
||||||
string const file = os::internal_path(fromqstr(
|
string const file = os::internal_path(fromqstr(
|
||||||
files.at(i).toLocalFile()));
|
files.at(i).toLocalFile()));
|
||||||
if (!file.empty()) {
|
if (file.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string const ext = support::getExtension(file);
|
||||||
|
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);
|
||||||
|
|
||||||
|
FuncRequest cmd;
|
||||||
|
if (found_formats.size() >= 1) {
|
||||||
|
if (found_formats.size() > 1) {
|
||||||
|
//FIXME: show a dialog to choose the correct importable format
|
||||||
|
LYXERR(Debug::FILES,
|
||||||
|
"Multiple importable formats found, selecting first");
|
||||||
|
}
|
||||||
|
string const arg = found_formats[0]->name() + " " + file;
|
||||||
|
cmd = FuncRequest(LFUN_BUFFER_IMPORT, arg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//FIXME: do we have to explicitly check whether it's a lyx file?
|
||||||
|
LYXERR(Debug::FILES,
|
||||||
|
"No formats found, trying to open it as a lyx file");
|
||||||
|
cmd = FuncRequest(LFUN_FILE_OPEN, file);
|
||||||
|
}
|
||||||
|
|
||||||
// Asynchronously post the event. DropEvent usually come
|
// Asynchronously post the event. DropEvent usually come
|
||||||
// from the BufferView. But reloading a file might close
|
// from the BufferView. But reloading a file might close
|
||||||
// the BufferView from within its own event handler.
|
// the BufferView from within its own event handler.
|
||||||
guiApp->dispatchDelayed(FuncRequest(LFUN_FILE_OPEN, file));
|
guiApp->dispatchDelayed(cmd);
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiView::message(docstring const & str)
|
void GuiView::message(docstring const & str)
|
||||||
|
Loading…
Reference in New Issue
Block a user