# HG changeset patch
# User insilmaril
# Date 1216299324 0
# Node ID 6f28020b33d1902a1200a5c3d983e1e1f5de6c6b
# Parent  394b2f297e1d6f8c141ebba597750914f0c6fb55
No jumping around left of MCO if animation is turned on

diff -r 394b2f297e1d -r 6f28020b33d1 branchobj.cpp
--- a/branchobj.cpp	Thu Jul 17 11:11:55 2008 +0000
+++ b/branchobj.cpp	Thu Jul 17 12:55:24 2008 +0000
@@ -1310,7 +1310,7 @@
 	}	
 }
 
-void BranchObj::alignRelativeTo (QPointF ref)
+void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
 {
 	qreal th = bboxTotal.height();	
 // TODO testing
@@ -1359,18 +1359,19 @@
 		{
 			LinkableMapObj::Orientation o;
 			o=parObj->getOrientation();
-			switch (orientation) 
-			{
-				case LinkableMapObj::LeftOfCenter:
-					move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
-				break;
-				case LinkableMapObj::RightOfCenter:	
-					move (ref.x() , ref.y() + (th-bbox.height())/2  );
-				break;
-				default:
-					qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
-				break;
-			}	
+			if (alignSelf)
+				switch (orientation) 
+				{
+					case LinkableMapObj::LeftOfCenter:
+						move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
+					break;
+					case LinkableMapObj::RightOfCenter:	
+						move (ref.x() , ref.y() + (th-bbox.height())/2  );
+					break;
+					default:
+						qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
+					break;
+				}	
 		}
     }		
 
@@ -1393,7 +1394,7 @@
     {	
 		if (!branch.at(i)->isHidden())
 		{
-			branch.at(i)->alignRelativeTo (ref2);
+			branch.at(i)->alignRelativeTo (ref2,true);
 			ref2.setY(ref2.y() + branch.at(i)->getBBoxSizeWithChilds().height() );
 		}
     }
diff -r 394b2f297e1d -r 6f28020b33d1 branchobj.h
--- a/branchobj.h	Thu Jul 17 11:11:55 2008 +0000
+++ b/branchobj.h	Thu Jul 17 12:55:24 2008 +0000
@@ -4,18 +4,27 @@
 #include "floatimageobj.h"
 #include "linkablemapobj.h"
 #include "ornamentedobj.h"
+#include "xlinkobj.h"
 
