treeitem.h
author insilmaril
Mon, 23 Mar 2009 09:06:51 +0000
changeset 745 2d4cc445a86a
parent 741 1b4d1ea6ea8c
child 746 ee6b0f3a4c2f
permissions -rw-r--r--
still working on insert/remove of rows
     1 #ifndef TREEITEM_H
     2 #define TREEITEM_H
     3 
     4 #include <QList>
     5 #include <QVariant>
     6 
     7 class LinkableMapObj;
     8 
     9 class TreeItem
    10 {
    11 public:
    12 	enum Type {Undefined,MapCenter,Branch,Image};
    13     TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
    14     ~TreeItem();
    15 
    16 	// General housekeeping
    17     void appendChild (TreeItem *child);
    18 	void removeChild (int row);
    19 
    20     TreeItem *child(int row);
    21     int childCount() const;
    22     int childNumber() const;
    23     int columnCount() const;
    24 	int branchCount() const;
    25 
    26     int row() const;
    27 	int column() const;
    28 	int depth() ;
    29     TreeItem *parent();
    30 	int num();		// object index, e.g. branch number
    31 
    32 	// Accessing data
    33     QVariant data(int column) const;
    34 	void setHeading (const QString s);
    35 	QString getHeading();
    36 	void setNote(const QString s);
    37 	QString getNote();
    38 	void setType (const Type t);
    39 	Type getType ();
    40 	QString getTypeName ();
    41 
    42 	// Navigation and selection
    43 	TreeItem* getChildNum(const int &n);
    44 	TreeItem* getFirstBranch();
    45 	TreeItem* getLastBranch();
    46 	TreeItem* getBranchNum(const int &n);
    47 	void setLastSelectedBranch();
    48 	TreeItem* getLastSelectedBranch();
    49 
    50 	
    51 	// Relation to map objects in graphicsscene
    52 	LinkableMapObj* getLMO();
    53 	void setLMO (LinkableMapObj*);
    54 
    55 protected:
    56     QList<TreeItem*> childItems;
    57     QList<QVariant> itemData;
    58     TreeItem *parentItem;
    59  
    60 	Type type;
    61 	LinkableMapObj *lmo;
    62 
    63 	int branchOffset;
    64 	int branchCounter;
    65 	int lastSelectedBranchNum;
    66 };
    67 
    68 #endif