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