treeitem.h
author insilmaril
Tue, 28 Apr 2009 20:53:44 +0000
changeset 759 bf3ea1f1520b
parent 758 04039e47ac74
child 760 59614eaf5fbb
permissions -rw-r--r--
minor fixes
     1 #ifndef TREEITEM_H
     2 #define TREEITEM_H
     3 
     4 #include <QColor>
     5 #include <QList>
     6 #include <QVariant>
     7 
     8 #include "noteobj.h"
     9 #include "xmlobj.h"
    10 
    11 class LinkableMapObj;
    12 class BranchObj;
    13 class BranchItem;
    14 
    15 
    16 class VymModel;
    17 
    18 class TreeItem:public XMLObj
    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 	// Accessing data
    58     virtual QVariant data(int column) const;
    59 
    60 protected:
    61 	QColor headingColor;
    62 public:	
    63 	virtual void setHeading (const QString s);
    64 	virtual QString getHeading() const;
    65 	virtual std::string getHeadingStd() const;	//! convenience function used for debugging
    66 	virtual void setHeadingColor(QColor color);	//! Set color of heading. In BranchItem overloaded to update QGraphicsView
    67 	virtual QColor getHeadingColor();			//! Returns color of heading
    68 
    69 protected:
    70 	NoteObj note;
    71 public:	
    72 	virtual void setNote(const QString s);
    73 	virtual QString getNote();
    74 	virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true);
    75 	virtual NoteObj getNoteObj();			
    76 	virtual QString getNoteASCII(const QString &indent, const int &width); // returns note	(ASCII)
    77     virtual QString getNoteASCII();			// returns note	(ASCII)
    78     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
    79 
    80 
    81 protected:
    82 	Type type;
    83 public:	
    84 	virtual void setType (const Type t);
    85 	virtual Type getType ();
    86 	virtual bool isBranchLikeType() const;
    87 	virtual QString getTypeName ();
    88 
    89 protected:
    90 	QString objID;					//! id set during load/save currently used for xLinks
    91 public:
    92 	virtual void setID (const QString &s);
    93 	virtual QString getID ();
    94 
    95 	// Navigation and selection
    96 	virtual TreeItem* getChildNum(const int &n);
    97 	virtual BranchItem* getFirstBranch();
    98 	virtual BranchItem* getLastBranch();
    99 	virtual BranchItem* getBranchNum(const int &n);
   100 	virtual BranchObj* getBranchObjNum(const int &n);
   101 	virtual void setLastSelectedBranch();		//! Set myself as last selected in parent
   102 	virtual void setLastSelectedBranch(int i);	//! Set last selected branch directly
   103 	virtual TreeItem* getLastSelectedBranch();
   104 	virtual TreeItem* findBySelectString (const QString &);	
   105 
   106 	virtual void setHideTmp (HideTmpMode);
   107 	virtual bool hasHiddenExportParent ();
   108 	virtual void setHideInExport(bool);		// set export of object (and children)
   109 	virtual bool hideInExport();
   110 	virtual bool isHidden ();		
   111 
   112 	
   113 	// Relation to map objects in graphicsscene	// FIXME-4 should be obsolete
   114 	virtual LinkableMapObj* getLMO();
   115 	virtual void setLMO (LinkableMapObj*);
   116 
   117 protected:
   118 	VymModel *model;
   119 
   120     QList<TreeItem*> childItems;
   121     QList<QVariant> itemData;
   122     TreeItem *parentItem;
   123  
   124 	LinkableMapObj *lmo;
   125 
   126 	int branchOffset;
   127 	int branchCounter;
   128 	int lastSelectedBranchNum;
   129 
   130 	bool hideExport;//! Hide this item in export
   131 	bool hidden;	//! Hidden in export if true
   132 };
   133 
   134 #endif