branchobj.h
author insilmaril
Wed, 30 Jul 2008 14:42:03 +0000
branchrelease-1-12-maintained
changeset 43 cf274b28e5fe
parent 41 6f28020b33d1
permissions -rw-r--r--
Fixed animation timer, which didn't stop once activated
     1 #ifndef BRANCHOBJ_H
     2 #define BRANCHOBJ_H
     3 
     4 #include "floatimageobj.h"
     5 #include "linkablemapobj.h"
     6 #include "ornamentedobj.h"
     7 #include "xlinkobj.h"
     8 
     9 
    10 bool isAbove(BranchObj*,BranchObj*);
    11 
    12 /*! \brief A branch visible in the map */
    13 
    14 /*! If HideExport is used, this branch and its childs will be hidden in export */
    15 enum HideTmpMode {HideNone, HideExport};
    16 
    17 
    18 /////////////////////////////////////////////////////////////////////////////
    19 class BranchObj:public OrnamentedObj {
    20 public:
    21 	/*! New branches will get use same color for heading as parent */
    22 	enum BranchModification {NewBranch, MovedBranch};
    23 
    24 
    25     BranchObj ();
    26     BranchObj (QGraphicsScene*);
    27     BranchObj (QGraphicsScene*, LinkableMapObj* parent);
    28     ~BranchObj ();
    29 	bool operator< ( const BranchObj & );
    30 	bool operator== ( const BranchObj & );
    31     virtual void init ();
    32     virtual void copy (BranchObj*);
    33     void clear();
    34 	virtual int getNum();				// return number of this in parent
    35 	virtual int getNum(BranchObj*);		// return number of this in parent
    36 	virtual int getFloatImageNum(FloatImageObj*);		
    37 	virtual int countBranches();		
    38 	virtual int countFloatImages();		
    39 	virtual int countXLinks();		
    40     virtual void setParObjTmp (LinkableMapObj*,QPointF,int);// Only for moving Obj around
    41 	virtual void unsetParObjTmp();			// reuse original ParObj
    42 
    43 	virtual void unScroll();				
    44 	virtual void toggleScroll();			// scroll or unscroll
    45 	virtual bool isScrolled();				// returns scroll state
    46 	virtual bool hasScrolledParent(BranchObj*);	// true, if any of the parents is scrolled
    47 	virtual void tmpUnscroll();				// unscroll scrolled parents temporary e.g. during "find" process
    48 	virtual void resetTmpUnscroll();		// scroll all tmp scrolled parents again e.g. when unselecting
    49 
    50 	virtual void setVisibility(bool,int);	// set visibility
    51     virtual void setVisibility(bool);	    // set vis. for w
    52 	virtual void setLinkColor();			// set the color of link
    53 	virtual void setColorSubtree(QColor);	// set the color of heading
    54 
    55 	BranchObj* first ();				// set Iterator to first LMO
    56 	BranchObj* next ();					// find next LMO after given one
    57 	BranchObj* getLastIterator();		// to interrupt and resume next iteration
    58 	void setLastIterator (BranchObj*);	// needed by next() 
    59 
    60 	virtual void positionContents();
    61     virtual void move (double x,double y);
    62     virtual void move (QPointF);
    63     virtual void moveBy (double x,double y);
    64     virtual void moveBy (QPointF);
    65     virtual void positionBBox();
    66     virtual void calcBBoxSize();
    67 	virtual void setDockPos();
    68     virtual LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
    69     virtual LinkableMapObj* findID (QString sid);	// find Obj by ID string
    70     virtual void setHeading (QString);
    71 
    72 	virtual void setHideTmp (HideTmpMode);
    73 	virtual bool hasHiddenExportParent ();
    74 
    75 	virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data recursivly to tempdir
    76 	virtual void addXLink (XLinkObj*);
    77 	virtual void removeXLinkRef (XLinkObj*);// Remove ref in list
    78 	virtual void deleteXLink (XLinkObj*);	// remove references and delete XLinkObj 
    79 	virtual void deleteXLinkAt (int);		// remove references and delete XLinkObj 
    80 	virtual XLinkObj* XLinkAt (int);		// return reference of XLinkObj 
    81 	virtual int countXLink ();
    82 	virtual BranchObj* XLinkTargetAt (int);
    83 	void setIncludeImagesVer(bool);
    84 	bool getIncludeImagesVer();
    85 	void setIncludeImagesHor(bool);
    86 	bool getIncludeImagesHor();
    87 	QString getIncludeImageAttr();
    88 	virtual FloatImageObj* addFloatImage();
    89 	virtual FloatImageObj* addFloatImage(FloatImageObj*);
    90 	virtual void removeFloatImage(FloatImageObj*);
    91     virtual FloatImageObj* getFirstFloatImage();
    92     virtual FloatImageObj* getLastFloatImage();
    93 	virtual FloatImageObj* getFloatImageNum(const uint &);
    94 protected:	
    95 	virtual void savePosInAngle();					// write pos in angle for resorting			
    96 	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
    97 public:	
    98     virtual BranchObj* addBranch();
    99     virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
   100     virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
   101     virtual BranchObj* insertBranch(int);
   102     virtual BranchObj* insertBranch(BranchObj*,int);
   103     virtual BranchObj* insertBranchPtr (BranchObj*,int);
   104     virtual void removeBranchHere(BranchObj*);  
   105     virtual void removeChilds();  
   106     virtual void removeBranch(BranchObj*);  
   107     virtual void removeBranchPtr (BranchObj*);  
   108     virtual void setLastSelectedBranch(BranchObj*);
   109     virtual BranchObj* getLastSelectedBranch();
   110     virtual BranchObj* getFirstBranch();
   111     virtual BranchObj* getLastBranch();
   112 	virtual BranchObj* getBranchNum(int);
   113     virtual bool canMoveBranchUp();
   114     virtual BranchObj* moveBranchUp(BranchObj*);
   115     virtual bool canMoveBranchDown();
   116     virtual BranchObj* moveBranchDown(BranchObj*);
   117     virtual void sortChildren();
   118     virtual BranchObj* linkTo (BranchObj*, int);
   119     virtual void alignRelativeTo(const QPointF ref, bool alignSelf=false );
   120 	virtual void reposition();
   121 	virtual void unsetAllRepositionRequests();
   122 
   123 	virtual QPolygonF shape();				//!< Returns arbitrary bounding polygon
   124 	virtual QRectF getTotalBBox();			// return BBox including childs			
   125 	virtual QRectF getBBoxSizeWithChilds();	// return size of BBox including childs  
   126 	virtual void calcBBoxSizeWithChilds();	// calc size of  BBox including childs recursivly
   127 
   128     virtual void select();
   129     virtual void unselect();
   130 	virtual QString getSelectString();
   131 	virtual void setAnimation(const AnimPoint &ap);
   132 	virtual bool animate();
   133 
   134 protected:
   135 	static BranchObj* itLast;		// iterator for first(), next()
   136 	static BranchObj* itFirst;		// first iterator for first(), next()
   137     QList<BranchObj*> branch;		// all child branches
   138 	QList<FloatImageObj*> floatimage;// child images
   139 	QList<XLinkObj*> xlink;			// xlinks to other branches
   140 
   141 	AnimPoint anim;
   142 
   143 public:	
   144 	float angle;					// used in mainbranch to reorder mainbranches
   145 protected:	
   146     int lastSelectedBranch;			// for going deeper into tree
   147 	bool scrolled;					// true if all childs are scrolled and thus invisible
   148 	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
   149 	bool includeImagesVer;			// include floatimages in bbox vertically
   150 	bool includeImagesHor;			// include floatimages in bbox horizontally
   151 
   152 };
   153 
   154 
   155 #endif
   156