vymmodel.h
author insilmaril
Wed, 30 Jul 2008 14:42:03 +0000
branchrelease-1-12-maintained
changeset 43 cf274b28e5fe
parent 40 394b2f297e1d
child 57 d045ba89798e
permissions -rw-r--r--
Fixed animation timer, which didn't stop once activated
insilmaril@40
     1
#ifndef VYMMODEL_H
insilmaril@40
     2
#define VYMMODEL_H
insilmaril@40
     3
insilmaril@40
     4
#include <QGraphicsScene>
insilmaril@40
     5
insilmaril@40
     6
#include "mapcenterobj.h"
insilmaril@40
     7
#include "mapeditor.h"
insilmaril@40
     8
insilmaril@40
     9
insilmaril@40
    10
/*! \brief This will later be divided into Model/View
insilmaril@40
    11
*/
insilmaril@40
    12
insilmaril@40
    13
class VymModel : public QObject{
insilmaril@40
    14
	Q_OBJECT
insilmaril@40
    15
insilmaril@40
    16
public:
insilmaril@40
    17
	VymModel();
insilmaril@40
    18
	~VymModel ();
insilmaril@40
    19
    void clear();
insilmaril@40
    20
    void init();
insilmaril@40
    21
	void setMapEditor(MapEditor *me);	// FIXME should not be necessary in Model/View
insilmaril@40
    22
	MapEditor* getMapEditor();
insilmaril@40
    23
	void setVersion(const  QString &);
insilmaril@40
    24
	void setAuthor  (const QString &);
insilmaril@40
    25
	QString getAuthor ();
insilmaril@40
    26
	void setComment (const QString &);
insilmaril@40
    27
	QString getComment ();
insilmaril@40
    28
	QString getDate();
insilmaril@40
    29
	void setScene(QGraphicsScene *s);
insilmaril@40
    30
	QGraphicsScene *getScene();
insilmaril@40
    31
	MapCenterObj* addMapCenter();
insilmaril@40
    32
	MapCenterObj* addMapCenter(QPointF absPos);
insilmaril@40
    33
	MapCenterObj* removeMapCenter(MapCenterObj *mco);
insilmaril@40
    34
insilmaril@40
    35
	BranchObj* first();					// FIXME replaced by ModelIndex later
insilmaril@40
    36
	BranchObj* next(BranchObj *bo);		// FIXME replaced by ModelIndex later
insilmaril@40
    37
insilmaril@40
    38
    LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
insilmaril@40
    39
    LinkableMapObj* findObjBySelect (const QString &s);		// find MapObj by select string
insilmaril@40
    40
    LinkableMapObj* findID (const QString &s);				// find MapObj by previously set ID
insilmaril@40
    41
	QString saveToDir (const QString&,const QString&,int, const QPointF&);// Save data recursivly to tempdir
insilmaril@40
    42
insilmaril@40
    43
insilmaril@40
    44
////////////////////////////////////////// View related
insilmaril@40
    45
    // void updateLink();  FIXME needed?
insilmaril@40
    46
    void updateRelPositions();
insilmaril@40
    47
insilmaril@40
    48
	QRectF getTotalBBox();
insilmaril@40
    49
	void reposition();					//!< Call reposition for all MCOs
insilmaril@40
    50
	void setHideTmp (HideTmpMode mode);	
insilmaril@40
    51
	QPolygonF shape(BranchObj *bo);		//!< Returns arbitrary shape of subtree
insilmaril@40
    52
	void moveAway (LinkableMapObj *lmo);//!< Autolayout: Move all out of the way
insilmaril@40
    53
insilmaril@40
    54
	// Animation  **experimental**
insilmaril@40
    55
private slots:
insilmaril@40
    56
	void animate();						//!< Called by timer to animate stuff
insilmaril@40
    57
public:
insilmaril@40
    58
	void startAnimation (const QPointF &start, const QPointF &dest);
insilmaril@40
    59
	void stopAnimation  (MapObj *mo);
insilmaril@40
    60
private:	
insilmaril@40
    61
	QTimer *animationTimer;
insilmaril@40
    62
	bool animationUse;
insilmaril@40
    63
	uint animationTicks;
insilmaril@40
    64
	uint animationInterval;
insilmaril@40
    65
	int timerId;				// animation timer
insilmaril@40
    66
	QList <MapObj*> animObjList;// list with animated objects
insilmaril@40
    67
insilmaril@40
    68
////////////////////////////////////////// Selection related 
insilmaril@40
    69
public:
insilmaril@40
    70
	LinkableMapObj* getSelection();
insilmaril@40
    71
	BranchObj* getSelectedBranch();
insilmaril@40
    72
	bool select (const QString &s);
insilmaril@40
    73
	QString getSelectString (LinkableMapObj *lmo);
insilmaril@40
    74
insilmaril@40
    75
private:
insilmaril@40
    76
	QGraphicsScene *mapScene;
insilmaril@40
    77
	MapEditor *mapEditor;
insilmaril@40
    78
	QList <MapCenterObj*> mapCenters;
insilmaril@40
    79
	QString version;	//!< version string saved in vym file
insilmaril@40
    80
	QString author;
insilmaril@40
    81
	QString comment;
insilmaril@40
    82
	QDate date;
insilmaril@40
    83
};
insilmaril@40
    84
insilmaril@40
    85
insilmaril@40
    86
#endif