treeitem.h
author insilmaril
Wed, 01 Apr 2009 15:06:57 +0000
changeset 749 9ff332964015
parent 746 ee6b0f3a4c2f
child 750 ff3b01ce0960
permissions -rw-r--r--
moved scroll functions from BranchObj to BranchItem
     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 VymModel;
    12 
    13 class TreeItem:public XMLObj
    14 {
    15 public:
    16 	enum Type {Undefined,MapCenter,Branch,Image};
    17     TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
    18     ~TreeItem();
    19 	QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset);
    20 
    21 
    22 	// General housekeeping
    23 	void setModel (VymModel *m);
    24 	VymModel* getModel();
    25 
    26     void appendChild (TreeItem *child);
    27 	void removeChild (int row);
    28 
    29     TreeItem *child(int row);
    30     int childCount() const;
    31     int childNumber() const;
    32     int columnCount() const;
    33 	int branchCount() const;
    34 	int imageCount() const;
    35 	int xlinkCount() const;
    36 
    37     int row() const;
    38 	int column() const;
    39 	int depth() ;
    40     TreeItem *parent();
    41 
    42 	/*! Return number of item in parent by type, 
    43 	    e.g. first branch has number 0           */
    44 	int num();		
    45 	int num (TreeItem *item);	//! Return number of item by type
    46 
    47 	// Accessing data
    48     QVariant data(int column) const;
    49 	void setHeading (const QString s);
    50 	QString getHeading();
    51 
    52 protected:
    53 	NoteObj note;
    54 public:	
    55 	void setNote(const QString s);
    56 	QString getNote();
    57 	virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true);
    58 	virtual NoteObj getNoteObj();			
    59 	virtual QString getNoteASCII(const QString &indent, const int &width); // returns note	(ASCII)
    60     virtual QString getNoteASCII();			// returns note	(ASCII)
    61     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
    62 
    63 
    64 protected:
    65 	Type type;
    66 public:	
    67 	void setType (const Type t);
    68 	Type getType ();
    69 	QString getTypeName ();
    70 
    71 	// Navigation and selection
    72 	TreeItem* getChildNum(const int &n);
    73 	TreeItem* getFirstBranch();
    74 	TreeItem* getLastBranch();
    75 	TreeItem* getBranchNum(const int &n);
    76 	void setLastSelectedBranch();
    77 	TreeItem* getLastSelectedBranch();
    78 
    79 	
    80 	// Relation to map objects in graphicsscene
    81 	LinkableMapObj* getLMO();
    82 	void setLMO (LinkableMapObj*);
    83 
    84 protected:
    85 	VymModel *model;
    86 
    87     QList<TreeItem*> childItems;
    88     QList<QVariant> itemData;
    89     TreeItem *parentItem;
    90  
    91 	LinkableMapObj *lmo;
    92 
    93 	int branchOffset;
    94 	int branchCounter;
    95 	int lastSelectedBranchNum;
    96 
    97 	bool hidden;	//! Hidden in export if true
    98 };
    99 
   100 #endif