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