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