# HG changeset patch # User insilmaril # Date 1121784270 0 # Node ID 9b9c7e8b9147b60a36faa52fb011878066e9e5b4 # Parent 0dc9286ad3d4b7ecae146f4931c854bb4a5cb550 enhanced dragdrop, speedup for moving branches diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 branchobj.cpp --- a/branchobj.cpp Wed Jul 13 11:36:15 2005 +0000 +++ b/branchobj.cpp Tue Jul 19 14:44:30 2005 +0000 @@ -1091,15 +1091,14 @@ { // Find current parent and // remove pointer to myself there - if (!dst) return NULL; - BranchObj *par=(BranchObj*)(parObj); if (par) par->removeBranchPtr (this); else return NULL; + // Create new pointer to myself at dst if (pos<0||dst->getDepth()==0) { // links myself as last branch at dst diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 demos/time-management.vym Binary file demos/time-management.vym has changed diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 demos/todo.vym Binary file demos/todo.vym has changed diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 exportxhtmldialog.ui --- a/exportxhtmldialog.ui Wed Jul 13 11:36:15 2005 +0000 +++ b/exportxhtmldialog.ui Tue Jul 19 14:44:30 2005 +0000 @@ -8,8 +8,8 @@ <rect> <x>0</x> <y>0</y> - <width>614</width> - <height>757</height> + <width>514</width> + <height>468</height> </rect> </property> <property name="minimumSize"> @@ -21,11 +21,11 @@ <property name="caption"> <string>Export XHTML</string> </property> - <vbox> + <grid> <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="QLayoutWidget"> + <widget class="QLayoutWidget" row="0" column="0"> <property name="name"> <cstring>layout17</cstring> </property> @@ -80,14 +80,60 @@ </widget> </hbox> </widget> - <widget class="QButtonGroup"> + <widget class="QLayoutWidget" row="5" column="0"> + <property name="name"> + <cstring>layout17</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>61</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>exportButton</cstring> + </property> + <property name="text"> + <string>Export</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>cancelButton</cstring> + </property> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QButtonGroup" row="1" column="0"> <property name="name"> <cstring>buttonGroup2</cstring> </property> <property name="sizePolicy"> <sizepolicy> - <hsizetype>3</hsizetype> - <vsizetype>3</vsizetype> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -155,180 +201,260 @@ </widget> </vbox> </widget> - <widget class="QLayoutWidget"> + <widget class="QGroupBox" row="2" column="0"> <property name="name"> - <cstring>layout6</cstring> + <cstring>groupBox2</cstring> + </property> + <property name="title"> + <string>Stylesheets</string> </property> <grid> <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="QPushButton" row="5" column="3"> + <widget class="QLayoutWidget" row="1" column="0"> <property name="name"> - <cstring>browsePostExportButton</cstring> + <cstring>layout7</cstring> </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>125</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>XSL:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="QLineEdit"> + <property name="name"> + <cstring>lineEditXSL</cstring> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>browseXSLButton</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Browse</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="0" column="0"> + <property name="name"> + <cstring>layout6</cstring> </property> - <property name="text"> - <string>Browse</string> - </property> - </widget> - <widget class="QLabel" row="4" column="0" rowspan="1" colspan="2"> - <property name="name"> - <cstring>textLabel1_3</cstring> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>5</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Before export:</string> - </property> - <property name="alignment"> - <set>AlignVCenter|AlignRight</set> - </property> - </widget> - <widget class="QLineEdit" row="2" column="1" rowspan="1" colspan="2"> - <property name="name"> - <cstring>lineEditXSL</cstring> - </property> - </widget> - <widget class="QPushButton" row="2" column="3"> - <property name="name"> - <cstring>browseXSLButton</cstring> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Browse</string> - </property> - </widget> - <widget class="QLineEdit" row="4" column="2"> - <property name="name"> - <cstring>lineEditPreScript</cstring> - </property> - </widget> - <widget class="QPushButton" row="4" column="3"> - <property name="name"> - <cstring>browsePreExportButton</cstring> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Browse</string> - </property> - </widget> - <widget class="QLabel" row="0" column="0"> - <property name="name"> - <cstring>textLabel2_3</cstring> - </property> - <property name="text"> - <string>Stylesheets:</string> - </property> - </widget> - <widget class="QPushButton" row="1" column="3"> - <property name="name"> - <cstring>browseCSSButton</cstring> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Browse</string> - </property> - </widget> - <widget class="QLabel" row="1" column="0"> - <property name="name"> - <cstring>textLabel1_2</cstring> - </property> - <property name="text"> - <string>CSS:</string> - </property> - <property name="alignment"> - <set>AlignVCenter|AlignRight</set> - </property> - </widget> - <widget class="QLabel" row="5" column="0" rowspan="1" colspan="2"> - <property name="name"> - <cstring>textLabel2_2</cstring> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>5</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShape"> - <enum>NoFrame</enum> - </property> - <property name="text"> - <string>After Export:</string> - </property> - <property name="alignment"> - <set>AlignVCenter|AlignRight</set> - </property> - </widget> - <widget class="QLineEdit" row="1" column="1" rowspan="1" colspan="2"> - <property name="name"> - <cstring>lineEditCSS</cstring> - </property> - </widget> - <widget class="QLabel" row="2" column="0"> - <property name="name"> - <cstring>textLabel2</cstring> - </property> - <property name="text"> - <string>XSL:</string> - </property> - <property name="alignment"> - <set>AlignVCenter|AlignRight</set> - </property> - </widget> - <widget class="QLineEdit" row="5" column="2"> - <property name="name"> - <cstring>lineEditPostScript</cstring> - </property> - </widget> - <widget class="QLabel" row="3" column="0"> - <property name="name"> - <cstring>textLabel1_4</cstring> - </property> - <property name="text"> - <string>Scripts:</string> - </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>125</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>CSS:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="QLineEdit"> + <property name="name"> + <cstring>lineEditCSS</cstring> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>browseCSSButton</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Browse</string> + </property> + </widget> + </hbox> </widget> </grid> </widget> - <spacer> + <widget class="QGroupBox" row="3" column="0"> + <property name="name"> + <cstring>groupBox1</cstring> + </property> + <property name="title"> + <string>Scripts</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget" row="0" column="0"> + <property name="name"> + <cstring>layout4</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1_3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>125</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Before export:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="QLineEdit"> + <property name="name"> + <cstring>lineEditPostScript</cstring> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>browsePreExportButton</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Browse</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="1" column="0"> + <property name="name"> + <cstring>layout5</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>125</width> + <height>0</height> + </size> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="text"> + <string>After Export:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="QLineEdit"> + <property name="name"> + <cstring>lineEditPreScript</cstring> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>browsePostExportButton</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Browse</string> + </property> + </widget> + </hbox> + </widget> + </grid> + </widget> + <spacer row="4" column="0"> <property name="name"> <cstring>spacer3</cstring> </property> @@ -336,62 +462,16 @@ <enum>Vertical</enum> </property> <property name="sizeType"> - <enum>Expanding</enum> + <enum>MinimumExpanding</enum> </property> <property name="sizeHint"> <size> <width>20</width> - <height>60</height> + <height>20</height> </size> </property> </spacer> - <widget class="QLayoutWidget"> - <property name="name"> - <cstring>layout17</cstring> - </property> - <hbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <spacer> - <property name="name"> - <cstring>spacer5</cstring> - </property> - <property name="orientation"> - <enum>Horizontal</enum> - </property> - <property name="sizeType"> - <enum>Expanding</enum> - </property> - <property name="sizeHint"> - <size> - <width>61</width> - <height>21</height> - </size> - </property> - </spacer> - <widget class="QPushButton"> - <property name="name"> - <cstring>exportButton</cstring> - </property> - <property name="text"> - <string>Export</string> - </property> - <property name="default"> - <bool>true</bool> - </property> - </widget> - <widget class="QPushButton"> - <property name="name"> - <cstring>cancelButton</cstring> - </property> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </hbox> - </widget> - </vbox> + </grid> </widget> <connections> <connection> diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 linkablemapobj.cpp --- a/linkablemapobj.cpp Wed Jul 13 11:36:15 2005 +0000 +++ b/linkablemapobj.cpp Tue Jul 19 14:44:30 2005 +0000 @@ -536,7 +536,6 @@ part=s.section(",",0,0); typ=part.left (3); num=part.right(part.length() - 3); - if (typ=="mc:") { if (depth>0) diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 mainwindow.cpp --- a/mainwindow.cpp Wed Jul 13 11:36:15 2005 +0000 +++ b/mainwindow.cpp Tue Jul 19 14:44:30 2005 +0000 @@ -1861,7 +1861,7 @@ { QMessageBox::information( findWindow, tr( "VYM -Information:" ), tr("No matches found for ")+ - "'<b>"+s+"</b>'"); + "<b>"+s+"</b>"); } } diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 mapeditor.cpp --- a/mapeditor.cpp Wed Jul 13 11:36:15 2005 +0000 +++ b/mapeditor.cpp Tue Jul 19 14:44:30 2005 +0000 @@ -18,6 +18,7 @@ #include <qdragobject.h> #include <qurloperator.h> #include <qnetworkprotocol.h> +#include <qregexp.h> #include <iostream> #include <cstdlib> @@ -611,37 +612,93 @@ */ } -void MapEditor::parseAtom(const QString &s) +void MapEditor::parseAtom(const QString &atom) { API api; - QString c,p,p0; - api.parseCommand (s,c,p); - api.getString(p,p0); - /* FIXME testing - cout <<"ME::parseAtom s="<<s<<endl; - cout <<"ME::parseAtom c="<<c<<endl; - cout <<"ME::parseAtom p="<<p<<endl; - */ - + QString s; + int x,y; + bool ok; + + // Split string s into command and parameters + api.parseCommand (atom); + QString com=api.command(); + // External commands - if (c==QString("moveBranchUp")) + if (com==QString("moveBranchUp")) moveBranchUp(); - else if (c=="moveBranchDown") + else if (com=="moveBranchDown") moveBranchDown(); - else if (c=="setHeading") - setHeading (p0); + else if (com=="move") + { + if (api.checkParamCount(2) && + selection && + typeid(*selection) == typeid(BranchObj) ) + { + x=api.parInt (ok,0); + if (ok) + { + y=api.parInt (ok,1); + if (ok) ((BranchObj*)(selection))->move (x,y); + } + } + } + else if (com=="linkBranchToPos") + { + if (selection && typeid(*selection) == typeid(BranchObj) ) + { + if (api.checkParamCount(4)) + { + s=api.parString(ok,0); + LinkableMapObj *dst=mapCenter->findObjBySelect (s); + if (dst) + { + if (typeid(*dst) == typeid(BranchObj) ) + ((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),-1); + if (typeid(*dst) == typeid(MapCenterObj) ) + { + ((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),-1); + x=api.parInt (ok,2); + if (ok) + { + y=api.parInt (ok,3); + if (ok) ((BranchObj*)(selection))->move (x,y); + } + } + } + } + } + } else if (com=="setHeading") + { + if (api.checkParamCount(1)) + { + s=api.parString (ok,0); + if (ok) setHeading (s); + } + } // Internal commands, used for undo etc. - else if (c==QString("undoMap")) + else if (com==QString("undoMap")) undoXML(""); - else if (c==QString("undoPart")) - undoXML(p0); - else if (c=="select") - select (p0); + else if (com==QString("undoPart")) + { + if (api.checkParamCount(1)) + { + s=api.parString (ok,0); + undoXML(s); + } + } else if (com=="select") + if (api.checkParamCount(1)) + { + s=api.parString(ok,0); + if (ok) select (s); + } else + api.setError ("Unknown command in: "+atom); + + // Any errors? + if (api.error()) { cout << "MapEditor::parseAtom: Error!\n"; - cout << " Command unknown: \""<<c<<"\""<<endl; - cout << " Used in atom: \""<<s<<"\""<<endl; + cout << " "<<api.errorDesc()<<endl; } } @@ -1233,11 +1290,13 @@ if (lineedit) finishedLineEditNoSave(); // Unselect + /*FIXME testing if (selection) { selection->unselect(); selection=NULL; } + */ parseAtom (undoCommand); mapCenter->reposition(); @@ -1415,6 +1474,21 @@ } } +void MapEditor::linkBranchToPos (LinkableMapObj *dst, const int &pos, const QPoint &p) +{ + // FIXME no saveState, because this is only internal at undo so far + if (selection && typeid(*selection) == typeid(BranchObj) ) + { + if (dst && typeid(*dst) == typeid(BranchObj) ) + ((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),-1); + if (dst && typeid(*dst) == typeid(MapCenterObj) ) + { + ((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),-1); + ((BranchObj*)(selection))->move (p); + } + } +} + void MapEditor::editHeading() { // Finish open lineEdits @@ -3006,7 +3080,6 @@ selection->select(); adjustCanvasSize(); - } // Check, if systemFlag clicked @@ -3035,6 +3108,11 @@ // Left Button Move Branches if (e->button() == QMouseEvent::LeftButton ) { + movingObj_start.setX( p.x() - selection->x() ); + movingObj_start.setY( p.y() - selection->y() ); + movingObj_orgPos.setX (lmo->x() ); + movingObj_orgPos.setY (lmo->y() ); + // If modMode==copy, then we want to "move" the _new_ object around // then we need the offset from p to the _old_ selection, because of tmp if (actionModModeCopy->isOn() && @@ -3043,20 +3121,13 @@ if (typeid(*selection)==typeid(BranchObj) ) { copyingObj=true; - movingObj_start.setX( p.x() - selection->x() ); - movingObj_start.setY( p.y() - selection->y() ); mapCenter->addBranch ((BranchObj*)(selection)); unselect(); selection=mapCenter->getLastBranch(); selection->select(); mapCenter->reposition(); } - } else - { - movingObj_start.setX( p.x() - selection->x() ); - movingObj_start.setY( p.y() - selection->y() ); - } - + } movingObj=selection; } else // Middle Button Toggle Scroll @@ -3137,7 +3208,6 @@ // setLinkStyle calls updateLink, only set it once if (fio->getLinkStyle()!=fio->getDefLinkStyle() ) fio->setLinkStyle (fio->getDefLinkStyle()); - } // TODO if (typeid(*selection) == typeid(FloatTextObj)) } @@ -3156,7 +3226,7 @@ { // depth==1, mainbranch setChanged(); - saveState(lmosel); + saveState("move "+qpointToString(movingObj_orgPos)); lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); } else { @@ -3299,50 +3369,34 @@ copyingObj=false; - if (!dst ) + if (dst ) { - if (copyingObj) - { - // remove the current selection, if we have no destination - selection->unselect(); - ((BranchObj*)(selection->getParObj()))->removeBranch ((BranchObj*)(selection)); - if (selectionLast) - { - selection=selectionLast; - selectionLast=NULL; - selection->select(); - } - } - } else - { + BranchObj* bs=((BranchObj*)(selection)); setChanged(); - saveState(); + saveState ("linkBranchToPos (\""+ + (bs->getParObj())->getSelectString()+ + "\","+ + QString("%1").arg(bs->getNum())+ + ","+ + QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ + ")"); // TODO we also could check, if dest and src are on same branch, // then it would be sufficient to saveState of this branch // Modifiers allow to insert above/below dst if (e->state() & QMouseEvent::ShiftButton) { - ((BranchObj*)(selection))->moveBranchTo - ( - (BranchObj*)(dst), - ((BranchObj*)(dst))->getNum() - ); - //if (selection) selection->select(); + bs->moveBranchTo ( (BranchObj*)(dst), ((BranchObj*)(dst))->getNum()); } else if (e->state() & QMouseEvent::ControlButton) { - ((BranchObj*)(selection))->moveBranchTo - ( - (BranchObj*)(dst), - ((BranchObj*)(dst))->getNum()+1 - ); - //if (selection) selection->select(); + bs->moveBranchTo ( (BranchObj*)(dst), ((BranchObj*)(dst))->getNum()+1); } else { - ((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),-1); + bs->moveBranchTo ((BranchObj*)(dst),-1); if (dst->getDepth()==0) - ((BranchObj*)(selection))->move (savePos); + bs->move (savePos); + cout << "ME::release start was: "<<movingObj_orgPos<<endl; } } // Draw the original link, before selection was moved around @@ -3390,6 +3444,10 @@ 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))) { @@ -3414,13 +3472,30 @@ } // If Uri are dragged from firefox - if (event->provides("text/x-moz-url") ){ + if (event->provides("_NETSCAPE_URL")){ event->accept(); return; } + + // If QTextDrag can decode mime type + if (QTextDrag::canDecode(event)) { + event->accept(); + return; + } + } event->ignore(); } + +bool isUnicode16(const QByteArray &d) +{ + // FIXME: make more precise check for unicode 16. + // Guess unicode16 if any of second bytes are zero + unsigned int length = max(0,d.size()-2)/2; + for (unsigned int i = 0; i<length ; i++) + if (d.at(i*2+1)==0) return true; + return false; +} void MapEditor::contentsDropEvent(QDropEvent *event) { @@ -3430,6 +3505,7 @@ { bool update=false; QStrList uris; + QString heading; if (event->provides("image/png")) { QPixmap pix; @@ -3444,7 +3520,7 @@ } 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 + // 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); @@ -3453,14 +3529,40 @@ } 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")) + } else if (event->provides ("_NETSCAPE_URL")) { // Uris provided by Mozilla - QString str; - QTextDrag::decode (event,str); - uris.append(str); + QStringList l = QStringList::split("\n", event->encodedData("_NETSCAPE_URL")); + uris.append(l[0]); + heading = l[1]; + } else if (event->provides("text/html")) { + + // Handels text mime types + // Look like firefox allways handle text as unicode16 (2 bytes per char.) + QByteArray d = event->encodedData("text/html"); + QString text; + if (isUnicode16(d)) + text = QString((const QChar*)d.data(),d.size()/2); + else + text = QString(d); + + textEditor->setText(text); + + event->accept(); + update=true; + } else if (event->provides("text/plain")) { + QByteArray d = event->encodedData("text/plain"); + QString text; + if (isUnicode16(d)) + text = QString((const QChar*)d.data(),d.size()/2); + else + text = QString(d); + + textEditor->setText(text); + + event->accept(); + update= true; } - if (uris.count()>0) { QStringList files; @@ -3473,12 +3575,23 @@ if (bo) { s=QUriDrag::uriToLocalFile(u); - if (s) - files.append(QDir::convertSeparators(s)); - else - urls.append (u); - bo->setHeading(u); - bo->setURL (u); + if (s) { + QString file = QDir::convertSeparators(s); + heading = QFileInfo(file).baseName(); + files.append(file); + if (file.endsWith(".vym", false)) + bo->setVymLink(file); + else + bo->setURL(u); + } else { + urls.append (u); + bo->setURL(u); + } + + if (heading) + bo->setHeading(heading); + else + bo->setHeading(u); } } update=true; @@ -3486,6 +3599,7 @@ if (update) { + setChanged(); mapCenter->reposition(); adjustCanvasSize(); canvas()->update(); @@ -3515,8 +3629,7 @@ } -void -MapEditor::imageDataFetched(const QByteArray &a, QNetworkOperation */*nop*/) +void MapEditor::imageDataFetched(const QByteArray &a, QNetworkOperation */*nop*/) { if (!imageBuffer) imageBuffer = new QBuffer(); if (!imageBuffer->isOpen()) { @@ -3526,21 +3639,24 @@ } -void -MapEditor::imageDataFinished(QNetworkOperation *nop) +void MapEditor::imageDataFinished(QNetworkOperation *nop) { - imageBuffer->close(); - if (nop->state()==QNetworkProtocol::StDone) { - QPixmap img(imageBuffer->buffer()); - addFloatImage(img); - } - - delete imageBuffer; - imageBuffer = 0; + if (nop->state()==QNetworkProtocol::StDone) { + QPixmap img(imageBuffer->buffer()); + addFloatImage(img); + } + + if (imageBuffer) { + imageBuffer->close(); + if (imageBuffer) { + imageBuffer->close(); + delete imageBuffer; + imageBuffer = 0; + } + } } -void -MapEditor::fetchImage(const QString &url) +void MapEditor::fetchImage(const QString &url) { if (urlOperator) { urlOperator->stop(); diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 mapeditor.h --- a/mapeditor.h Wed Jul 13 11:36:15 2005 +0000 +++ b/mapeditor.h Tue Jul 19 14:44:30 2005 +0000 @@ -84,6 +84,7 @@ void cut(); // cut to clipboard and backup void moveBranchUp(); void moveBranchDown(); + void linkBranchToPos(LinkableMapObj*,const int &, const QPoint &);// move selection to dst and pos void editHeading(); // Start editing heading private: void setHeading(const QString &); // Just set the heading for selection @@ -190,6 +191,7 @@ LinkableMapObj* selectionLast; // last selection MapObj* movingObj; // moving a MapObj MapObj* linkingObj_src; // part of a link + QPoint movingObj_orgPos; // org. pos of mouse before move QPoint movingObj_start; // rel. pos of mouse to absPos QPoint movingCont_start; // inital pos of moving Content or QPoint movingVec; // how far has Content moved diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 mapobj.cpp --- a/mapobj.cpp Wed Jul 13 11:36:15 2005 +0000 +++ b/mapobj.cpp Tue Jul 19 14:44:30 2005 +0000 @@ -1,4 +1,5 @@ #include "mapobj.h" +#include "misc.h" ///////////////////////////////////////////////////////////////// // MapObj @@ -70,6 +71,11 @@ return bbox.height(); } +QString MapObj::getPos() +{ + return qpointToString(absPos); +} + void MapObj::move (double x, double y) { int xi=static_cast <int> (x); diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 mapobj.h --- a/mapobj.h Wed Jul 13 11:36:15 2005 +0000 +++ b/mapobj.h Tue Jul 19 14:44:30 2005 +0000 @@ -9,6 +9,7 @@ using namespace std; #define Z_BBOX 0 +#define Z_XLINK 10 #define Z_LINK 20 #define Z_FRAME 50 #define Z_SELBOX 60 @@ -28,6 +29,7 @@ virtual int y(); virtual int width(); virtual int height(); + virtual QString getPos(); // Return position as string (x,y) virtual void move (double x,double y); // move to absolute Position virtual void moveBy (double x,double y); // move to relative Position virtual bool inBBox(QPoint); // Check if Point is in bbox diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 misc.cpp --- a/misc.cpp Wed Jul 13 11:36:15 2005 +0000 +++ b/misc.cpp Tue Jul 19 14:44:30 2005 +0000 @@ -3,10 +3,14 @@ #include "misc.h" +QString qpointToString (const QPoint &p) +{ + return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")"; +} ostream &operator<< (ostream &stream, QPoint const &p) { - return (stream << "(" << p.x() << "," << p.y() << ")"); + return (stream << qpointToString(p) ); } float getAngle(const QPoint &p) diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 misc.h --- a/misc.h Wed Jul 13 11:36:15 2005 +0000 +++ b/misc.h Tue Jul 19 14:44:30 2005 +0000 @@ -6,18 +6,11 @@ using namespace std; -#define Z_BBOX 0 -#define Z_XLINK 10 -#define Z_LINK 20 -#define Z_FRAME 50 -#define Z_SELBOX 60 -#define Z_ICON 80 -#define Z_TEXT 100 - enum LoadMode {NewMap,ImportAdd,ImportReplace}; enum SaveMode {PartOfMap,CompleteMap,UndoCommand}; ///////////////////////////////////////////////////////////////////////////// +QString qpointToString (const QPoint &p); extern ostream &operator<< (ostream &stream, QPoint const &p); float getAngle(const QPoint &); QPoint normalise (const QPoint &); diff -r 0dc9286ad3d4 -r 9b9c7e8b9147 version.h --- a/version.h Wed Jul 13 11:36:15 2005 +0000 +++ b/version.h Tue Jul 19 14:44:30 2005 +0000 @@ -1,7 +1,7 @@ #ifndef VERSION_H #define VERSION_H -#define __VYM_VERSION__ "1.7.0" -#define __BUILD_DATE__ "July 13, 2005" +#define __VYM_VERSION__ "1.7.1" +#define __BUILD_DATE__ "July 19, 2005" #endif