No jumping around left of MCO if animation is turned on release-1-12-maintained
authorinsilmaril
Thu, 17 Jul 2008 12:55:24 +0000
branchrelease-1-12-maintained
changeset 416f28020b33d1
parent 40 394b2f297e1d
child 42 b2c0fe7cfdef
No jumping around left of MCO if animation is turned on
branchobj.cpp
branchobj.h
mapeditor.cpp
     1.1 --- a/branchobj.cpp	Thu Jul 17 11:11:55 2008 +0000
     1.2 +++ b/branchobj.cpp	Thu Jul 17 12:55:24 2008 +0000
     1.3 @@ -1310,7 +1310,7 @@
     1.4  	}	
     1.5  }
     1.6  
     1.7 -void BranchObj::alignRelativeTo (QPointF ref)
     1.8 +void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
     1.9  {
    1.10  	qreal th = bboxTotal.height();	
    1.11  // TODO testing
    1.12 @@ -1359,18 +1359,19 @@
    1.13  		{
    1.14  			LinkableMapObj::Orientation o;
    1.15  			o=parObj->getOrientation();
    1.16 -			switch (orientation) 
    1.17 -			{
    1.18 -				case LinkableMapObj::LeftOfCenter:
    1.19 -					move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
    1.20 -				break;
    1.21 -				case LinkableMapObj::RightOfCenter:	
    1.22 -					move (ref.x() , ref.y() + (th-bbox.height())/2  );
    1.23 -				break;
    1.24 -				default:
    1.25 -					qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
    1.26 -				break;
    1.27 -			}	
    1.28 +			if (alignSelf)
    1.29 +				switch (orientation) 
    1.30 +				{
    1.31 +					case LinkableMapObj::LeftOfCenter:
    1.32 +						move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
    1.33 +					break;
    1.34 +					case LinkableMapObj::RightOfCenter:	
    1.35 +						move (ref.x() , ref.y() + (th-bbox.height())/2  );
    1.36 +					break;
    1.37 +					default:
    1.38 +						qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
    1.39 +					break;
    1.40 +				}	
    1.41  		}
    1.42      }		
    1.43  
    1.44 @@ -1393,7 +1394,7 @@
    1.45      {	
    1.46  		if (!branch.at(i)->isHidden())
    1.47  		{
    1.48 -			branch.at(i)->alignRelativeTo (ref2);
    1.49 +			branch.at(i)->alignRelativeTo (ref2,true);
    1.50  			ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChilds().height() );
    1.51  		}
    1.52      }
     2.1 --- a/branchobj.h	Thu Jul 17 11:11:55 2008 +0000
     2.2 +++ b/branchobj.h	Thu Jul 17 12:55:24 2008 +0000
     2.3 @@ -4,18 +4,27 @@
     2.4  #include "floatimageobj.h"
     2.5  #include "linkablemapobj.h"
     2.6  #include "ornamentedobj.h"
     2.7 +#include "xlinkobj.h"
     2.8  
     2.9 -class BranchObjPtrList : public QPtrList<BranchObj>
    2.10 -{
    2.11 -	virtual int compareItems (QPtrCollection::Item i, QPtrCollection::Item j);
    2.12 -};
    2.13 +
    2.14 +bool isAbove(BranchObj*,BranchObj*);
    2.15 +
    2.16 +/*! \brief A branch visible in the map */
    2.17 +
    2.18 +/*! If HideExport is used, this branch and its childs will be hidden in export */
    2.19 +enum HideTmpMode {HideNone, HideExport};
    2.20 +
    2.21  
    2.22  /////////////////////////////////////////////////////////////////////////////
    2.23  class BranchObj:public OrnamentedObj {
    2.24  public:
    2.25 +	/*! New branches will get use same color for heading as parent */
    2.26 +	enum BranchModification {NewBranch, MovedBranch};
    2.27 +
    2.28 +
    2.29      BranchObj ();
    2.30 -    BranchObj (QCanvas*);
    2.31 -    BranchObj (QCanvas*, LinkableMapObj* parent);
    2.32 +    BranchObj (QGraphicsScene*);
    2.33 +    BranchObj (QGraphicsScene*, LinkableMapObj* parent);
    2.34      ~BranchObj ();
    2.35  	bool operator< ( const BranchObj & );
    2.36  	bool operator== ( const BranchObj & );
    2.37 @@ -27,7 +36,8 @@
    2.38  	virtual int getFloatImageNum(FloatImageObj*);		
    2.39  	virtual int countBranches();		
    2.40  	virtual int countFloatImages();		
    2.41 -    virtual void setParObjTmp (LinkableMapObj*,QPoint,int);// Only for moving Obj around
    2.42 +	virtual int countXLinks();		
    2.43 +    virtual void setParObjTmp (LinkableMapObj*,QPointF,int);// Only for moving Obj around
    2.44  	virtual void unsetParObjTmp();			// reuse original ParObj
    2.45  
    2.46  	virtual void unScroll();				
    2.47 @@ -40,72 +50,105 @@
    2.48  	virtual void setVisibility(bool,int);	// set visibility
    2.49      virtual void setVisibility(bool);	    // set vis. for w
    2.50  	virtual void setLinkColor();			// set the color of link
    2.51 -	virtual void setColor(QColor,bool);		// set the color of heading
    2.52 -
    2.53 +	virtual void setColorSubtree(QColor);	// set the color of heading
    2.54  
    2.55  	BranchObj* first ();				// set Iterator to first LMO
    2.56  	BranchObj* next ();					// find next LMO after given one
    2.57  	BranchObj* getLastIterator();		// to interrupt and resume next iteration
    2.58  	void setLastIterator (BranchObj*);	// needed by next() 
    2.59  
    2.60 +	virtual void positionContents();
    2.61      virtual void move (double x,double y);
    2.62 -    virtual void move (QPoint);
    2.63 +    virtual void move (QPointF);
    2.64      virtual void moveBy (double x,double y);
    2.65 -    virtual void moveBy (QPoint);
    2.66 +    virtual void moveBy (QPointF);
    2.67      virtual void positionBBox();
    2.68      virtual void calcBBoxSize();
    2.69 -    virtual LinkableMapObj* findMapObj(QPoint,LinkableMapObj*);	// find MapObj 
    2.70 +	virtual void setDockPos();
    2.71 +    virtual LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
    2.72 +    virtual LinkableMapObj* findID (QString sid);	// find Obj by ID string
    2.73      virtual void setHeading (QString);
    2.74 -    virtual void setURL (QString);
    2.75 -    virtual QString getURL ();
    2.76 -    virtual void setVymLink (QString);
    2.77 -    virtual QString getVymLink ();
    2.78 -	virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data recursivly to tempdir
    2.79 -	virtual LinkableMapObj* addFloatImage();
    2.80 -	virtual LinkableMapObj* addFloatImage(FloatImageObj*);
    2.81 +
    2.82 +	virtual void setHideTmp (HideTmpMode);
    2.83 +	virtual bool hasHiddenExportParent ();
    2.84 +
    2.85 +	virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data recursivly to tempdir
    2.86 +	virtual void addXLink (XLinkObj*);
    2.87 +	virtual void removeXLinkRef (XLinkObj*);// Remove ref in list
    2.88 +	virtual void deleteXLink (XLinkObj*);	// remove references and delete XLinkObj 
    2.89 +	virtual void deleteXLinkAt (int);		// remove references and delete XLinkObj 
    2.90 +	virtual XLinkObj* XLinkAt (int);		// return reference of XLinkObj 
    2.91 +	virtual int countXLink ();
    2.92 +	virtual BranchObj* XLinkTargetAt (int);
    2.93 +	void setIncludeImagesVer(bool);
    2.94 +	bool getIncludeImagesVer();
    2.95 +	void setIncludeImagesHor(bool);
    2.96 +	bool getIncludeImagesHor();
    2.97 +	QString getIncludeImageAttr();
    2.98 +	virtual FloatImageObj* addFloatImage();
    2.99 +	virtual FloatImageObj* addFloatImage(FloatImageObj*);
   2.100  	virtual void removeFloatImage(FloatImageObj*);
   2.101      virtual FloatImageObj* getFirstFloatImage();
   2.102      virtual FloatImageObj* getLastFloatImage();
   2.103  	virtual FloatImageObj* getFloatImageNum(const uint &);
   2.104  protected:	
   2.105 -	virtual void savePosInAngle();			// write pos in angle for resorting			
   2.106 +	virtual void savePosInAngle();					// write pos in angle for resorting			
   2.107 +	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
   2.108  public:	
   2.109      virtual BranchObj* addBranch();
   2.110      virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
   2.111 +    virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
   2.112      virtual BranchObj* insertBranch(int);
   2.113      virtual BranchObj* insertBranch(BranchObj*,int);
   2.114 +    virtual BranchObj* insertBranchPtr (BranchObj*,int);
   2.115 +    virtual void removeBranchHere(BranchObj*);  
   2.116 +    virtual void removeChilds();  
   2.117      virtual void removeBranch(BranchObj*);  
   2.118 +    virtual void removeBranchPtr (BranchObj*);  
   2.119      virtual void setLastSelectedBranch(BranchObj*);
   2.120      virtual BranchObj* getLastSelectedBranch();
   2.121      virtual BranchObj* getFirstBranch();
   2.122      virtual BranchObj* getLastBranch();
   2.123 -	virtual BranchObj* getBranchNum(const uint &);
   2.124 +	virtual BranchObj* getBranchNum(int);
   2.125 +    virtual bool canMoveBranchUp();
   2.126      virtual BranchObj* moveBranchUp(BranchObj*);
   2.127 +    virtual bool canMoveBranchDown();
   2.128      virtual BranchObj* moveBranchDown(BranchObj*);
   2.129 +    virtual void sortChildren();
   2.130 +    virtual BranchObj* linkTo (BranchObj*, int);
   2.131 +    virtual void alignRelativeTo(const QPointF ref, bool alignSelf=false );
   2.132 +	virtual void reposition();
   2.133 +	virtual void unsetAllRepositionRequests();
   2.134  
   2.135 -    virtual void alignRelativeTo(const QPoint );
   2.136 -	virtual void reposition();
   2.137 -
   2.138 -	virtual QRect getTotalBBox();			// return BBox including childs			
   2.139 -	virtual QRect getBBoxSizeWithChilds();	// return size of BBox including childs  
   2.140 +	virtual QPolygonF shape();				//!< Returns arbitrary bounding polygon
   2.141 +	virtual QRectF getTotalBBox();			// return BBox including childs			
   2.142 +	virtual QRectF getBBoxSizeWithChilds();	// return size of BBox including childs  
   2.143  	virtual void calcBBoxSizeWithChilds();	// calc size of  BBox including childs recursivly
   2.144  
   2.145      virtual void select();
   2.146      virtual void unselect();
   2.147  	virtual QString getSelectString();
   2.148 +	virtual void setAnimation(const AnimPoint &ap);
   2.149 +	virtual bool animate();
   2.150  
   2.151  protected:
   2.152  	static BranchObj* itLast;		// iterator for first(), next()
   2.153 -    BranchObjPtrList branch;		// all child branches
   2.154 -	QPtrList<FloatImageObj> floatimage;	// child images
   2.155 +	static BranchObj* itFirst;		// first iterator for first(), next()
   2.156 +    QList<BranchObj*> branch;		// all child branches
   2.157 +	QList<FloatImageObj*> floatimage;// child images
   2.158 +	QList<XLinkObj*> xlink;			// xlinks to other branches
   2.159 +
   2.160 +	AnimPoint anim;
   2.161 +
   2.162  public:	
   2.163  	float angle;					// used in mainbranch to reorder mainbranches
   2.164  protected:	
   2.165      int lastSelectedBranch;			// for going deeper into tree
   2.166  	bool scrolled;					// true if all childs are scrolled and thus invisible
   2.167  	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
   2.168 -	QString url;					// url to external doc
   2.169 -	QString vymLink;				// path to another map
   2.170 +	bool includeImagesVer;			// include floatimages in bbox vertically
   2.171 +	bool includeImagesHor;			// include floatimages in bbox horizontally
   2.172 +
   2.173  };
   2.174  
   2.175  
     3.1 --- a/mapeditor.cpp	Thu Jul 17 11:11:55 2008 +0000
     3.2 +++ b/mapeditor.cpp	Thu Jul 17 12:55:24 2008 +0000
     3.3 @@ -4760,12 +4760,7 @@
     3.4  				} else
     3.5  				{
     3.6  					// Move ordinary branch
     3.7 -					if (lmosel->getOrientation() == LinkableMapObj::LeftOfCenter)
     3.8 -						// Add width of bbox here, otherwise alignRelTo will cause jumping around
     3.9 -						lmosel->move(p.x() -movingObj_start.x()+lmosel->getBBox().width(), 
    3.10 -							p.y()-movingObj_start.y() +lmosel->getTopPad() );		
    3.11 -					else	
    3.12 -						lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() -lmosel->getTopPad());
    3.13 +					lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y()  );		
    3.14  				} 
    3.15  
    3.16  				// Maybe we can relink temporary?