treeitem.h
author insilmaril
Tue May 26 11:24:51 2009 +0000 (2009-05-26)
changeset 774 2f002657dada
parent 772 e3f722759c7e
child 776 25e634a7e1dc
permissions -rw-r--r--
added missing new files
insilmaril@725
     1
#ifndef TREEITEM_H
insilmaril@725
     2
#define TREEITEM_H
insilmaril@725
     3
insilmaril@758
     4
#include <QColor>
insilmaril@725
     5
#include <QList>
insilmaril@725
     6
#include <QVariant>
insilmaril@725
     7
insilmaril@766
     8
#include "flagrow.h"
insilmaril@760
     9
#include "mapitem.h"
insilmaril@746
    10
#include "noteobj.h"
insilmaril@746
    11
#include "xmlobj.h"
insilmaril@746
    12
insilmaril@726
    13
class LinkableMapObj;
insilmaril@750
    14
class BranchObj;
insilmaril@750
    15
class BranchItem;
insilmaril@746
    16
class VymModel;
insilmaril@726
    17
insilmaril@762
    18
class TreeItem:public MapItem
insilmaril@725
    19
{
insilmaril@725
    20
public:
insilmaril@735
    21
	enum Type {Undefined,MapCenter,Branch,Image};
insilmaril@753
    22
	enum HideTmpMode {HideNone, HideExport};
insilmaril@753
    23
insilmaril@725
    24
    TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
insilmaril@725
    25
    ~TreeItem();
insilmaril@756
    26
	void init();
insilmaril@756
    27
insilmaril@727
    28
	// General housekeeping
insilmaril@759
    29
	virtual void setModel (VymModel *m);
insilmaril@759
    30
	virtual VymModel* getModel();
insilmaril@746
    31
insilmaril@759
    32
    virtual void appendChild (TreeItem *child);
insilmaril@759
    33
	virtual void removeChild (int row);
insilmaril@772
    34
	virtual void removeChildBranches ();
insilmaril@725
    35
insilmaril@759
    36
    virtual TreeItem *child(int row);
insilmaril@759
    37
    virtual int childCount() const;
insilmaril@759
    38
    virtual int childNumber() const;
insilmaril@759
    39
    virtual int columnCount() const;
insilmaril@759
    40
	virtual int branchCount() const;
insilmaril@759
    41
	virtual int imageCount() const;
insilmaril@759
    42
	virtual int xlinkCount() const;
insilmaril@727
    43
insilmaril@759
    44
    virtual int row() const;
insilmaril@759
    45
	virtual int column() const;
insilmaril@759
    46
	virtual int depth() ;
insilmaril@759
    47
    virtual TreeItem *parent();
insilmaril@749
    48
insilmaril@749
    49
	/*! Return number of item in parent by type, 
insilmaril@749
    50
	    e.g. first branch has number 0           */
insilmaril@758
    51
	virtual int childNum();				//! Return number of item in list of all children
insilmaril@758
    52
	virtual int num();					//! Return number of item by type
insilmaril@758
    53
	virtual int num (TreeItem *item);	//! Return number of item by type
insilmaril@727
    54
insilmaril@766
    55
protected:
insilmaril@766
    56
	Type type;
insilmaril@766
    57
public:	
insilmaril@766
    58
	virtual void setType (const Type t);
insilmaril@766
    59
	virtual Type getType ();
insilmaril@766
    60
	virtual bool isBranchLikeType() const;
insilmaril@766
    61
	virtual QString getTypeName ();
insilmaril@766
    62
insilmaril@766
    63
// Accessing data
insilmaril@758
    64
    virtual QVariant data(int column) const;
insilmaril@758
    65
insilmaril@767
    66
insilmaril@758
    67
protected:
insilmaril@758
    68
	QColor headingColor;
insilmaril@758
    69
public:	
insilmaril@758
    70
	virtual void setHeading (const QString s);
insilmaril@758
    71
	virtual QString getHeading() const;
insilmaril@758
    72
	virtual std::string getHeadingStd() const;	//! convenience function used for debugging
insilmaril@758
    73
	virtual void setHeadingColor(QColor color);	//! Set color of heading. In BranchItem overloaded to update QGraphicsView
insilmaril@758
    74
	virtual QColor getHeadingColor();			//! Returns color of heading
insilmaril@746
    75
insilmaril@767
    76
insilmaril@767
    77
protected:
insilmaril@767
    78
	QString url;
insilmaril@767
    79
public:
insilmaril@767
    80
	void setURL (const QString &url);			//! Set URL
insilmaril@767
    81
	QString getURL ();							//! Get URL
insilmaril@767
    82
insilmaril@767
    83
insilmaril@767
    84
protected:
insilmaril@767
    85
	QString vymLink;
insilmaril@767
    86
public:
insilmaril@767
    87
	void setVymLink (const QString &url);			//! Set URL
insilmaril@767
    88
	QString getVymLink ();							//! Get URL
insilmaril@767
    89
insilmaril@767
    90
insilmaril@746
    91
protected:
insilmaril@746
    92
	NoteObj note;
insilmaril@746
    93
public:	
insilmaril@767
    94
	virtual void setNote(const QString &s);
insilmaril@767
    95
	virtual void clearNote();
insilmaril@758
    96
	virtual QString getNote();
insilmaril@768
    97
	virtual bool hasEmptyNote();
insilmaril@746
    98
	virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true);
