treeitem.h
author insilmaril
Thu, 26 Mar 2009 07:50:32 +0000
changeset 747 008e72977ab8
parent 746 ee6b0f3a4c2f
child 749 9ff332964015
permissions -rw-r--r--
Notes work again (to some degree)
     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 
    35     int row() const;
    36 	int column() const;
    37 	int depth() ;
    38     TreeItem *parent();
    39 	int num();		// object index, e.g. branch number
    40 
    41 	// Accessing data
    42     QVariant data(int column) const;
    43 	void setHeading (const QString s);
    44 	QString getHeading();
    45 
    46 protected:
    47 	NoteObj note;
    48 public:	
    49 	void setNote(const QString s);
    50 	QString getNote();
    51 	virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true);
    52 	virtual NoteObj getNoteObj();			
    53 	virtual QString getNoteASCII(const QString &indent, const int &width); // returns note	(ASCII)
    54     virtual QString getNoteASCII();			// returns note	(ASCII)
    55     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
    56 
    57 
    58 protected:
    59 	Type type;
    60 public:	
    61 	void setType (const Type t);
    62 	Type getType ();
    63 	QString getTypeName ();
    64 
    65 	// Navigation and selection
    66 	TreeItem* getChildNum(const int &n);
    67 	TreeItem* getFirstBranch();
    68 	TreeItem* getLastBranch();
    69 	TreeItem* getBranchNum(const int &n);
    70 	void setLastSelectedBranch();
    71 	TreeItem* getLastSelectedBranch();
    72 
    73 	
    74 	// Relation to map objects in graphicsscene
    75 	LinkableMapObj* getLMO();
    76 	void setLMO (LinkableMapObj*);
    77 
    78 protected:
    79 	VymModel *model;
    80 
    81     QList<TreeItem*> childItems;
    82     QList<QVariant> itemData;
    83     TreeItem *parentItem;
    84  
    85 	LinkableMapObj *lmo;
    86 
    87 	int branchOffset;
    88 	int branchCounter;
    89 	int lastSelectedBranchNum;
    90 
    91 	bool hidden;	//! Hidden in export if true
    92 };
    93 
    94 #endif