treeitem.h
author insilmaril
Thu, 07 May 2009 08:48:53 +0000
changeset 766 7a71a914afdb
parent 763 8c028a5d9083
child 767 6d2b32f305f9
permissions -rw-r--r--
Started to reanimate flags
     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,const QString &prefix, const QPointF& offset);
    29 
    30 
    31 	// General housekeeping
    32 	virtual void setModel (VymModel *m);
    33 	virtual VymModel* getModel();
    34 
    35     virtual void appendChild (TreeItem *child);
    36 	virtual void removeChild (int row);
    37 
    38     virtual TreeItem *child(int row);
    39     virtual int childCount() const;
    40     virtual int childNumber() const;
    41     virtual int columnCount() const;
    42 	virtual int branchCount() const;
    43 	virtual int imageCount() const;
    44 	virtual int xlinkCount() const;
    45 
    46     virtual int row() const;
    47 	virtual int column() const;
    48 	virtual int depth() ;
    49     virtual TreeItem *parent();
    50 
    51 	/*! Return number of item in parent by type, 
    52 	    e.g. first branch has number 0           */
    53 	virtual int childNum();				//! Return number of item in list of all children
    54 	virtual int num();					//! Return number of item by type
    55 	virtual int num (TreeItem *item);	//! Return number of item by type
    56 
    57 protected:
    58 	Type type;
    59 public:	
    60 	virtual void setType (const Type t);
    61 	virtual Type getType ();
    62 	virtual bool isBranchLikeType() const;
    63 	virtual QString getTypeName ();
    64 
    65 // Accessing data
    66     virtual QVariant data(int column) const;
    67 
    68 protected:
    69 	QColor headingColor;
    70 public:	
    71 	virtual void setHeading (const QString s);
    72 	virtual QString getHeading() const;
    73 	virtual std::string getHeadingStd() const;	//! convenience function used for debugging
    74 	virtual void setHeadingColor(QColor color);	//! Set color of heading. In BranchItem overloaded to update QGraphicsView
    75 	virtual QColor getHeadingColor();			//! Returns color of heading
    76 
    77 protected:
    78 	NoteObj note;
    79 public:	
    80 	virtual void setNote(const QString s);
    81 	virtual QString getNote();
    82 	virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true);
    83 	virtual NoteObj getNoteObj();			
    84 	virtual QString getNoteASCII(const QString &indent, const int &width); // returns note	(ASCII)
    85     virtual QString getNoteASCII();			// returns note	(ASCII)
    86     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
    87 
    88 protected:
    89 	FlagRow standardFlags;
    90 public:	
    91 	virtual void activateStandardFlag(const QString &flag);
    92 	virtual void deactivateStandardFlag(const QString &flag);
    93 	virtual void toggleStandardFlag(const QString &flag);
    94 	virtual bool isActiveStandardFlag (const QString &flag);
    95 
    96 
    97 
    98 protected:
    99 	QString objID;					//! id set during load/save currently used for xLinks
   100 public:
   101 	virtual void setID (const QString &s);
   102 	virtual QString getID ();
   103 
   104 	// Navigation and selection
   105 	virtual TreeItem* getChildNum(const int &n);
   106 	virtual BranchItem* getFirstBranch();
   107 	virtual BranchItem* getLastBranch();
   108 
   109 	/*! Get next branch after current branch. Return NULL if there is no
   110 	    next branch */
   111 	virtual BranchItem* getNextBranch(BranchItem* currentBranch);
   112 
   113 	virtual BranchItem* getBranchNum(const int &n);
   114 	virtual BranchObj* getBranchObjNum(const int &n);
   115 	virtual void setLastSelectedBranch();		//! Set myself as last selected in parent
   116 	virtual void setLastSelectedBranch(int i);	//! Set last selected branch directly
   117 	virtual TreeItem* getLastSelectedBranch();
   118 
   119 	virtual void setHideTmp (HideTmpMode);
   120 	virtual bool hasHiddenExportParent ();
   121 	virtual void setHideInExport(bool);		// set export of object (and children)
   122 	virtual bool hideInExport();
   123 	virtual bool isHidden ();		
   124 
   125 	
   126 protected:
   127 	VymModel *model;
   128 
   129     QList<TreeItem*> childItems;
   130     QList<QVariant> itemData;
   131     TreeItem *parentItem;
   132  
   133 	int branchOffset;
   134 	int branchCounter;
   135 	int lastSelectedBranchNum;
   136 
   137 	int imageOffset;
   138 	int imageCounter;
   139 
   140 	bool hideExport;//! Hide this item in export
   141 	bool hidden;	//! Hidden in export if true
   142 };
   143 
   144 #endif