treeitem.h
author insilmaril
Fri, 06 Mar 2009 15:02:58 +0000
changeset 741 1b4d1ea6ea8c
parent 740 6dc0a20031f7
child 745 2d4cc445a86a
permissions -rw-r--r--
Iteration over map works now (again)
     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 columnCount() const;
    23 	int branchCount() const;
    24 
    25     int row() const;
    26 	int column() const;
    27 	int depth() ;
    28     TreeItem *parent();
    29 	int num();		// object index, e.g. branch number
    30 
    31 	// Accessing data
    32     QVariant data(int column) const;
    33 	void setHeading (const QString s);
    34 	QString getHeading();
    35 	void setNote(const QString s);
    36 	QString getNote();
    37 	void setType (const Type t);
    38 	Type getType ();
    39 	QString getTypeName ();
    40 
    41 	// Navigation and selection
    42 	TreeItem* getChildNum(const int &n);
    43 	TreeItem* getFirstBranch();
    44 	TreeItem* getLastBranch();
    45 	TreeItem* getBranchNum(const int &n);
    46 	void setLastSelectedBranch();
    47 	TreeItem* getLastSelectedBranch();
    48 
    49 	
    50 	// Relation to map objects in graphicsscene
    51 	LinkableMapObj* getLMO();
    52 	void setLMO (LinkableMapObj*);
    53 
    54 protected:
    55     QList<TreeItem*> childItems;
    56     QList<QVariant> itemData;
    57     TreeItem *parentItem;
    58  
    59 	Type type;
    60 	LinkableMapObj *lmo;
    61 
    62 	int branchOffset;
    63 	int branchCounter;
    64 	int lastSelectedBranchNum;
    65 };
    66 
    67 #endif