branchobj.h
author insilmaril
Fri Dec 08 20:18:58 2006 +0000 (2006-12-08)
changeset 410 ceb4532eae34
parent 406 1c8ff1928b97
child 411 910ba9fab728
permissions -rw-r--r--
1.6.1 Port to QGraphics
     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 enum BranchModification {NewBranch, MovedBranch};
    11 enum HideTmpMode {HideNone, HideExport};
    12 
    13 /////////////////////////////////////////////////////////////////////////////
    14 class BranchObj:public OrnamentedObj {
    15 public:
    16     BranchObj ();
    17     BranchObj (QGraphicsScene*);
    18     BranchObj (QGraphicsScene*, LinkableMapObj* parent);
    19     ~BranchObj ();
    20 	bool operator< ( const BranchObj & );
    21 	bool operator== ( const BranchObj & );
    22     virtual void init ();
    23     virtual void copy (BranchObj*);
    24     void clear();
    25 	virtual int getNum();				// return number of this in parent
    26 	virtual int getNum(BranchObj*);		// return number of this in parent
    27 	virtual int getFloatImageNum(FloatImageObj*);		
    28 	virtual int countBranches();		
    29 	virtual int countFloatImages();		
    30 	virtual int countXLinks();		
    31     virtual void setParObjTmp (LinkableMapObj*,QPointF,int);// Only for moving Obj around
    32 	virtual void unsetParObjTmp();			// reuse original ParObj
    33 
    34 	virtual void unScroll();				
    35 	virtual void toggleScroll();			// scroll or unscroll
    36 	virtual bool isScrolled();				// returns scroll state
    37 	virtual bool hasScrolledParent(BranchObj*);	// true, if any of the parents is scrolled
    38 	virtual void tmpUnscroll();				// unscroll scrolled parents temporary e.g. during "find" process
    39 	virtual void resetTmpUnscroll();		// scroll all tmp scrolled parents again e.g. when unselecting
    40 
    41 	virtual void setVisibility(bool,int);	// set visibility
    42     virtual void setVisibility(bool);	    // set vis. for w
    43 	virtual void setLinkColor();			// set the color of link
    44 	virtual void setColorChilds(QColor);			// set the color of heading
    45 
    46 	BranchObj* first ();				// set Iterator to first LMO
    47 	BranchObj* next ();					// find next LMO after given one
    48 	BranchObj* getLastIterator();		// to interrupt and resume next iteration
    49 	void setLastIterator (BranchObj*);	// needed by next() 
    50 
    51 	virtual void positionContents();
    52     virtual void move (double x,double y);
    53     virtual void move (QPointF);
    54     virtual void moveBy (double x,double y);
    55     virtual void moveBy (QPointF);
    56     virtual void positionBBox();
    57     virtual void calcBBoxSize();
    58 	virtual void setDockPos();
    59     virtual LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
    60     virtual void setHeading (QString);
    61 
    62 	virtual void setHideTmp (HideTmpMode);
    63 	virtual bool hasHiddenExportParent (BranchObj*);
    64 
    65 	virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data recursivly to tempdir
    66 	virtual void addXLink (XLinkObj*);
    67 	virtual void removeXLinkRef (XLinkObj*);// Remove ref in list
    68 	virtual void deleteXLink (XLinkObj*);	// remove references and delete XLinkObj 
    69 	virtual void deleteXLinkAt (int);		// remove references and delete XLinkObj 
    70 	virtual XLinkObj* XLinkAt (int);		// return reference of XLinkObj 
    71 	virtual int countXLink ();
    72 	virtual BranchObj* XLinkTargetAt (int);
    73 	void setIncludeImagesVer(bool);
    74 	bool getIncludeImagesVer();
    75 	void setIncludeImagesHor(bool);
    76 	bool getIncludeImagesHor();
    77 	QString getIncludeImageAttr();
    78 	virtual FloatImageObj* addFloatImage();
    79 	virtual FloatImageObj* addFloatImage(FloatImageObj*);
    80 	virtual void removeFloatImage(FloatImageObj*);
    81     virtual FloatImageObj* getFirstFloatImage();
    82     virtual FloatImageObj* getLastFloatImage();
    83 	virtual FloatImageObj* getFloatImageNum(const uint &);
    84 protected:	
    85 	virtual void savePosInAngle();					// write pos in angle for resorting			
    86 	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
    87 public:	
    88     virtual BranchObj* addBranch();
    89     virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
    90     virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
    91     virtual BranchObj* insertBranch(int);
    92     virtual BranchObj* insertBranch(BranchObj*,int);
    93     virtual BranchObj* insertBranchPtr (BranchObj*,int);
    94     virtual void removeBranchHere(BranchObj*);  
    95     virtual void removeChilds();  
    96     virtual void removeBranch(BranchObj*);  
    97     virtual void removeBranchPtr (BranchObj*);  
    98     virtual void setLastSelectedBranch(BranchObj*);
    99     virtual BranchObj* getLastSelectedBranch();
   100     virtual BranchObj* getFirstBranch();
   101     virtual BranchObj* getLastBranch();
   102 	virtual BranchObj* getBranchNum(int);
   103     virtual bool canMoveBranchUp();
   104     virtual BranchObj* moveBranchUp(BranchObj*);
   105     virtual bool canMoveBranchDown();
   106     virtual BranchObj* moveBranchDown(BranchObj*);
   107     virtual BranchObj* moveBranchTo (BranchObj*, int);
   108     virtual void alignRelativeTo(const QPointF );
   109 	virtual void reposition();
   110 	virtual void unsetAllRepositionRequests();
   111 
   112 	virtual QRectF getTotalBBox();			// return BBox including childs			
   113 	virtual QRectF getBBoxSizeWithChilds();	// return size of BBox including childs  
   114 	virtual void calcBBoxSizeWithChilds();	// calc size of  BBox including childs recursivly
   115 
   116     virtual void select();
   117     virtual void unselect();
   118 	virtual QString getSelectString();
   119 
   120 protected:
   121 	static BranchObj* itLast;		// iterator for first(), next()
   122 	static BranchObj* itFirst;		// first iterator for first(), next()
   123     QList<BranchObj*> branch;		// all child branches
   124 	QList<FloatImageObj*> floatimage;// child images
   125 	QList<XLinkObj*> xlink;			// xlinks to other branches
   126 public:	
   127 	float angle;					// used in mainbranch to reorder mainbranches
   128 protected:	
   129     int lastSelectedBranch;			// for going deeper into tree
   130 	bool scrolled;					// true if all childs 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 
   138 #endif
   139