branchobj.h
author insilmaril
Wed, 01 Apr 2009 15:06:57 +0000
changeset 749 9ff332964015
parent 748 edb78a44240b
child 750 ff3b01ce0960
permissions -rw-r--r--
moved scroll functions from BranchObj to BranchItem
     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 
    35     virtual void setParObjTmp (LinkableMapObj*,QPointF,int);// Only for moving Obj around
    36 	virtual void unsetParObjTmp();			// reuse original ParObj
    37 
    38 	virtual void setVisibility(bool,int);	// set visibility
    39     virtual void setVisibility(bool);	    // set vis. for w
    40 	virtual void setLinkColor();			// set the color of link
    41 	virtual void setColorSubtree(QColor);	// set the color of heading
    42 
    43 	virtual void positionContents();
    44     virtual void move (double x,double y);
    45     virtual void move (QPointF);
    46     virtual void moveBy (double x,double y);
    47     virtual void moveBy (QPointF);
    48     virtual void positionBBox();
    49     virtual void calcBBoxSize();
    50 	virtual void setDockPos();
    51     virtual LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
    52     virtual LinkableMapObj* findID (QString sid);	// find Obj by ID string
    53     virtual void setHeading (QString);
    54 
    55 	virtual void setHideTmp (HideTmpMode);
    56 	virtual bool hasHiddenExportParent ();
    57 
    58 	virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data recursivly to tempdir
    59 
    60 	virtual void addXLink (XLinkObj*);
    61 	virtual void removeXLinkRef (XLinkObj*);// Remove ref in list
    62 	virtual void deleteXLink (XLinkObj*);	// remove references and delete XLinkObj 
    63 	virtual void deleteXLinkAt (int);		// remove references and delete XLinkObj 
    64 	virtual XLinkObj* XLinkAt (int);		// return reference of XLinkObj 
    65 	virtual BranchObj* XLinkTargetAt (int);
    66 
    67 	void setIncludeImagesVer(bool);
    68 	bool getIncludeImagesVer();
    69 	void setIncludeImagesHor(bool);
    70 	bool getIncludeImagesHor();
    71 	QString getIncludeImageAttr();
    72 
    73 	virtual FloatImageObj* addFloatImage();
    74 	virtual FloatImageObj* addFloatImage(FloatImageObj*);
    75 	virtual void removeFloatImage(FloatImageObj*);
    76     virtual FloatImageObj* getFirstFloatImage();
    77     virtual FloatImageObj* getLastFloatImage();
    78 	virtual FloatImageObj* getFloatImageNum(const uint &);
    79 protected:	
    80 	virtual void savePosInAngle();					// write pos in angle for resorting			
    81 	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
    82 public:	
    83     virtual BranchObj* addBranch();
    84     virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
    85     virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
    86     virtual BranchObj* insertBranch(int);
    87     virtual BranchObj* insertBranch(BranchObj*,int);
    88     virtual BranchObj* insertBranchPtr (BranchObj*,int);
    89     virtual void removeBranchHere(BranchObj*);  
    90     virtual void removeChildren();  
    91     virtual void removeBranch(BranchObj*);  
    92     virtual void removeBranchPtr (BranchObj*);  
    93 
    94     virtual BranchObj* getFirstBranch();
    95     virtual BranchObj* getLastBranch();
    96 	virtual BranchObj* getBranchNum(int);
    97 
    98     virtual bool canMoveBranchUp();
    99     virtual BranchObj* moveBranchUp(BranchObj*);
   100     virtual bool canMoveBranchDown();
   101     virtual BranchObj* moveBranchDown(BranchObj*);
   102 
   103     virtual void sortChildren();
   104     virtual BranchObj* linkTo (BranchObj*, int);
   105     virtual void alignRelativeTo(const QPointF, bool alignSelf=false );
   106 	virtual void reposition();
   107 	virtual void unsetAllRepositionRequests();
   108 
   109 	virtual QPolygonF shape();				//!< Returns arbitrary bounding polygon
   110 	virtual QRectF getTotalBBox();			// return BBox including children			
   111 	virtual QRectF getBBoxSizeWithChildren();	// return size of BBox including children  
   112 	virtual void calcBBoxSizeWithChildren();	// calc size of  BBox including children recursivly
   113 
   114 	virtual QString getSelectString();
   115 	virtual void setAnimation(const AnimPoint &ap);
   116 	virtual bool animate();
   117 
   118 protected:
   119 	static BranchObj* itLast;		// iterator for first(), next()
   120 	static BranchObj* itFirst;		// first iterator for first(), next()
   121     QList<BranchObj*> branch;		// all child branches
   122 	QList<FloatImageObj*> floatimage;// child images
   123 	QList<XLinkObj*> xlink;			// xlinks to other branches
   124 
   125 	AnimPoint anim;
   126 
   127 public:	
   128 	float angle;					// used in mainbranch to reorder mainbranches
   129 protected:	
   130 //	bool scrolled;					// true if all children are scrolled and thus invisible
   131 //	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
   132 	bool includeImagesVer;			// include floatimages in bbox vertically
   133 	bool includeImagesHor;			// include floatimages in bbox horizontally
   134 };
   135 
   136 
   137 #endif
   138