branchobj.h
author insilmaril
Sat Jul 23 10:26:29 2005 +0000 (2005-07-23)
changeset 132 fd7f08a85971
parent 98 58adc2d2ed08
child 139 087e60400acc
permissions -rw-r--r--
updated api.*
     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 /////////////////////////////////////////////////////////////////////////////
    15 class BranchObj:public OrnamentedObj {
    16 public:
    17     BranchObj ();
    18     BranchObj (QCanvas*);
    19     BranchObj (QCanvas*, LinkableMapObj* parent);
    20     ~BranchObj ();
    21 	bool operator< ( const BranchObj & );
    22 	bool operator== ( const BranchObj & );
    23     virtual void init ();
    24     virtual void copy (BranchObj*);
    25     void clear();
    26 	virtual int getNum();				// return number of this in parent
    27 	virtual int getNum(BranchObj*);		// return number of this in parent
    28 	virtual int getFloatImageNum(FloatImageObj*);		
    29 	virtual int countBranches();		
    30 	virtual int countFloatImages();		
    31 	virtual int countXLinks();		
    32     virtual void setParObjTmp (LinkableMapObj*,QPoint,int);// Only for moving Obj around
    33 	virtual void unsetParObjTmp();			// reuse original ParObj
    34 
    35 	virtual void unScroll();				
    36 	virtual void toggleScroll();			// scroll or unscroll
    37 	virtual bool isScrolled();				// returns scroll state
    38 	virtual bool hasScrolledParent(BranchObj*);	// true, if any of the parents is scrolled
    39 	virtual void tmpUnscroll();				// unscroll scrolled parents temporary e.g. during "find" process
    40 	virtual void resetTmpUnscroll();		// scroll all tmp scrolled parents again e.g. when unselecting
    41 
    42 	virtual void setVisibility(bool,int);	// set visibility
    43     virtual void setVisibility(bool);	    // set vis. for w
    44 	virtual void setLinkColor();			// set the color of link
    45 	virtual void setColor(QColor,bool);		// set the color of heading
    46 	virtual QColor getColor();				// get color of heading
    47 
    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 move (double x,double y);
    55     virtual void move (QPoint);
    56     virtual void moveBy (double x,double y);
    57     virtual void moveBy (QPoint);
    58     virtual void positionBBox();
    59     virtual void calcBBoxSize();
    60     virtual LinkableMapObj* findMapObj(QPoint,LinkableMapObj*);	// find MapObj 
    61     virtual void setHeading (QString);
    62     virtual void setURL (QString);
    63     virtual QString getURL ();
    64     virtual void setVymLink (QString);
    65     virtual QString getVymLink ();
    66 	virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data recursivly to tempdir
    67 	virtual void addXLink (XLinkObj*);
    68 	virtual void removeXLinkRef (XLinkObj*);	// Remove ref in list
    69 	virtual void deleteXLink (XLinkObj*);		// remove references and delete XLinkObj 
    70 	virtual void deleteXLinkAt (int);		// remove references and delete XLinkObj 
    71 	virtual XLinkObj* XLinkAt (int);		// return reference of XLinkObj 
    72 	virtual int countXLink ();
    73 	virtual BranchObj* XLinkTargetAt (int);
    74 	virtual LinkableMapObj* addFloatImage();
    75 	virtual LinkableMapObj* addFloatImage(FloatImageObj*);
    76 	virtual void removeFloatImage(FloatImageObj*);
    77     virtual FloatImageObj* getFirstFloatImage();
    78     virtual FloatImageObj* getLastFloatImage();
    79 	virtual FloatImageObj* getFloatImageNum(const uint &);
    80 protected:	
    81 	virtual void savePosInAngle();			// write pos in angle for resorting			
    82 public:	
    83     virtual BranchObj* addBranch();
    84     virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
    85     virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
    86     virtual BranchObj* insertBranch(int);
    87     virtual BranchObj* insertBranch(BranchObj*,int);
    88     virtual BranchObj* insertBranchPtr (BranchObj*,int);
    89     virtual void removeBranchHere(BranchObj*);  
    90     virtual void removeChilds();  
    91     virtual void removeBranch(BranchObj*);  
    92     virtual void removeBranchPtr (BranchObj*);  
    93     virtual void setLastSelectedBranch(BranchObj*);
    94     virtual BranchObj* getLastSelectedBranch();
    95     virtual BranchObj* getFirstBranch();
    96     virtual BranchObj* getLastBranch();
    97 	virtual BranchObj* getBranchNum(const uint &);
    98     virtual BranchObj* moveBranchUp(BranchObj*);
    99     virtual BranchObj* moveBranchDown(BranchObj*);
   100     virtual BranchObj* moveBranchTo (BranchObj*, int);
   101     virtual void alignRelativeTo(const QPoint );
   102 	virtual void reposition();
   103 
   104 	virtual QRect getTotalBBox();			// return BBox including childs			
   105 	virtual QRect getBBoxSizeWithChilds();	// return size of BBox including childs  
   106 	virtual void calcBBoxSizeWithChilds();	// calc size of  BBox including childs recursivly
   107 
   108     virtual void select();
   109     virtual void unselect();
   110 	virtual QString getSelectString();
   111 
   112 protected:
   113 	static BranchObj* itLast;		// iterator for first(), next()
   114     BranchObjPtrList branch;		// all child branches
   115 	QPtrList<FloatImageObj> floatimage;	// child images
   116 	QPtrList<XLinkObj> xlink;		// xlinks to other branches
   117 public:	
   118 	float angle;					// used in mainbranch to reorder mainbranches
   119 protected:	
   120     int lastSelectedBranch;			// for going deeper into tree
   121 	bool scrolled;					// true if all childs are scrolled and thus invisible
   122 	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
   123 	QString url;					// url to external doc
   124 	QString vymLink;				// path to another map
   125 };
   126 
   127 
   128 #endif
   129