More undo/redo commands. Undo debug output still enabled
1.1 --- a/branchobj.cpp Thu Aug 31 12:51:20 2006 +0000
1.2 +++ b/branchobj.cpp Tue Sep 05 07:56:57 2006 +0000
1.3 @@ -150,7 +150,7 @@
1.4 int BranchObj::getNum()
1.5 {
1.6 if (parObj)
1.7 - return ((BranchObj*)(parObj))->getNum ((BranchObj*)(this));
1.8 + return ((BranchObj*)parObj)->getNum (this);
1.9 else
1.10 return 0;
1.11 }
1.12 @@ -159,9 +159,10 @@
1.13 {
1.14 // keep current pointer in branch,
1.15 // otherwise save might fail
1.16 - int cur=branch.at();
1.17 + // FIXME is this _really_ still true?
1.18 +// int cur=branch.at();
1.19 int ind=branch.findRef (bo);
1.20 - branch.at(cur);
1.21 +// branch.at(cur);
1.22 return ind;
1.23 }
1.24
1.25 @@ -1204,7 +1205,7 @@
1.26 // Find current parent and
1.27 // remove pointer to myself there
1.28 if (!dst) return NULL;
1.29 - BranchObj *par=(BranchObj*)(parObj);
1.30 + BranchObj *par=(BranchObj*)parObj;
1.31 if (par)
1.32 par->removeBranchPtr (this);
1.33 else
2.1 Binary file demos/todo.vym has changed
3.1 --- a/linkablemapobj.cpp Thu Aug 31 12:51:20 2006 +0000
3.2 +++ b/linkablemapobj.cpp Tue Sep 05 07:56:57 2006 +0000
3.3 @@ -154,8 +154,7 @@
3.4 {
3.5 if (parObj)
3.6 {
3.7 - relPos.setX (absPos.x() - parObj->getChildPos().x() );
3.8 - relPos.setY (absPos.y() - parObj->getChildPos().y() );
3.9 + relPos=getRelPos();
3.10
3.11 parObj->calcBBoxSize();
3.12 parObj->requestReposition();
3.13 @@ -171,6 +170,14 @@
3.14 }
3.15 }
3.16
3.17 +QPoint LinkableMapObj::getRelPos()
3.18 +{
3.19 + if (!parObj) return QPoint();
3.20 + relPos.setX (absPos.x() - parObj->getChildPos().x() );
3.21 + relPos.setY (absPos.y() - parObj->getChildPos().y() );
3.22 + return relPos;
3.23 +}
3.24 +
3.25 int LinkableMapObj::getTopPad()
3.26 {
3.27 return topPad;
3.28 @@ -665,21 +672,6 @@
3.29 return parPos;
3.30 }
3.31
3.32 -QPoint LinkableMapObj::getRelPos()
3.33 -{
3.34 - return relPos;
3.35 -/* FIXME not needed? relPos was moved in 1.7.10 from
3.36 - floatobj to linkablemapobj. Before we had:
3.37 -
3.38 - if (!parObj) return QPoint (0,0);
3.39 - return QPoint(
3.40 - absPos.x() - parObj->x(),
3.41 - absPos.y() - parObj->y()
3.42 - );
3.43 -*/
3.44 -}
3.45 -
3.46 -
3.47 void LinkableMapObj::setUseOrientation (const bool &b)
3.48 {
3.49 if (useOrientation!=b)
4.1 --- a/linkablemapobj.h Thu Aug 31 12:51:20 2006 +0000
4.2 +++ b/linkablemapobj.h Tue Sep 05 07:56:57 2006 +0000
4.3 @@ -41,6 +41,7 @@
4.4 virtual void setUseRelPos (const bool&);
4.5 virtual void setRelPos(); // set relPos to current parentPos
4.6 virtual void setRelPos(const QPoint&);
4.7 + virtual QPoint getRelPos();
4.8 virtual void setUseOrientation (const bool &);
4.9
4.10
4.11 @@ -71,7 +72,6 @@
4.12 virtual void setDockPos(); // sets childPos and parPos
4.13 QPoint getChildPos(); // returns pos where childs dock
4.14 QPoint getParPos(); // returns pos where parents dock
4.15 - QPoint getRelPos(); // get position relative to parent (or (0,0))
4.16 LinkOrient getOrientation(); // get orientation
4.17 virtual int getDepth(); // return depth
4.18 virtual void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag)
5.1 --- a/mapeditor.cpp Thu Aug 31 12:51:20 2006 +0000
5.2 +++ b/mapeditor.cpp Tue Sep 05 07:56:57 2006 +0000
5.3 @@ -645,6 +645,18 @@
5.4 }
5.5 }
5.6 }
5.7 + else if (com=="moveRel")
5.8 + {
5.9 + if (api.checkParamCount(2) && selection )
5.10 + {
5.11 + x=api.parInt (ok,0);
5.12 + if (ok)
5.13 + {
5.14 + y=api.parInt (ok,1);
5.15 + if (ok) moveRel (x,y);
5.16 + }
5.17 + }
5.18 + }
5.19 else if (com=="delete")
5.20 {
5.21 if (api.checkParamCount(1) && selection )
5.22 @@ -763,15 +775,16 @@
5.23 undoXML(s,t);
5.24 }
5.25 } else if (com=="select")
5.26 + {
5.27 if (api.checkParamCount(1))
5.28 {
5.29 s=api.parString(ok,0);
5.30 if (ok) select (s);
5.31 }
5.32 + }
5.33 else
5.34 {
5.35 api.setError ("Unknown command in: "+atom);
5.36 - cout << "ME::parse api should have error now...\n";
5.37 }
5.38
5.39 // Any errors?
5.40 @@ -1484,10 +1497,35 @@
5.41
5.42 void MapEditor::move(const int &x, const int &y)
5.43 {
5.44 - // TODO no saveState, because this is only internal at undo so far
5.45 - if (selection) selection->move(x,y);
5.46 - if (typeid(*selection) == typeid(FloatImageObj))
5.47 - ((FloatImageObj*)selection)->setRelPos();
5.48 + if (selection)
5.49 + {
5.50 + QString ps=qpointToString (selection->getAbsPos());
5.51 + QString s=selection->getSelectString();
5.52 + saveState(
5.53 + s, "move "+ps,
5.54 + s, "move "+qpointToString (QPoint (x,y)),
5.55 + QString("Move %1 to %2").arg(getName(selection)).arg(ps));
5.56 + selection->move(x,y);
5.57 + mapCenter->reposition();
5.58 + adjustCanvasSize();
5.59 + }
5.60 +
5.61 +}
5.62 +
5.63 +void MapEditor::moveRel (const int &x, const int &y)
5.64 +{
5.65 + if (selection)
5.66 + {
5.67 + QString ps=qpointToString (selection->getRelPos());
5.68 + QString s=selection->getSelectString();
5.69 + saveState(
5.70 + s, "moveRel "+ps,
5.71 + s, "moveRel "+qpointToString (QPoint (x,y)),
5.72 + QString("Move %1 to relativ position %2").arg(getName(selection)).arg(ps));
5.73 + selection->setRelPos (QPoint(x,y));
5.74 + mapCenter->reposition();
5.75 + adjustCanvasSize();
5.76 + }
5.77 }
5.78
5.79 void MapEditor::moveBranchUp()
5.80 @@ -3401,6 +3439,7 @@
5.81 movingObj_start.setY( p.y() - selection->y() );
5.82 movingObj_orgPos.setX (lmo->x() );
5.83 movingObj_orgPos.setY (lmo->y() );
5.84 + movingObj_orgRelPos=lmo->getRelPos();
5.85
5.86 // If modMode==copy, then we want to "move" the _new_ object around
5.87 // then we need the offset from p to the _old_ selection, because of tmp
5.88 @@ -3466,9 +3505,6 @@
5.89 if (typeid(*selection) == typeid(FloatImageObj))
5.90 {
5.91 FloatObj *fo=(FloatObj*)selection;
5.92 - saveStateConstSelection(
5.93 - "move "+qpointToString(movingObj_orgPos),fo->getSelectString() ,
5.94 - QString("Move %1").arg(getName(selection)));
5.95 fo->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
5.96 fo->setRelPos();
5.97 fo->reposition();
5.98 @@ -3625,6 +3661,14 @@
5.99 // Moved FloatObj? Maybe we need to reposition
5.100 if(typeid(*selection)==typeid (FloatImageObj))
5.101 {
5.102 + FloatImageObj *fo=(FloatImageObj*)selection;
5.103 + QString pold=qpointToString(movingObj_orgRelPos);
5.104 + QString pnow=qpointToString(fo->getRelPos());
5.105 + saveStateConstSelection(
5.106 + "moveRel "+pold,
5.107 + "moveRel "+pnow,
5.108 + QString("Move %1 to relativ position %2").arg(getName(selection)).arg(pnow));
5.109 +
5.110 selection->getParObj()->requestReposition();
5.111 mapCenter->reposition();
5.112 }
5.113 @@ -3647,7 +3691,7 @@
5.114 ((LinkableMapObj*)selection)->unsetParObjTmp();
5.115
5.116 // For Redo we may need to save original selection
5.117 - QString orgSel=selection->getSelectString();
5.118 + QString preSelStr=selection->getSelectString();
5.119
5.120 copyingObj=false;
5.121 if (dst )
5.122 @@ -3655,40 +3699,40 @@
5.123 BranchObj* bsel=(BranchObj*)selection;
5.124 BranchObj* bdst=(BranchObj*)dst;
5.125
5.126 -
5.127 - QString undoCom="linkBranchToPos (\""+
5.128 - (bsel->getParObj())->getSelectString()+
5.129 - "\","+
5.130 - QString("%1").arg(bsel->getNum())+
5.131 - ","+
5.132 - QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+
5.133 - ")";
5.134 -
5.135 - // Modifiers allow to insert above/below dst
5.136 - if (e->state() & Qt::ShiftModifier)
5.137 - {
5.138 + QString preParStr=(bsel->getParObj())->getSelectString();
5.139 + QString preNum=QString::number (bsel->getNum(),10);
5.140 + QString preDstParStr;
5.141 +
5.142 + if (e->state() & Qt::ShiftModifier && dst->getParObj())
5.143 + { // Link above dst
5.144 + preDstParStr=dst->getParObj()->getSelectString();
5.145 bsel->moveBranchTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum());
5.146 } else
5.147 - if (e->state() & Qt::ControlModifier)
5.148 - {
5.149 + if (e->state() & Qt::ControlModifier && dst->getParObj())
5.150 + {
5.151 + // Link below dst
5.152 + preDstParStr=dst->getParObj()->getSelectString();
5.153 bsel->moveBranchTo ( (BranchObj*)(bdst->getParObj()), bdst->getNum()+1);
5.154 } else
5.155 - {
5.156 + { // Append to dst
5.157 + preDstParStr=dst->getSelectString();
5.158 bsel->moveBranchTo (bdst,-1);
5.159 - if (dst->getDepth()==0)
5.160 - bsel->move (savePos);
5.161 + if (dst->getDepth()==0) bsel->move (savePos);
5.162 }
5.163 + QString postSelStr=selection->getSelectString();
5.164 + QString postNum=QString::number (bsel->getNum(),10);
5.165 +
5.166 + QString undoCom="linkBranchToPos (\""+
5.167 + preParStr+ "\"," + preNum +"," +
5.168 + QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ ")";
5.169 +
5.170 QString redoCom="linkBranchToPos (\""+
5.171 - ((BranchObj*)(bsel->getParObj()))->getSelectString()+
5.172 - "\","+
5.173 - QString("%1").arg(bsel->getNum())+
5.174 - ","+
5.175 - QString ("%1,%2").arg(savePos.x()).arg(savePos.y())+
5.176 - ")";
5.177 + preDstParStr + "\"," + postNum + "," +
5.178 + QString ("%1,%2").arg(savePos.x()).arg(savePos.y())+ ")";
5.179
5.180 saveState (
5.181 - selection->getSelectString(),undoCom,
5.182 - orgSel,redoCom,
5.183 + postSelStr,undoCom,
5.184 + preSelStr, redoCom,
5.185 QString("Relink %1 to %2").arg(getName(bsel)).arg(getName(dst)) );
5.186 } else
5.187 if (selection->getDepth()==1)
5.188 @@ -3697,11 +3741,11 @@
5.189 // Therefor reposition and then use string of old selection, too
5.190 mapCenter->reposition();
5.191
5.192 - QString ps=qpointToString ( ((BranchObj*)selection)->getAbsPos() );
5.193 + QString ps=qpointToString ( ((BranchObj*)selection)->getRelPos() );
5.194 saveState(
5.195 - selection->getSelectString(), "move "+qpointToString(movingObj_orgPos),
5.196 - orgSel, "move "+ps,
5.197 - QString("Move %1 to %2").arg(getName(selection)).arg(ps));
5.198 + selection->getSelectString(), "moveRel "+qpointToString(movingObj_orgRelPos),
5.199 + preSelStr, "moveRel "+ps,
5.200 + QString("Move %1 to relative position %2").arg(getName(selection)).arg(ps));
5.201
5.202 }
5.203 // Draw the original link, before selection was moved around
6.1 --- a/mapeditor.h Thu Aug 31 12:51:20 2006 +0000
6.2 +++ b/mapeditor.h Tue Sep 05 07:56:57 2006 +0000
6.3 @@ -98,7 +98,8 @@
6.4 public:
6.5 void paste(); // paste clipboard to branch and backup
6.6 void cut(); // cut to clipboard and backup
6.7 - void move(const int &,const int&);
6.8 + void move (const int &,const int&);
6.9 + void moveRel (const int &,const int&);
6.10 void moveBranchUp();
6.11 void moveBranchDown();
6.12 QString getHeading (bool &,QPoint &); // Get heading, ok if selection is branch
6.13 @@ -223,6 +224,7 @@
6.14 MapObj* movingObj; // moving a MapObj
6.15 MapObj* linkingObj_src; // part of a link
6.16 QPoint movingObj_orgPos; // org. pos of mouse before move
6.17 + QPoint movingObj_orgRelPos; // org. relative pos of mouse before move
6.18 QPoint movingObj_start; // rel. pos of mouse to absPos
6.19 QPoint movingCont_start; // inital pos of moving Content or
6.20 QPoint movingVec; // how far has Content moved
7.1 --- a/ornamentedobj.cpp Thu Aug 31 12:51:20 2006 +0000
7.2 +++ b/ornamentedobj.cpp Tue Sep 05 07:56:57 2006 +0000
7.3 @@ -159,8 +159,7 @@
7.4
7.5 void OrnamentedObj::move2RelPos(double x, double y)
7.6 {
7.7 - if (!parObj) return;
7.8 - move (parObj->getChildPos().x()+x, parObj->getChildPos().y()+y);
7.9 + setRelPos (QPoint(x,y));
7.10 }
7.11
7.12 void OrnamentedObj::move2RelPos(QPoint p)
8.1 --- a/tex/vym.changelog Thu Aug 31 12:51:20 2006 +0000
8.2 +++ b/tex/vym.changelog Tue Sep 05 07:56:57 2006 +0000
8.3 @@ -1,3 +1,8 @@
8.4 +-------------------------------------------------------------------
8.5 +Tue Sep 5 09:55:55 CEST 2006 - uwedr
8.6 +
8.7 +- Bugfix: More undo/redo (move of floatimages, relinking of branches)
8.8 +
8.9 -------------------------------------------------------------------
8.10 Thu Aug 31 13:54:30 CEST 2006 - uwedr
8.11
9.1 --- a/version.h Thu Aug 31 12:51:20 2006 +0000
9.2 +++ b/version.h Tue Sep 05 07:56:57 2006 +0000
9.3 @@ -3,6 +3,6 @@
9.4
9.5 #define __VYM "VYM"
9.6 #define __VYM_VERSION "1.8.54"
9.7 -#define __BUILD_DATE "August 31, 2006"
9.8 +#define __BUILD_DATE "September 5, 2006"
9.9
9.10 #endif