-class BranchObjPtrList : public QPtrList<BranchObj>
-{
-	virtual int compareItems (QPtrCollection::Item i, QPtrCollection::Item j);
-};
+
+bool isAbove(BranchObj*,BranchObj*);
+
+/*! \brief A branch visible in the map */
+
+/*! If HideExport is used, this branch and its childs will be hidden in export */
+enum HideTmpMode {HideNone, HideExport};
+
 
 /////////////////////////////////////////////////////////////////////////////
 class BranchObj:public OrnamentedObj {
 public:
+	/*! New branches will get use same color for heading as parent */
+	enum BranchModification {NewBranch, MovedBranch};
+
+
     BranchObj ();
-    BranchObj (QCanvas*);
-    BranchObj (QCanvas*, LinkableMapObj* parent);
+    BranchObj (QGraphicsScene*);
+    BranchObj (QGraphicsScene*, LinkableMapObj* parent);
     ~BranchObj ();
 	bool operator< ( const BranchObj & );
 	bool operator== ( const BranchObj & );
@@ -27,7 +36,8 @@
 	virtual int getFloatImageNum(FloatImageObj*);		
 	virtual int countBranches();		
 	virtual int countFloatImages();		
-    virtual void setParObjTmp (LinkableMapObj*,QPoint,int);// Only for moving Obj around
+	virtual int countXLinks();		
+    virtual void setParObjTmp (LinkableMapObj*,QPointF,int);// Only for moving Obj around
 	virtual void unsetParObjTmp();			// reuse original ParObj
 
 	virtual void unScroll();				
@@ -40,72 +50,105 @@
 	virtual void setVisibility(bool,int);	// set visibility
     virtual void setVisibility(bool);	    // set vis. for w
 	virtual void setLinkColor();			// set the color of link
-	virtual void setColor(QColor,bool);		// set the color of heading
-
+	virtual void setColorSubtree(QColor);	// set the color of heading
 
 	BranchObj* first ();				// set Iterator to first LMO
 	BranchObj* next ();					// find next LMO after given one
 	BranchObj* getLastIterator();		// to interrupt and resume next iteration
 	void setLastIterator (BranchObj*);	// needed by next() 
 
+	virtual void positionContents();
     virtual void move (double x,double y);
-    virtual void move (QPoint);
+    virtual void move (QPointF);
     virtual void moveBy (double x,double y);
-    virtual void moveBy (QPoint);
+    virtual void moveBy (QPointF);
     virtual void positionBBox();
     virtual void calcBBoxSize();
-    virtual LinkableMapObj* findMapObj(QPoint,LinkableMapObj*);	// find MapObj 
+	virtual void setDockPos();
+    virtual LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
+    virtual LinkableMapObj* findID (QString sid);	// find Obj by ID string
     virtual void setHeading (QString);
-    virtual void setURL (QString);
-    virtual QString getURL ();
-    virtual void setVymLink (QString);
-    virtual QString getVymLink ();
-	virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data recursivly to tempdir
-	virtual LinkableMapObj* addFloatImage();
-	virtual LinkableMapObj* addFloatImage(FloatImageObj*);
+
+	virtual void setHideTmp (HideTmpMode);
+	virtual bool hasHiddenExportParent ();
+
+	virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data recursivly to tempdir
+	virtual void addXLink (XLinkObj*);
+	virtual void removeXLinkRef (XLinkObj*);// Remove ref in list
+	virtual void deleteXLink (XLinkObj*);	// remove references and delete XLinkObj 
+	virtual void deleteXLinkAt (int);		// remove references and delete XLinkObj 
+	virtual XLinkObj* XLinkAt (int);		// return reference of XLinkObj 
+	virtual int countXLink ();
+	virtual BranchObj* XLinkTargetAt (int);
+	void setIncludeImagesVer(bool);
+	bool getIncludeImagesVer();
+	void setIncludeImagesHor(bool);
+	bool getIncludeImagesHor();
+	QString getIncludeImageAttr();
+	virtual FloatImageObj* addFloatImage();
+	virtual FloatImageObj* addFloatImage(FloatImageObj*);
 	virtual void removeFloatImage(FloatImageObj*);
     virtual FloatImageObj* getFirstFloatImage();
     virtual FloatImageObj* getLastFloatImage();
 	virtual FloatImageObj* getFloatImageNum(const uint &);
 protected:	
-	virtual void savePosInAngle();			// write pos in angle for resorting			
+	virtual void savePosInAngle();					// write pos in angle for resorting			
+	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
 public:	
     virtual BranchObj* addBranch();
     virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
+    virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
     virtual BranchObj* insertBranch(int);
     virtual BranchObj* insertBranch(BranchObj*,int);
+    virtual BranchObj* insertBranchPtr (BranchObj*,int);
+    virtual void removeBranchHere(BranchObj*);  
+    virtual void removeChilds();  
     virtual void removeBranch(BranchObj*);  
+    virtual void removeBranchPtr (BranchObj*);  
     virtual void setLastSelectedBranch(BranchObj*);
     virtual BranchObj* getLastSelectedBranch();
     virtual BranchObj* getFirstBranch();
     virtual BranchObj* getLastBranch();
-	virtual BranchObj* getBranchNum(const uint &);
+	virtual BranchObj* getBranchNum(int);
+    virtual bool canMoveBranchUp();
     virtual BranchObj* moveBranchUp(BranchObj*);
+    virtual bool canMoveBranchDown();
     virtual BranchObj* moveBranchDown(BranchObj*);
+    virtual void sortChildren();
+    virtual BranchObj* linkTo (BranchObj*, int);
+    virtual void alignRelativeTo(const QPointF ref, bool alignSelf=false );
+	virtual void reposition();
+	virtual void unsetAllRepositionRequests();
 
-    virtual void alignRelativeTo(const QPoint );
-	virtual void reposition();
-
-	virtual QRect getTotalBBox();			// return BBox including childs			
-	virtual QRect getBBoxSizeWithChilds();	// return size of BBox including childs  
+	virtual QPolygonF shape();				//!< Returns arbitrary bounding polygon
+	virtual QRectF getTotalBBox();			// return BBox including childs			
+	virtual QRectF getBBoxSizeWithChilds();	// return size of BBox including childs  
 	virtual void calcBBoxSizeWithChilds();	// calc size of  BBox including childs recursivly
 
     virtual void select();
     virtual void unselect();
 	virtual QString getSelectString();
+	virtual void setAnimation(const AnimPoint &ap);
+	virtual bool animate();
 
 protected:
 	static BranchObj* itLast;		// iterator for first(), next()
-    BranchObjPtrList branch;		// all child branches
-	QPtrList<FloatImageObj> floatimage;	// child images
+	static BranchObj* itFirst;		// first iterator for first(), next()
+    QList<BranchObj*> branch;		// all child branches
+	QList<FloatImageObj*> floatimage;// child images
+	QList<XLinkObj*> xlink;			// xlinks to other branches
+
+	AnimPoint anim;
+
 public:	
 	float angle;					// used in mainbranch to reorder mainbranches
 protected:	
     int lastSelectedBranch;			// for going deeper into tree
 	bool scrolled;					// true if all childs are scrolled and thus invisible
 	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
-	QString url;					// url to external doc
-	QString vymLink;				// path to another map
+	bool includeImagesVer;			// include floatimages in bbox vertically
+	bool includeImagesHor;			// include floatimages in bbox horizontally
+
 };
 
 
diff -r 394b2f297e1d -r 6f28020b33d1 mapeditor.cpp
--- a/mapeditor.cpp	Thu Jul 17 11:11:55 2008 +0000
+++ b/mapeditor.cpp	Thu Jul 17 12:55:24 2008 +0000
@@ -4760,12 +4760,7 @@
 				} else
 				{
 					// Move ordinary branch
-					if (lmosel->getOrientation() == LinkableMapObj::LeftOfCenter)
-						// Add width of bbox here, otherwise alignRelTo will cause jumping around
-						lmosel->move(p.x() -movingObj_start.x()+lmosel->getBBox().width(), 
-							p.y()-movingObj_start.y() +lmosel->getTopPad() );		
-					else	
-						lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() -lmosel->getTopPad());
+					lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y()  );		
 				} 
 
 				// Maybe we can relink temporary?