# 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 @@
0
0
- 614
- 757
+ 514
+ 468
@@ -21,11 +21,11 @@
Export XHTML
-
+
unnamed
-
+
layout17
@@ -80,14 +80,60 @@
-
+
+
+ layout17
+
+
+
+ unnamed
+
+
+
+ spacer5
+
+
+ Horizontal
+
+
+ Expanding
+
+
+
+ 61
+ 21
+
+
+
+
+
+ exportButton
+
+
+ Export
+
+
+ true
+
+
+
+
+ cancelButton
+
+
+ Cancel
+
+
+
+
+
buttonGroup2
- 3
- 3
+ 5
+ 5
0
0
@@ -155,180 +201,260 @@
-
+
- layout6
+ groupBox2
+
+
+ Stylesheets
unnamed
-
+
- browsePostExportButton
+ layout7
-
-
- 0
- 0
- 0
- 0
-
+
+
+ unnamed
+
+
+
+ textLabel2
+
+
+
+ 0
+ 5
+ 0
+ 0
+
+
+
+
+ 125
+ 0
+
+
+
+ XSL:
+
+
+ AlignVCenter|AlignRight
+
+
+
+
+ lineEditXSL
+
+
+
+
+ browseXSLButton
+
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ Browse
+
+
+
+
+
+
+ layout6
-
- Browse
-
-
-
-
- textLabel1_3
-
-
-
- 1
- 5
- 0
- 0
-
-
-
- Before export:
-
-
- AlignVCenter|AlignRight
-
-
-
-
- lineEditXSL
-
-
-
-
- browseXSLButton
-
-
-
- 0
- 0
- 0
- 0
-
-
-
- Browse
-
-
-
-
- lineEditPreScript
-
-
-
-
- browsePreExportButton
-
-
-
- 0
- 0
- 0
- 0
-
-
-
- Browse
-
-
-
-
- textLabel2_3
-
-
- Stylesheets:
-
-
-
-
- browseCSSButton
-
-
-
- 0
- 0
- 0
- 0
-
-
-
- Browse
-
-
-
-
- textLabel1_2
-
-
- CSS:
-
-
- AlignVCenter|AlignRight
-
-
-
-
- textLabel2_2
-
-
-
- 1
- 5
- 0
- 0
-
-
-
- NoFrame
-
-
- After Export:
-
-
- AlignVCenter|AlignRight
-
-
-
-
- lineEditCSS
-
-
-
-
- textLabel2
-
-
- XSL:
-
-
- AlignVCenter|AlignRight
-
-
-
-
- lineEditPostScript
-
-
-
-
- textLabel1_4
-
-
- Scripts:
-
+
+
+ unnamed
+
+
+
+ textLabel1_2
+
+
+
+ 0
+ 5
+ 0
+ 0
+
+
+
+
+ 125
+ 0
+
+
+
+ CSS:
+
+
+ AlignVCenter|AlignRight
+
+
+
+
+ lineEditCSS
+
+
+
+
+ browseCSSButton
+
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ Browse
+
+
+
-
+
+
+ groupBox1
+
+
+ Scripts
+
+
+
+ unnamed
+
+
+
+ layout4
+
+
+
+ unnamed
+
+
+
+ textLabel1_3
+
+
+
+ 0
+ 5
+ 0
+ 0
+
+
+
+
+ 125
+ 0
+
+
+
+ Before export:
+
+
+ AlignVCenter|AlignRight
+
+
+
+
+ lineEditPostScript
+
+
+
+
+ browsePreExportButton
+
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ Browse
+
+
+
+
+
+
+ layout5
+
+
+
+ unnamed
+
+
+
+ textLabel2_2
+
+
+
+ 0
+ 5
+ 0
+ 0
+
+
+
+
+ 125
+ 0
+
+
+
+ NoFrame
+
+
+ After Export:
+
+
+ AlignVCenter|AlignRight
+
+
+
+
+ lineEditPreScript
+
+
+
+
+ browsePostExportButton
+
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+
+ Browse
+
+
+
+
+
+
+
spacer3
@@ -336,62 +462,16 @@
Vertical
- Expanding
+ MinimumExpanding
20
- 60
+ 20
-
-
- layout17
-
-
-
- unnamed
-
-
-
- spacer5
-
-
- Horizontal
-
-
- Expanding
-
-
-
- 61
- 21
-
-
-
-
-
- exportButton
-
-
- Export
-
-
- true
-
-
-
-
- cancelButton
-
-
- Cancel
-
-
-
-
-
+
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 ")+
- "'"+s+"'");
+ ""+s+"");
}
}
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
#include
#include
+#include
#include
#include
@@ -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="<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: \""<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: "<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; iprovides("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 (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