insilmaril@746
    99
	virtual NoteObj getNoteObj();			
insilmaril@746
   100
	virtual QString getNoteASCII(const QString &indent, const int &width); // returns note	(ASCII)
insilmaril@746
   101
    virtual QString getNoteASCII();			// returns note	(ASCII)
insilmaril@746
   102
    virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
insilmaril@746
   103
insilmaril@767
   104
insilmaril@746
   105
protected:
insilmaril@766
   106
	FlagRow standardFlags;
insilmaril@767
   107
	FlagRow systemFlags;
insilmaril@746
   108
public:	
insilmaril@766
   109
	virtual void activateStandardFlag(const QString &flag);
insilmaril@766
   110
	virtual void deactivateStandardFlag(const QString &flag);
insilmaril@767
   111
	virtual void deactivateAllStandardFlags();
insilmaril@767
   112
insilmaril@767
   113
	/*! \brief Toggle a Flag 
insilmaril@767
   114
	    If master is not NULL,, only one Flag from FlagRow master may 
insilmaril@767
   115
		be active simultanously, the others get deactivated.
insilmaril@767
   116
	*/	
insilmaril@767
   117
	virtual void toggleStandardFlag(const QString &flag, FlagRow *master=NULL);
insilmaril@766
   118
	virtual bool isActiveStandardFlag (const QString &flag);
insilmaril@767
   119
	virtual QStringList activeStandardFlagNames();
insilmaril@770
   120
	virtual FlagRow* getStandardFlagRow ();
insilmaril@770
   121
insilmaril@767
   122
	virtual QStringList activeSystemFlagNames();
insilmaril@766
   123
insilmaril@766
   124
insilmaril@767
   125
	virtual bool canMoveDown();
insilmaril@767
   126
	virtual bool canMoveUp();
insilmaril@738
   127
insilmaril@754
   128
protected:
insilmaril@754
   129
	QString objID;					//! id set during load/save currently used for xLinks
insilmaril@754
   130
public:
insilmaril@754
   131
	virtual void setID (const QString &s);
insilmaril@754
   132
	virtual QString getID ();
insilmaril@754
   133
insilmaril@738
   134
	// Navigation and selection
insilmaril@758
   135
	virtual TreeItem* getChildNum(const int &n);
insilmaril@758
   136
	virtual BranchItem* getFirstBranch();
insilmaril@758
   137
	virtual BranchItem* getLastBranch();
insilmaril@763
   138
insilmaril@763
   139
	/*! Get next branch after current branch. Return NULL if there is no
insilmaril@763
   140
	    next branch */
insilmaril@763
   141
	virtual BranchItem* getNextBranch(BranchItem* currentBranch);
insilmaril@763
   142
insilmaril@758
   143
	virtual BranchItem* getBranchNum(const int &n);
insilmaril@758
   144
	virtual BranchObj* getBranchObjNum(const int &n);
insilmaril@758
   145
	virtual void setLastSelectedBranch();		//! Set myself as last selected in parent
insilmaril@758
   146
	virtual void setLastSelectedBranch(int i);	//! Set last selected branch directly
insilmaril@758
   147
	virtual TreeItem* getLastSelectedBranch();
insilmaril@738
   148
insilmaril@768
   149
protected:
insilmaril@768
   150
	bool hideExport;							//! Hide this item in export
insilmaril@768
   151
public:
insilmaril@753
   152
	virtual void setHideTmp (HideTmpMode);
insilmaril@753
   153
	virtual bool hasHiddenExportParent ();
insilmaril@753
   154
	virtual void setHideInExport(bool);		// set export of object (and children)
insilmaril@753
   155
	virtual bool hideInExport();
insilmaril@753
   156
	virtual bool isHidden ();		
insilmaril@753
   157
insilmaril@726
   158
	
insilmaril@741
   159
protected:
insilmaril@746
   160
	VymModel *model;
insilmaril@746
   161
insilmaril@725
   162
    QList<TreeItem*> childItems;
insilmaril@725
   163
    QList<QVariant> itemData;
insilmaril@725
   164
    TreeItem *parentItem;
insilmaril@773
   165
insilmaril@773
   166
	/*!  Set rootItem (does not change, needed for quick check 
insilmaril@773
   167
	     if some branch is mapCenter */
insilmaril@773
   168
	TreeItem *rootItem;
insilmaril@726
   169
 
insilmaril@738
   170
	int branchOffset;
insilmaril@741
   171
	int branchCounter;
insilmaril@738
   172
	int lastSelectedBranchNum;
insilmaril@746
   173
insilmaril@763
   174
	int imageOffset;
insilmaril@763
   175
	int imageCounter;
insilmaril@763
   176
insilmaril@746
   177
	bool hidden;	//! Hidden in export if true
insilmaril@725
   178
};
insilmaril@725
   179
insilmaril@725
   180
#endif