treeitem.h
author insilmaril
Mon, 18 May 2009 09:41:31 +0000
changeset 770 57ce1ba6d1cb
parent 768 382a444f5b0c
child 772 e3f722759c7e
permissions -rw-r--r--
Fixed Standard Flags finally
     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 	virtual QString saveToDir (const QString &tmpdir=QString(),const
    29 	QString &prefix=QString(), const QPointF& offset=QPointF());
    30 
    31 
    32 	// General housekeeping
    33 	virtual void setModel (VymModel *m);
    34 	virtual VymModel* getModel();
    35 
    36     virtual void appendChild (TreeItem *child);
    37 	virtual void removeChild (int row);
    38 
    39     virtual TreeItem *child(int row);
    40     virtual int childCount() const;
    41     virtual int childNumber() const;
    42     virtual int columnCount() const;
    43 	virtual int branchCount() const;
    44 	virtual int imageCount() const;
    45 	virtual int xlinkCount() const;
    46 
    47     virtual int row() const;
    48 	virtual int column() const;
    49 	virtual int depth() ;
    50     virtual TreeItem *parent();
    51 
    52 	/*! Return number of item in parent by type, 
    53 	    e.g. first branch has number 0           */
    54 	virtual int childNum();				//! Return number of item in list of all children
    55 	virtual int num();					//! Return number of item by type
    56 	virtual int num (TreeItem *item);	//! Return number of item by type
    57 
    58 protected:
    59 	Type type;
    60 public:	
    61 	virtual void setType (const Type t);
    62 	virtual Type getType ();
    63 	virtual bool isBranchLikeType() const;
    64 	virtual QString getTypeName ();
    65 
    66 // Accessing data
    67     virtual QVariant data(int column) const;
    68 
    69 
    70 protected:
    71 	QColor headingColor;
    72 public:	
    73 	virtual void setHeading (const QString s);
    74 	virtual QString getHeading() const;
    75 	virtual std::string getHeadingStd() const;	//! convenience function used for debugging
    76 	virtual void setHeadingColor(QColor color);	//! Set color of heading. In BranchItem overloaded to update QGraphicsView
    77 	virtual QColor getHeadingColor();			//! Returns color of heading
    78 
    79 
    80 protected:
    81 	QString url;
    82 public:
    83 	void setURL (const QString &url);			//! Set URL
    84 	QString getURL ();							//! Get URL
    85 
    86 
    87 protected:
    88 	QString vymLink;
    89 public:
    90 	void setVymLink (const QString &url);			//! Set URL
    91 	QString getVymLink ();							//! Get URL
    92 
    93 
    94 protected:
    95 	NoteObj note;
    96 public:	
    97 	virtual void setNote(const QString &s);
    98 	virtual void clearNote();
    99 	virtual QString getNote();
   100 	virtual bool hasEmptyNote();
   101 	virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true);
   102 	virtual NoteObj getNoteObj();			
   103 	virtual QString getNoteASCII(const QString &indent, const int &width); // returns note	(ASCII)
   104     virtual QString getNoteASCII();			// returns note	(ASCII)
   105     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
   106 
   107 
   108 protected:
   109 	FlagRow standardFlags;
   110 	FlagRow systemFlags;
   111 public:	
   112 	virtual void activateStandardFlag(const QString &flag);
   113 	virtual void deactivateStandardFlag(const QString &flag);
   114 	virtual void deactivateAllStandardFlags();
   115 
   116 	/*! \brief Toggle a Flag 
   117 	    If master is not NULL,, only one Flag from FlagRow master may 
   118 		be active simultanously, the others get deactivated.
   119 	*/	
   120 	virtual void toggleStandardFlag(const QString &flag, FlagRow *master=NULL);
   121 	virtual bool isActiveStandardFlag (const QString &flag);
   122 	virtual QStringList activeStandardFlagNames();
   123 	virtual FlagRow* getStandardFlagRow ();
   124 	//virtual void updateToolBar();
   125 
   126 	virtual QStringList activeSystemFlagNames();
   127 
   128 
   129 	virtual bool canMoveDown();
   130 	virtual bool canMoveUp();
   131 
   132 protected:
   133 	QString objID;					//! id set during load/save currently used for xLinks
   134 public:
   135 	virtual void setID (const QString &s);
   136 	virtual QString getID ();
   137 
   138 	// Navigation and selection
   139 	virtual TreeItem* getChildNum(const int &n);
   140 	virtual BranchItem* getFirstBranch();
   141 	virtual BranchItem* getLastBranch();
   142 
   143 	/*! Get next branch after current branch. Return NULL if there is no
   144 	    next branch */
   145 	virtual BranchItem* getNextBranch(BranchItem* currentBranch);
   146 
   147 	virtual BranchItem* getBranchNum(const int &n);
   148 	virtual BranchObj* getBranchObjNum(const int &n);
   149 	virtual void setLastSelectedBranch();		//! Set myself as last selected in parent
   150 	virtual void setLastSelectedBranch(int i);	//! Set last selected branch directly
   151 	virtual TreeItem* getLastSelectedBranch();
   152 
   153 protected:
   154 	bool hideExport;							//! Hide this item in export
   155 public:
   156 	virtual void setHideTmp (HideTmpMode);
   157 	virtual bool hasHiddenExportParent ();
   158 	virtual void setHideInExport(bool);		// set export of object (and children)
   159 	virtual bool hideInExport();
   160 	virtual bool isHidden ();		
   161 
   162 	
   163 protected:
   164 	VymModel *model;
   165 
   166     QList<TreeItem*> childItems;
   167     QList<QVariant> itemData;
   168     TreeItem *parentItem;
   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