undoCommand also for moving floatimage
authorinsilmaril
Tue, 19 Jul 2005 15:57:49 +0000
changeset 13030cd58b70d02
parent 129 9b9c7e8b9147
child 131 16b250a57c17
undoCommand also for moving floatimage
demos/todo.vym
mapeditor.cpp
mapeditor.h
     1.1 Binary file demos/todo.vym has changed
     2.1 --- a/mapeditor.cpp	Tue Jul 19 14:44:30 2005 +0000
     2.2 +++ b/mapeditor.cpp	Tue Jul 19 15:57:49 2005 +0000
     2.3 @@ -631,14 +631,13 @@
     2.4  	else if (com=="move")
     2.5  	{
     2.6  		if (api.checkParamCount(2) &&
     2.7 -			selection && 
     2.8 -			typeid(*selection) == typeid(BranchObj) ) 
     2.9 +			selection )
    2.10  		{	
    2.11  			x=api.parInt (ok,0);
    2.12  			if (ok)
    2.13  			{
    2.14  				y=api.parInt (ok,1);
    2.15 -				if (ok) ((BranchObj*)(selection))->move (x,y);
    2.16 +				if (ok) move (x,y);
    2.17  			}
    2.18  		}	
    2.19  	}
    2.20 @@ -1432,6 +1431,14 @@
    2.21  	adjustCanvasSize();
    2.22  }
    2.23  
    2.24 +void MapEditor::move(const int &x, const int &y)
    2.25 +{
    2.26 +	// FIXME  no saveState, because this is only internal at undo so far
    2.27 +	if (selection) selection->move(x,y);
    2.28 +	if (typeid(*selection) == typeid(FloatImageObj))
    2.29 +		((FloatImageObj*)(selection))->setRelPos();
    2.30 +}
    2.31 +
    2.32  void MapEditor::moveBranchUp()
    2.33  {
    2.34  	// Finish open lineEdits
    2.35 @@ -1474,21 +1481,6 @@
    2.36  	}	
    2.37  }
    2.38  
    2.39 -void MapEditor::linkBranchToPos (LinkableMapObj *dst, const int &pos, const QPoint &p)
    2.40 -{
    2.41 -	// FIXME  no saveState, because this is only internal at undo so far
    2.42 -	if (selection && typeid(*selection) == typeid(BranchObj) ) 
    2.43 -	{
    2.44 -		if (dst  &&  typeid(*dst) == typeid(BranchObj) ) 
    2.45 -			((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),-1);
    2.46 -		if (dst  &&  typeid(*dst) == typeid(MapCenterObj) ) 
    2.47 -		{
    2.48 -			((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),-1);
    2.49 -			((BranchObj*)(selection))->move (p);
    2.50 -		}	
    2.51 -	}
    2.52 -}
    2.53 -
    2.54  void MapEditor::editHeading()
    2.55  {
    2.56  	// Finish open lineEdits
    2.57 @@ -2943,8 +2935,6 @@
    2.58  	}
    2.59  }
    2.60  
    2.61 -#include "api.h"
    2.62 -
    2.63  void MapEditor::testFunction()
    2.64  {
    2.65  	cout << "MapEditor::testFunction() called\n";
    2.66 @@ -3174,7 +3164,7 @@
    2.67  		if (typeid(*selection) == typeid(FloatImageObj))
    2.68  		{
    2.69  			setChanged();
    2.70 -			saveState();
    2.71 +			saveState("move "+qpointToString(movingObj_orgPos));
    2.72  			FloatObj *fo=(FloatObj*)(selection);
    2.73  			if (fo->getLinkStyle()==StyleUndef) 
    2.74  			{
    2.75 @@ -3396,7 +3386,6 @@
    2.76  					bs->moveBranchTo ((BranchObj*)(dst),-1);
    2.77  					if (dst->getDepth()==0) 
    2.78  						bs->move (savePos);
    2.79 -						cout << "ME::release  start was: "<<movingObj_orgPos<<endl;
    2.80  				} 
    2.81  			}	
    2.82  			// Draw the original link, before selection was moved around
     3.1 --- a/mapeditor.h	Tue Jul 19 14:44:30 2005 +0000
     3.2 +++ b/mapeditor.h	Tue Jul 19 15:57:49 2005 +0000
     3.3 @@ -82,9 +82,9 @@
     3.4  public:	
     3.5      void paste();		// paste clipboard to branch and backup
     3.6      void cut();			// cut to clipboard and backup
     3.7 +    void move(const int &,const int&);
     3.8      void moveBranchUp();
     3.9      void moveBranchDown();
    3.10 -    void linkBranchToPos(LinkableMapObj*,const int &, const QPoint &);// move selection to dst and pos
    3.11      void editHeading();					// Start editing heading 
    3.12  private:
    3.13  	void setHeading(const QString &);	// Just set the heading for selection