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