branchobj.h
author insilmaril
Mon May 15 07:34:54 2006 +0000 (2006-05-15)
changeset 330 d39c67b49cbd
parent 254 d3080e02b13a
child 334 df4fdaa07527
permissions -rw-r--r--
removed wiki style
     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 class BranchObjPtrList : public QPtrList<BranchObj>
    10 {
    11 	virtual int compareItems (QPtrCollection::Item i, QPtrCollection::Item j);
    12 };
    13 
    14 enum BranchModification {NewBranch, MovedBranch};
    15 enum HideTmpMode {HideNone, HideExport};
    16 
    17 /////////////////////////////////////////////////////////////////////////////
    18 class BranchObj:public OrnamentedObj {
    19 public:
    20     BranchObj ();
    21     BranchObj (QCanvas*);
    22     BranchObj (QCanvas*, LinkableMapObj* parent);
    23     ~BranchObj ();
    24 	bool operator< ( const BranchObj & );
    25 	bool operator== ( const BranchObj & );
    26     virtual void init ();
    27     virtual void copy (BranchObj*);
    28     void clear();
    29 	virtual int getNum();				// return number of this in parent
    30 	virtual int getNum(BranchObj*);		// return number of this in parent
    31 	virtual int getFloatImageNum(FloatImageObj*);		
    32 	virtual int countBranches();		
    33 	virtual int countFloatImages();		
    34 	virtual int countXLinks();		
    35     virtual void setParObjTmp (LinkableMapObj*,QPoint,int);// Only for moving Obj around
    36 	virtual void unsetParObjTmp();			// reuse original ParObj
    37 
    38 	virtual void unScroll();				
    39 	virtual void toggleScroll();			// scroll or unscroll
    40 	virtual bool isScrolled();				// returns scroll state
    41 	virtual bool hasScrolledParent(BranchObj*);	// true, if any of the parents is scrolled
    42 	virtual void tmpUnscroll();				// unscroll scrolled parents temporary e.g. during "find" process
    43 	virtual void resetTmpUnscroll();		// scroll all tmp scrolled parents again e.g. when unselecting
    44 
    45 	virtual void setVisibility(bool,int);	// set visibility
    46     virtual void setVisibility(bool);	    // set vis. for w
    47 	virtual void setLinkColor();			// set the color of link
    48 	virtual void setColorChilds(QColor);			// set the color of heading
    49 
    50 	BranchObj* first ();				// set Iterator to first LMO
    51 	BranchObj* next ();					// find next LMO after given one
    52 	BranchObj* getLastIterator();		// to interrupt and resume next iteration
    53 	void setLastIterator (BranchObj*);	// needed by next() 
    54 
    55     virtual void move (double x,double y);
    56     virtual void move (QPoint);
    57     virtual void moveBy (double x,double y);
    58     virtual void moveBy (QPoint);
    59     virtual void positionBBox();
    60     virtual void calcBBoxSize();
    61 	virtual void setDockPos();
    62     virtual LinkableMapObj* findMapObj(QPoint,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 QPoint&);// 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 LinkableMapObj* addFloatImage();
    82 	virtual LinkableMapObj* 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(const uint &);
   106     virtual bool canMoveBranchUp();
   107     virtual BranchObj* moveBranchUp(BranchObj*);
   108     virtual bool canMoveBranchDown();
   109     virtual BranchObj* moveBranchDown(BranchObj*);
   110     virtual BranchObj* moveBranchTo (BranchObj*, int);
   111     virtual void alignRelativeTo(const QPoint );
   112 	virtual void reposition();
   113 
   114 	virtual QRect getTotalBBox();			// return BBox including childs			
   115 	virtual QRect 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     BranchObjPtrList branch;		// all child branches
   125 	QPtrList<FloatImageObj> floatimage;	// child images
   126 	QPtrList<XLinkObj> xlink;		// xlinks to other branches
   127 public:	
   128 	float angle;					// used in mainbranch to reorder mainbranches
   129 protected:	
   130     int lastSelectedBranch;			// for going deeper into tree
   131 	bool scrolled;					// true if all childs are scrolled and thus invisible
   132 	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
   133 	bool includeImagesVer;			// include floatimages in bbox vertically
   134 	bool includeImagesHor;			// include floatimages in bbox horizontally
   135 
   136 };
   137 
   138 
   139 #endif
   140