branchobj.h
author insilmaril
Thu, 26 Mar 2009 07:49:17 +0000
changeset 746 ee6b0f3a4c2f
parent 738 716a777c1c98
child 748 edb78a44240b
permissions -rw-r--r--
Notes work again (to some degree)
     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 children 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 	virtual void positionContents();
    56     virtual void move (double x,double y);
    57     virtual void move (QPointF);
    58     virtual void moveBy (double x,double y);
    59     virtual void moveBy (QPointF);
    60     virtual void positionBBox();
    61     virtual void calcBBoxSize();
    62 	virtual void setDockPos();
    63     virtual LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
    64     virtual LinkableMapObj* findID (QString sid);	// find Obj by ID string
    65     virtual void setHeading (QString);
    66 
    67 	virtual void setHideTmp (HideTmpMode);
    68 	virtual bool hasHiddenExportParent ();
    69 
    70 	virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data recursivly to tempdir
    71 	virtual void addXLink (XLinkObj*);
    72 	virtual void removeXLinkRef (XLinkObj*);// Remove ref in list
    73 	virtual void deleteXLink (XLinkObj*);	// remove references and delete XLinkObj 
    74 	virtual void deleteXLinkAt (int);		// remove references and delete XLinkObj 
    75 	virtual XLinkObj* XLinkAt (int);		// return reference of XLinkObj 
    76 	virtual int countXLink ();
    77 	virtual BranchObj* XLinkTargetAt (int);
    78 	void setIncludeImagesVer(bool);
    79 	bool getIncludeImagesVer();
    80 	void setIncludeImagesHor(bool);
    81 	bool getIncludeImagesHor();
    82 	QString getIncludeImageAttr();
    83 	virtual FloatImageObj* addFloatImage();
    84 	virtual FloatImageObj* addFloatImage(FloatImageObj*);
    85 	virtual void removeFloatImage(FloatImageObj*);
    86     virtual FloatImageObj* getFirstFloatImage();
    87     virtual FloatImageObj* getLastFloatImage();
    88 	virtual FloatImageObj* getFloatImageNum(const uint &);
    89 protected:	
    90 	virtual void savePosInAngle();					// write pos in angle for resorting			
    91 	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
    92 public:	
    93     virtual BranchObj* addBranch();
    94     virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
    95     virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
    96     virtual BranchObj* insertBranch(int);
    97     virtual BranchObj* insertBranch(BranchObj*,int);
    98     virtual BranchObj* insertBranchPtr (BranchObj*,int);
    99     virtual void removeBranchHere(BranchObj*);  
   100     virtual void removeChildren();  
   101     virtual void removeBranch(BranchObj*);  
   102     virtual void removeBranchPtr (BranchObj*);  
   103     virtual BranchObj* getFirstBranch();
   104     virtual BranchObj* getLastBranch();
   105 	virtual BranchObj* getBranchNum(int);
   106     virtual bool canMoveBranchUp();
   107     virtual BranchObj* moveBranchUp(BranchObj*);
   108     virtual bool canMoveBranchDown();
   109     virtual BranchObj* moveBranchDown(BranchObj*);
   110     virtual void sortChildren();
   111     virtual BranchObj* linkTo (BranchObj*, int);
   112     virtual void alignRelativeTo(const QPointF, bool alignSelf=false );
   113 	virtual void reposition();
   114 	virtual void unsetAllRepositionRequests();
   115 
   116 	virtual QPolygonF shape();				//!< Returns arbitrary bounding polygon
   117 	virtual QRectF getTotalBBox();			// return BBox including children			
   118 	virtual QRectF getBBoxSizeWithChildren();	// return size of BBox including children  
   119 	virtual void calcBBoxSizeWithChildren();	// calc size of  BBox including children recursivly
   120 
   121     virtual void select();
   122     virtual void unselect();
   123 	virtual QString getSelectString();
   124 	virtual void setAnimation(const AnimPoint &ap);
   125 	virtual bool animate();
   126 
   127 protected:
   128 	static BranchObj* itLast;		// iterator for first(), next()
   129 	static BranchObj* itFirst;		// first iterator for first(), next()
   130     QList<BranchObj*> branch;		// all child branches
   131 	QList<FloatImageObj*> floatimage;// child images
   132 	QList<XLinkObj*> xlink;			// xlinks to other branches
   133 
   134 	AnimPoint anim;
   135 
   136 public:	
   137 	float angle;					// used in mainbranch to reorder mainbranches
   138 protected:	
   139 	bool scrolled;					// true if all children are scrolled and thus invisible
   140 	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
   141 	bool includeImagesVer;			// include floatimages in bbox vertically
   142 	bool includeImagesHor;			// include floatimages in bbox horizontally
   143 
   144 };
   145 
   146 
   147 #endif
   148