diff -r a4532e5c2ce3 -r 1c8ff1928b97 mapeditor.cpp --- a/mapeditor.cpp Mon Nov 20 12:12:05 2006 +0000 +++ b/mapeditor.cpp Thu Nov 23 13:53:08 2006 +0000 @@ -1,8 +1,6 @@ #include "mapeditor.h" -#include -#include -#include +//#include #include #include @@ -310,6 +308,7 @@ standardFlagsDefault->resetUsedCounter(); // Reset the counters before saving + // TODO constr. of FIO creates lots of objects, better do this in some other way... FloatImageObj (mapCanvas).resetSaveCounter(); // Build xml recursivly @@ -3986,50 +3985,68 @@ void MapEditor::contentsDragEnterEvent(QDragEnterEvent *event) { - -// for (unsigned int i=0;event->format(i);i++) // Debug mime type -// cerr << event->format(i) << endl; - - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj))) { - - // If QImageDrag can decode mime type - if (Q3ImageDrag::canDecode(event)) { - event->accept(); - return; - } - - // 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 (Q3UriDrag::canDecode(event)) { - event->accept(); - return; - } - + if (selection && + (typeid(*selection) == typeid(BranchObj)) || + (typeid(*selection) == typeid(MapCenterObj))) + { + if (event->mimeData()->hasFormat("image/png")) + { + cout <<"found png in dragenterevent\n"; + event->accept(); + return; + } + + if (event->mimeData()->hasFormat("text/uri-list")) + { + cout <<"found uri-list in dragenterevent\n"; + event->accept(); + return; + } + +/* + // If QImageDrag can decode mime type + if (Q3ImageDrag::canDecode(event)) + { + cout << "dragenterevent q3imagedrag\n"; + event->accept(); + return; + } +*/ + // If image are dragged from firefox + if (event->mimeData()->hasFormat("application/x-moz-file-promise-url") && + event->mimeData()->hasFormat("application/x-moz-nativeimage")) { + event->accept(true); + cout << "dragenterevent firefox\n"; + return; + } +/* + // If QUriDrag can decode mime type + if (Q3UriDrag::canDecode(event)) { + event->accept(); + cout << "accepted uri drag\n"; + return; + } // If Uri are dragged from firefox - if (event->provides("_NETSCAPE_URL")){ - event->accept(); - return; - } - - // If QTextDrag can decode mime type - if (Q3TextDrag::canDecode(event)) { - event->accept(); - return; - } - - } - event->ignore(); + if (event->provides("_NETSCAPE_URL")){ + event->accept(); + cout << "dragenterevent NETSCAPE\n"; + return; + } + + // If QTextDrag can decode mime type + if (Q3TextDrag::canDecode(event)) { + event->accept(); + cout << "dragenterevent textdrag\n"; + return; + } +*/ + } + event->ignore(); } -bool isUnicode16(const QByteArray &d) + + +/* FIXME needed in QT4? bool isUnicode16(const QByteArray &d) { // TODO: make more precise check for unicode 16. // Guess unicode16 if any of second bytes are zero @@ -4038,7 +4055,8 @@ if (d.at(i*2+1)==0) return true; return false; } - +*/ + void MapEditor::contentsDropEvent(QDropEvent *event) { if (selection && @@ -4046,32 +4064,30 @@ (typeid(*selection) == typeid(MapCenterObj))) { bool update=false; - Q3StrList uris; + QStringList uris; + QList urls; QString heading; - if (event->provides("image/png")) + + + if (event->mimeData()->hasFormat("image/png")) { - QPixmap pix; - if (Q3ImageDrag::decode(event, pix)) - { - addFloatImageInt(pix); - event->accept(); - update=true; - } else - event->ignore(); - - } else if (event->provides("application/x-moz-file-promise-url") && - event->provides("application/x-moz-nativeimage")) + event->acceptProposedAction(); + addFloatImageInt(event->mimeData()->imageData().value()); + cout << "Drop png...\n"; + } else if (event->mimeData()->hasFormat("application/x-moz-file-promise-url")&& + event->mimeData()->hasFormat("application/x-moz-nativeimage")) { + cout << "Drop Mozilla...\n"; // Contains url to the img src in unicode16 QByteArray d = event->encodedData("application/x-moz-file-promise-url"); QString url = QString((const QChar*)d.data(),d.size()/2); fetchImage(url); - event->accept(); + event->acceptProposedAction(); update=true; - } else if (event->provides ("text/uri-list")) - { // Uris provided e.g. by konqueror - Q3UriDrag::decode (event,uris); - } else if (event->provides ("_NETSCAPE_URL")) + } else if (event->mimeData()->hasUrls()) + { + urls=event->mimeData()->urls(); + } /*else if (event->provides ("_NETSCAPE_URL")) { // Uris provided by Mozilla QStringList l = QStringList::split("\n", event->encodedData("_NETSCAPE_URL")); uris.append(l[0]); @@ -4104,7 +4120,13 @@ event->accept(); update= true; } - + */ + + for (int i=0; i0) { QStringList files; @@ -4140,7 +4162,7 @@ } update=true; } - + */ if (update) { //FIXME saveState has to be called earlier for each of the drops... @@ -4159,6 +4181,7 @@ (typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=((BranchObj*)selection); + qWarning ("Warning: Image added by drop event: no undo/redo so far."); //FIXME XXX saveStateChangingPart(selection,QString("Add floatimage to %1").arg(getName(bo))); //QString fn=fd->selectedFile(); //lastImageDir=fn.left(fn.findRev ("/"));