branchobj.h
author jhilmer
Mon Aug 01 19:33:16 2005 +0000 (2005-08-01)
changeset 144 f4bbdc809fec
parent 100 f79a53ee8cf6
child 146 1b52ff19aad5
permissions -rw-r--r--
Fix: closing of editor when text are modified
     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 int getDefHeadingSize();
    62     virtual void setHeading (QString);
    63     virtual void setURL (QString);
    64     virtual QString getURL ();
    65     virtual void setVymLink (QString);
    66     virtual QString getVymLink ();
    67 	virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data recursivly to tempdir
    68 	virtual void addXLink (XLinkObj*);
    69 	virtual void removeXLinkRef (XLinkObj*);	// Remove ref in list
    70 	virtual void deleteXLink (XLinkObj*);		// remove references and delete XLinkObj 
    71 	virtual void deleteXLinkAt (int);		// remove references and delete XLinkObj 
    72 	virtual XLinkObj* XLinkAt (int);		// return reference of XLinkObj 
    73 	virtual int countXLink ();
    74 	virtual BranchObj* XLinkTargetAt (int);
    75 	virtual LinkableMapObj* addFloatImage();
    76 	virtual LinkableMapObj* addFloatImage(FloatImageObj*);
    77 	virtual void removeFloatImage(FloatImageObj*);
    78     virtual FloatImageObj* getFirstFloatImage();
    79     virtual FloatImageObj* getLastFloatImage();
    80 	virtual FloatImageObj* getFloatImageNum(const uint &);
    81 protected:	
    82 	virtual void savePosInAngle();			// write pos in angle for resorting			
    83 public:	
    84     virtual BranchObj* addBranch();
    85     virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
    86     virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
    87     virtual BranchObj* insertBranch(int);
    88     virtual BranchObj* insertBranch(BranchObj*,int);
    89     virtual BranchObj* insertBranchPtr (BranchObj*,int);
    90     virtual void removeBranchHere(BranchObj*);  
    91     virtual void removeChilds();  
    92     virtual void removeBranch(BranchObj*);  
    93     virtual void removeBranchPtr (BranchObj*);  
    94     virtual void setLastSelectedBranch(BranchObj*);
    95     virtual BranchObj* getLastSelectedBranch();
    96     virtual BranchObj* getFirstBranch();
    97     virtual BranchObj* getLastBranch();
    98 	virtual BranchObj* getBranchNum(const uint &);
    99     virtual BranchObj* moveBranchUp(BranchObj*);
   100     virtual BranchObj* moveBranchDown(BranchObj*);
   101     virtual BranchObj* moveBranchTo (BranchObj*, int);
   102     virtual void alignRelativeTo(const QPoint );
   103 	virtual void reposition();
   104 
   105 	virtual QRect getTotalBBox();			// return BBox including childs			
   106 	virtual QRect getBBoxSizeWithChilds();	// return size of BBox including childs  
   107 	virtual void calcBBoxSizeWithChilds();	// calc size of  BBox including childs recursivly
   108 
   109     virtual void select();
   110     virtual void unselect();
   111 	virtual QString getSelectString();
   112 
   113 protected:
   114 	static BranchObj* itLast;		// iterator for first(), next()
   115     BranchObjPtrList branch;		// all child branches
   116 	QPtrList<FloatImageObj> floatimage;	// child images
   117 	QPtrList<XLinkObj> xlink;		// xlinks to other branches
   118 public:	
   119 	float angle;					// used in mainbranch to reorder mainbranches
   120 protected:	
   121     int lastSelectedBranch;			// for going deeper into tree
   122 	bool scrolled;					// true if all childs are scrolled and thus invisible
   123 	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
   124 	QString url;					// url to external doc
   125 	QString vymLink;				// path to another map
   126 };
   127 
   128 
   129 #endif
   130