treeitem.h
author insilmaril
Fri Oct 02 13:24:55 2009 +0000 (2009-10-02)
changeset 802 f076fdec767d
parent 794 d922fb6ea482
child 822 c2ce9944148c
permissions -rw-r--r--
More fixes for using proxy
     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 "noteobj.h"
    10 #include "xmlobj.h"
    11 
    12 class AttributeItem;
    13 class BranchObj;
    14 class BranchItem;
    15 class FloatImageObj;
    16 class ImageItem;
    17 class LinkableMapObj;
    18 class VymModel;
    19 class XLinkItem;
    20 class XLinkObj;
    21 
    22 class TreeItem:public XMLObj
    23 {
    24 public:
    25 	enum Type {Undefined,MapCenter,Branch,Image,Attribute,XLink};
    26 	enum HideTmpMode {HideNone, HideExport};
    27 
    28     TreeItem();
    29     TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
    30     virtual ~TreeItem();
    31 	void init();
    32 
    33 	// General housekeeping
    34 	virtual void setModel (VymModel *m);
    35 	virtual VymModel* getModel();
    36 
    37 
    38 	/*! Return number of item, as it would be after it would have been appended.
    39 	    This is used to notify view about layout changes before model is modified. */
    40 	virtual int getRowNumAppend (TreeItem *child);
    41 
    42     virtual void appendChild (TreeItem *child);
    43 	virtual void removeChild (int row);
    44 
    45     virtual TreeItem *child(int row);
    46     virtual int childCount() const;
    47     virtual int childNumber() const;
    48     virtual int columnCount() const;
    49 	virtual int branchCount() const;
    50 	virtual int imageCount() const;
    51 	virtual int xlinkCount() const;
    52 	virtual int attributeCount() const;
    53 
    54     virtual int row() const;
    55 	virtual int depth() ;
    56     virtual TreeItem *parent();
    57 
    58 	/*! Return number of item in parent by type, 
    59 	    e.g. first branch has number 0           */
    60 	virtual int childNum();				//! Return number of item in list of all children
    61 	virtual int num();					//! Return number of item by type
    62 	virtual int num (TreeItem *item);	//! Return number of item by type
    63 
    64 protected:
    65 	Type type;
    66 public:	
    67 	virtual void setType (const Type t);
    68 	virtual Type getType ();
    69 	virtual bool isBranchLikeType() const;
    70 	virtual QString getTypeName ();
    71 
    72 // Accessing data
    73     virtual QVariant data(int column) const;
    74 
    75 
    76 protected:
    77 	QColor headingColor;
    78 public:	
    79 	virtual void setHeading (const QString s);
    80 	virtual QString getHeading() const;
    81 	virtual std::string getHeadingStd() const;	//! convenience function used for debugging
    82 	virtual void setHeadingColor(QColor color);	//! Set color of heading. In BranchItem overloaded to update QGraphicsView
    83 	virtual QColor getHeadingColor();			//! Returns color of heading
    84 
    85 
    86 protected:
    87 	QString url;
    88 public:
    89 	void setURL (const QString &url);			//! Set URL
    90 	QString getURL ();							//! Get URL
    91 
    92 
    93 protected:
    94 	QString vymLink;
    95 public:
    96 	void setVymLink (const QString &url);			//! Set URL
    97 	QString getVymLink ();							//! Get URL
    98 
    99 
   100 protected:
   101 	NoteObj note;
   102 public:	
   103 	virtual void setNote(const QString &s);
   104 	virtual void clearNote();
   105 	virtual QString getNote();
   106 	virtual bool hasEmptyNote();
   107 	virtual void setNoteObj(const NoteObj &); //FIXME-3 setNoteObj is called for every select or so???
   108 
   109 	virtual NoteObj getNoteObj();			
   110 	virtual QString getNoteASCII(const QString &indent, const int &width); // returns note	(ASCII)
   111     virtual QString getNoteASCII();			// returns note	(ASCII)
   112     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
   113 
   114 
   115 protected:
   116 	FlagRow standardFlags;
   117 	FlagRow systemFlags;
   118 public:	
   119 	virtual void activateStandardFlag(const QString &flag);
   120 	virtual void deactivateStandardFlag(const QString &flag);
   121 	virtual void deactivateAllStandardFlags();
   122 
   123 	/*! \brief Toggle a Flag 
   124 	    If master is not NULL,, only one Flag from FlagRow master may 
   125 		be active simultanously, the others get deactivated.
   126 	*/	
   127 	virtual void toggleStandardFlag(const QString &flag, FlagRow *master=NULL);
   128 	virtual bool isActiveStandardFlag (const QString &flag);
   129 	virtual QStringList activeStandardFlagNames();
   130 	virtual FlagRow* getStandardFlagRow ();
   131 
   132 	virtual QStringList activeSystemFlagNames();
   133 
   134 	virtual bool canMoveDown();
   135 	virtual bool canMoveUp();
   136 
   137 protected:
   138 	QString objID;					//! id set during load/save currently used for xLinks
   139 public:
   140 	virtual void setID (const QString &s);
   141 	virtual QString getID ();
   142 
   143 	// Navigation and selection
   144 	virtual TreeItem* getChildNum(const int &n);
   145 	virtual BranchItem* getFirstBranch();
   146 	virtual BranchItem* getLastBranch();
   147 
   148 	/*! Get next branch after current branch. Return NULL if there is no
   149 	    next branch */
   150 	virtual BranchItem* getNextBranch(BranchItem* currentBranch);
   151 
   152 	virtual BranchItem* getBranchNum(const int &n);
   153 	virtual BranchObj* getBranchObjNum(const int &n);
   154 
   155 	virtual ImageItem* getImageNum(const int &n);
   156 	virtual FloatImageObj* getImageObjNum(const int &n);
   157 
   158 	virtual AttributeItem* getAttributeNum(const int &n);
   159 
   160 	virtual XLinkItem* getXLinkNum(const int &n);
   161 	virtual XLinkObj* getXLinkObjNum(const int &n);
   162 
   163 protected:
   164 	bool hideExport;						//! Hide this item in export
   165 	bool hidden;							//! Hidden in export if true
   166 public:
   167 	virtual void setHideTmp (HideTmpMode);
   168 	virtual bool hasHiddenExportParent ();
   169 	virtual void setHideInExport(bool);		// set export of object (and children)
   170 	virtual bool hideInExport();
   171 	virtual bool isHidden ();		
   172 	virtual void updateVisibility();		//! Sets visibility in LinkableMapObj, if existing
   173 
   174 	virtual QString getGeneralAttr();
   175 	
   176 protected:
   177 	VymModel *model;
   178 
   179     QList<TreeItem*> childItems;
   180     QList<QVariant> itemData;
   181     TreeItem *parentItem;
   182 
   183 	/*!  Set rootItem (does not change, needed for quick check 
   184 	     if some branch is mapCenter */
   185 	TreeItem *rootItem;
   186  
   187 	int branchOffset;
   188 	int branchCounter;
   189 	int imageOffset;
   190 	int imageCounter;
   191 
   192 	int attributeOffset;
   193 	int attributeCounter;
   194 
   195 	int xlinkOffset;
   196 	int xlinkCounter;
   197 
   198 };
   199 
   200 #endif