treeitem.h
author insilmaril
Wed, 03 Jun 2009 20:37:17 +0000
changeset 775 6e4b586aa88a
parent 773 340bc29da9a0
child 776 25e634a7e1dc
permissions -rw-r--r--
Unscrolling temporary works again
     1 #ifndef TREEITEM_H
     2 #define TREEITEM_H
     3 
     4 #include <QColor>
     5 #include <QList>
     6 #include <QVariant>
     7 
     8 #include "flagrow.h"
     9 #include "mapitem.h"
    10 #include "noteobj.h"
    11 #include "xmlobj.h"
    12 
    13 class LinkableMapObj;
    14 class BranchObj;
    15 class BranchItem;
    16 class VymModel;
    17 
    18 class TreeItem:public MapItem
    19 {
    20 public:
    21 	enum Type {Undefined,MapCenter,Branch,Image};
    22 	enum HideTmpMode {HideNone, HideExport};
    23 
    24     TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
    25     ~TreeItem();
    26 	void init();
    27 
    28 	// General housekeeping
    29 	virtual void setModel (VymModel *m);
    30 	virtual VymModel* getModel();
    31 
    32     virtual void appendChild (TreeItem *child);
    33 	virtual void removeChild (int row);
    34 	virtual void removeChildBranches ();
    35 
    36     virtual TreeItem *child(int row);
    37     virtual int childCount() const;
    38     virtual int childNumber() const;
    39     virtual int columnCount() const;
    40 	virtual int branchCount() const;
    41 	virtual int imageCount() const;
    42 	virtual int xlinkCount() const;
    43 
    44     virtual int row() const;
    45 	virtual int column() const;
    46 	virtual int depth() ;
    47     virtual TreeItem *parent();
    48 
    49 	/*! Return number of item in parent by type, 
    50 	    e.g. first branch has number 0           */
    51 	virtual int childNum();				//! Return number of item in list of all children
    52 	virtual int num();					//! Return number of item by type
    53 	virtual int num (TreeItem *item);	//! Return number of item by type
    54 
    55 protected:
    56 	Type type;
    57 public:	
    58 	virtual void setType (const Type t);
    59 	virtual Type getType ();
    60 	virtual bool isBranchLikeType() const;
    61 	virtual QString getTypeName ();
    62 
    63 // Accessing data
    64     virtual QVariant data(int column) const;
    65 
    66 
    67 protected:
    68 	QColor headingColor;
    69 public:	
    70 	virtual void setHeading (const QString s);
    71 	virtual QString getHeading() const;
    72 	virtual std::string getHeadingStd() const;	//! convenience function used for debugging
    73 	virtual void setHeadingColor(QColor color);	//! Set color of heading. In BranchItem overloaded to update QGraphicsView
    74 	virtual QColor getHeadingColor();			//! Returns color of heading
    75 
    76 
    77 protected:
    78 	QString url;
    79 public:
    80 	void setURL (const QString &url);			//! Set URL
    81 	QString getURL ();							//! Get URL
    82 
    83 
    84 protected:
    85 	QString vymLink;
    86 public:
    87 	void setVymLink (const QString &url);			//! Set URL
    88 	QString getVymLink ();							//! Get URL
    89 
    90 
    91 protected:
    92 	NoteObj note;
    93 public:	
    94 	virtual void setNote(const QString &s);
    95 	virtual void clearNote();
    96 	virtual QString getNote();
    97 	virtual bool hasEmptyNote();
    98 	virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true);
    99 	virtual NoteObj getNoteObj();			
   100 	virtual QString getNoteASCII(const QString &indent, const int &width); // returns note	(ASCII)
   101     virtual QString getNoteASCII();			// returns note	(ASCII)
   102     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
   103 
   104 
   105 protected:
   106 	FlagRow standardFlags;
   107 	FlagRow systemFlags;
   108 public:	
   109 	virtual void activateStandardFlag(const QString &flag);
   110 	virtual void deactivateStandardFlag(const QString &flag);
   111 	virtual void deactivateAllStandardFlags();
   112 
   113 	/*! \brief Toggle a Flag 
   114 	    If master is not NULL,, only one Flag from FlagRow master may 
   115 		be active simultanously, the others get deactivated.
   116 	*/	
   117 	virtual void toggleStandardFlag(const QString &flag, FlagRow *master=NULL);
   118 	virtual bool isActiveStandardFlag (const QString &flag);
   119 	virtual QStringList activeStandardFlagNames();
   120 	virtual FlagRow* getStandardFlagRow ();
   121 
   122 	virtual QStringList activeSystemFlagNames();
   123 
   124 
   125 	virtual bool canMoveDown();
   126 	virtual bool canMoveUp();
   127 
   128 protected:
   129 	QString objID;					//! id set during load/save currently used for xLinks
   130 public:
   131 	virtual void setID (const QString &s);
   132 	virtual QString getID ();
   133 
   134 	// Navigation and selection
   135 	virtual TreeItem* getChildNum(const int &n);
   136 	virtual BranchItem* getFirstBranch();
   137 	virtual BranchItem* getLastBranch();
   138 
   139 	/*! Get next branch after current branch. Return NULL if there is no
   140 	    next branch */
   141 	virtual BranchItem* getNextBranch(BranchItem* currentBranch);
   142 
   143 	virtual BranchItem* getBranchNum(const int &n);
   144 	virtual BranchObj* getBranchObjNum(const int &n);
   145 	virtual void setLastSelectedBranch();		//! Set myself as last selected in parent
   146 	virtual void setLastSelectedBranch(int i);	//! Set last selected branch directly
   147 	virtual TreeItem* getLastSelectedBranch();
   148 
   149 protected:
   150 	bool hideExport;							//! Hide this item in export
   151 public:
   152 	virtual void setHideTmp (HideTmpMode);
   153 	virtual bool hasHiddenExportParent ();
   154 	virtual void setHideInExport(bool);		// set export of object (and children)
   155 	virtual bool hideInExport();
   156 	virtual bool isHidden ();		
   157 
   158 	
   159 protected:
   160 	VymModel *model;
   161 
   162     QList<TreeItem*> childItems;
   163     QList<QVariant> itemData;
   164     TreeItem *parentItem;
   165 
   166 	/*!  Set rootItem (does not change, needed for quick check 
   167 	     if some branch is mapCenter */
   168 	TreeItem *rootItem;
   169  
   170 	int branchOffset;
   171 	int branchCounter;
   172 	int lastSelectedBranchNum;
   173 
   174 	int imageOffset;
   175 	int imageCounter;
   176 
   177 	bool hidden;	//! Hidden in export if true
   178 };
   179 
   180 #endif