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