# HG changeset patch # User insilmaril # Date 1121254575 0 # Node ID 0dc9286ad3d4b7ecae146f4931c854bb4a5cb550 # Parent ebfc893dde31ec90c6a3a114b56b83ed418ca125 added drag and drop of URLs 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) diff -r ebfc893dde31 -r 0dc9286ad3d4 tex/vym.tex --- a/tex/vym.tex Wed Jul 13 10:22:14 2005 +0000 +++ b/tex/vym.tex Wed Jul 13 11:36:15 2005 +0000 @@ -470,7 +470,7 @@ \includegraphics[width=0.5cm]{flag-url.png} \end{center} If you want to keep bookmarks in a map, select a branch where you want -to add the bookmark, than simply drag the URL from your browser to the +to add the bookmark, then simply drag the URL from your browser to the map. Also you could use an existing heading as URL: Right click onto the branch and select "Use heading for URL". @@ -691,7 +691,7 @@ be stored in the same directory. \subsubsection*{Export a part of a map} -Select a branch you want to export together with its childs, than open +Select a branch you want to export together with its childs, then open the context menu and choose {\em Save Selection}. This will create a file with the postfix {\tt .vyp}, which is an abbreviation for \lq vym part\rq. diff -r ebfc893dde31 -r 0dc9286ad3d4 version.h --- a/version.h Wed Jul 13 10:22:14 2005 +0000 +++ b/version.h Wed Jul 13 11:36:15 2005 +0000 @@ -2,6 +2,6 @@ #define VERSION_H #define __VYM_VERSION__ "1.7.0" -#define __BUILD_DATE__ "July 12, 2005" +#define __BUILD_DATE__ "July 13, 2005" #endif