treeitem.h
author insilmaril
Fri, 30 Jan 2009 09:14:12 +0000
changeset 738 716a777c1c98
parent 735 84ae10f6e3a3
child 740 6dc0a20031f7
permissions -rw-r--r--
fixes for selecting branches
     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 
    24     int row() const;
    25 	int column() const;
    26     TreeItem *parent();
    27 
    28 	// Accessing data
    29     QVariant data(int column) const;
    30 	void setHeading (const QString s);
    31 	QString getHeading();
    32 	void setType (const Type t);
    33 	Type getType ();
    34 	QString getTypeName ();
    35 
    36 	// Navigation and selection
    37 	TreeItem* getChildNum(const int &n);
    38 	TreeItem* getFirstBranch();
    39 	TreeItem* getLastBranch();
    40 	TreeItem* getBranchNum(const int &n);
    41 	void setLastSelectedBranch();
    42 	TreeItem* getLastSelectedBranch();
    43 
    44 	
    45 	// Relation to map objects in graphicsscene
    46 	LinkableMapObj* getLMO();
    47 	void setLMO (LinkableMapObj*);
    48 
    49 private:
    50     QList<TreeItem*> childItems;
    51     QList<QVariant> itemData;
    52     TreeItem *parentItem;
    53  
    54 	Type type;
    55 	LinkableMapObj *lmo;
    56 
    57 	int branchOffset;
    58 	int branchCount;
    59 	int lastSelectedBranchNum;
    60 };
    61 
    62 #endif