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