treeitem.h
author insilmaril
Tue, 07 Apr 2009 16:15:53 +0000
changeset 753 25a77484ec72
parent 750 ff3b01ce0960
child 754 db0ec4bcf416
permissions -rw-r--r--
more work on screwing up the data structures
     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 
    14 
    15 class VymModel;
    16 
    17 class TreeItem:public XMLObj
    18 {
    19 public:
    20 	enum Type {Undefined,MapCenter,Branch,Image};
    21 	enum HideTmpMode {HideNone, HideExport};
    22 
    23     TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
    24     ~TreeItem();
    25 	QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset);
    26 
    27 
    28 	// General housekeeping
    29 	void setModel (VymModel *m);
    30 	VymModel* getModel();
    31 
    32     void appendChild (TreeItem *child);
    33 	void removeChild (int row);
    34 
    35     TreeItem *child(int row);
    36     int childCount() const;
    37     int childNumber() const;
    38     int columnCount() const;
    39 	int branchCount() const;
    40 	int imageCount() const;
    41 	int xlinkCount() const;
    42 
    43     int row() const;
    44 	int column() const;
    45 	int depth() ;
    46     TreeItem *parent();
    47 
    48 	/*! Return number of item in parent by type, 
    49 	    e.g. first branch has number 0           */
    50 	int num();		
    51 	int num (TreeItem *item);	//! Return number of item by type
    52 
    53 	// Accessing data
    54     QVariant data(int column) const;
    55 	void setHeading (const QString s);
    56 	QString getHeading() const;
    57 	std::string headingStd() const;	//! convenience function used for debugging
    58 
    59 protected:
    60 	NoteObj note;
    61 public:	
    62 	void setNote(const QString s);
    63 	QString getNote();
    64 	virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true);
    65 	virtual NoteObj getNoteObj();			
    66 	virtual QString getNoteASCII(const QString &indent, const int &width); // returns note	(ASCII)
    67     virtual QString getNoteASCII();			// returns note	(ASCII)
    68     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
    69 
    70 
    71 protected:
    72 	Type type;
    73 public:	
    74 	void setType (const Type t);
    75 	Type getType ();
    76 	bool isBranchLikeType() const;
    77 	QString getTypeName ();
    78 
    79 	// Navigation and selection
    80 	TreeItem* getChildNum(const int &n);
    81 	BranchItem* getFirstBranch();
    82 	BranchItem* getLastBranch();
    83 	BranchItem* getBranchNum(const int &n);
    84 	BranchObj* getBranchObjNum(const int &n);
    85 	void setLastSelectedBranch();
    86 	TreeItem* getLastSelectedBranch();
    87 
    88 	virtual void setHideTmp (HideTmpMode);
    89 	virtual bool hasHiddenExportParent ();
    90 	virtual void setHideInExport(bool);		// set export of object (and children)
    91 	virtual bool hideInExport();
    92 	virtual bool isHidden ();		
    93 
    94 	
    95 	// Relation to map objects in graphicsscene	// FIXME-3 should be obsolete
    96 	LinkableMapObj* getLMO();
    97 	void setLMO (LinkableMapObj*);
    98 
    99 protected:
   100 	VymModel *model;
   101 
   102     QList<TreeItem*> childItems;
   103     QList<QVariant> itemData;
   104     TreeItem *parentItem;
   105  
   106 	LinkableMapObj *lmo;
   107 
   108 	int branchOffset;
   109 	int branchCounter;
   110 	int lastSelectedBranchNum;
   111 
   112 	bool hideExport;//! Hide this item in export
   113 	bool hidden;	//! Hidden in export if true
   114 };
   115 
   116 #endif