treeitem.h
author insilmaril
Thu, 23 Apr 2009 12:15:31 +0000
changeset 755 ed5b407975b3
parent 754 db0ec4bcf416
child 756 a8a5c7288f57
permissions -rw-r--r--
more data in Tree, less in Map
     1 #ifndef TREEITEM_H
     2 #define TREEITEM_H
     3 
     4 #include <QList>
     5 #include <QVariant>
     6 
     7 #include "noteobj.h"
     8 #include "xmlobj.h"
     9 
    10 class LinkableMapObj;
    11 class BranchObj;
    12 class BranchItem;
    13 
    14 
    15 class VymModel;
    16 
    17 class TreeItem:public XMLObj
    18 {
    19 public:
    20 	enum Type {Undefined,MapCenter,Branch,Image};
    21 	enum HideTmpMode {HideNone, HideExport};
    22 
    23     TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
    24     ~TreeItem();
    25 	QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset);
    26 
    27 
    28 	// General housekeeping
    29 	void setModel (VymModel *m);
    30 	VymModel* getModel();
    31 
    32     void appendChild (TreeItem *child);
    33 	void removeChild (int row);
    34 
    35     TreeItem *child(int row);
    36     int childCount() const;
    37     int childNumber() const;
    38     int columnCount() const;
    39 	int branchCount() const;
    40 	int imageCount() const;
    41 	int xlinkCount() const;
    42 
    43     int row() const;
    44 	int column() const;
    45 	int depth() ;
    46     TreeItem *parent();
    47 
    48 	/*! Return number of item in parent by type, 
    49 	    e.g. first branch has number 0           */
    50 	int childNum();				//! Return number of item in list of all children
    51 	int num();					//! Return number of item by type
    52 	int num (TreeItem *item);	//! Return number of item by type
    53 
    54 	// Accessing data
    55     QVariant data(int column) const;
    56 	void setHeading (const QString s);
    57 	QString getHeading() const;
    58 	std::string getHeadingStd() const;	//! convenience function used for debugging
    59 
    60 protected:
    61 	NoteObj note;
    62 public:	
    63 	void setNote(const QString s);
    64 	QString getNote();
    65 	virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true);
    66 	virtual NoteObj getNoteObj();			
    67 	virtual QString getNoteASCII(const QString &indent, const int &width); // returns note	(ASCII)
    68     virtual QString getNoteASCII();			// returns note	(ASCII)
    69     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
    70 
    71 
    72 protected:
    73 	Type type;
    74 public:	
    75 	void setType (const Type t);
    76 	Type getType ();
    77 	bool isBranchLikeType() const;
    78 	QString getTypeName ();
    79 
    80 protected:
    81 	QString objID;					//! id set during load/save currently used for xLinks
    82 public:
    83 	virtual void setID (const QString &s);
    84 	virtual QString getID ();
    85 
    86 	// Navigation and selection
    87 	TreeItem* getChildNum(const int &n);
    88 	BranchItem* getFirstBranch();
    89 	BranchItem* getLastBranch();
    90 	BranchItem* getBranchNum(const int &n);
    91 	BranchObj* getBranchObjNum(const int &n);
    92 	void setLastSelectedBranch();		//! Set myself as last selected in parent
    93 	void setLastSelectedBranch(int i);	//! Set last selected branch directly
    94 	TreeItem* getLastSelectedBranch();
    95 	TreeItem* findBySelectString (const QString &);	
    96 
    97 	virtual void setHideTmp (HideTmpMode);
    98 	virtual bool hasHiddenExportParent ();
    99 	virtual void setHideInExport(bool);		// set export of object (and children)
   100 	virtual bool hideInExport();
   101 	virtual bool isHidden ();		
   102 
   103 	
   104 	// Relation to map objects in graphicsscene	// FIXME-3 should be obsolete
   105 	LinkableMapObj* getLMO();
   106 	void setLMO (LinkableMapObj*);
   107 
   108 protected:
   109 	VymModel *model;
   110 
   111     QList<TreeItem*> childItems;
   112     QList<QVariant> itemData;
   113     TreeItem *parentItem;
   114  
   115 	LinkableMapObj *lmo;
   116 
   117 	int branchOffset;
   118 	int branchCounter;
   119 	int lastSelectedBranchNum;
   120 
   121 	bool hideExport;//! Hide this item in export
   122 	bool hidden;	//! Hidden in export if true
   123 };
   124 
   125 #endif