diff -r ebfc893dde31 -r 0dc9286ad3d4 mapeditor.cpp --- a/mapeditor.cpp Wed Jul 13 10:22:14 2005 +0000 +++ b/mapeditor.cpp Wed Jul 13 11:36:15 2005 +0000 @@ -3388,8 +3388,7 @@ adjustCanvasSize(); } -void -MapEditor::contentsDragEnterEvent(QDragEnterEvent *event) +void MapEditor::contentsDragEnterEvent(QDragEnterEvent *event) { if (selection && (typeid(*selection) == typeid(BranchObj)) || @@ -3401,39 +3400,97 @@ return; } - // If image are drag from firefox + // If image are dragged from firefox if (event->provides("application/x-moz-file-promise-url") && event->provides("application/x-moz-nativeimage")) { event->accept(true); return; } + // If QUriDrag can decode mime type + if (QUriDrag::canDecode(event)) { + event->accept(); + return; + } + + // If Uri are dragged from firefox + if (event->provides("text/x-moz-url") ){ + event->accept(); + return; + } } - event->ignore(); } -void -MapEditor::contentsDropEvent(QDropEvent *event) +void MapEditor::contentsDropEvent(QDropEvent *event) { - - if (event->provides("image/png")) { - QPixmap pix; - if (QImageDrag::decode(event, pix)) { - addFloatImage(pix); - event->accept(); - } else - event->ignore(); - - } else if (event->provides("application/x-moz-file-promise-url") && - event->provides("application/x-moz-nativeimage")) { - - // Contains url to the img src in UTF-16 - QByteArray d = event->encodedData("application/x-moz-file-promise-url"); - QString url = QString((const QChar*)d.data(),d.size()/2); - fetchImage(url); - event->accept(); - } + if (selection && + (typeid(*selection) == typeid(BranchObj)) || + (typeid(*selection) == typeid(MapCenterObj))) + { + bool update=false; + QStrList uris; + if (event->provides("image/png")) + { + QPixmap pix; + if (QImageDrag::decode(event, pix)) + { + addFloatImage(pix); + event->accept(); + update=true; + } else + event->ignore(); + + } else if (event->provides("application/x-moz-file-promise-url") && + event->provides("application/x-moz-nativeimage")) + { + // Contains url to the img src in UTF-16 + QByteArray d = event->encodedData("application/x-moz-file-promise-url"); + QString url = QString((const QChar*)d.data(),d.size()/2); + fetchImage(url); + event->accept(); + update=true; + } else if (event->provides ("text/uri-list")) + { // Uris provided e.g. by konqueror + QUriDrag::decode (event,uris); + } else if (event->provides ("text/x-moz-url-data")) + { // Uris provided by Mozilla + QString str; + QTextDrag::decode (event,str); + uris.append(str); + } + + + if (uris.count()>0) + { + QStringList files; + QStringList urls; + QString s; + BranchObj *bo; + for (const char* u=uris.first(); u; u=uris.next()) + { + bo=((BranchObj*)(selection))->addBranch(); + if (bo) + { + s=QUriDrag::uriToLocalFile(u); + if (s) + files.append(QDir::convertSeparators(s)); + else + urls.append (u); + bo->setHeading(u); + bo->setURL (u); + } + } + update=true; + } + + if (update) + { + mapCenter->reposition(); + adjustCanvasSize(); + canvas()->update(); + } + } } void MapEditor::addFloatImage(const QPixmap &img)