mapeditor.h
author insilmaril
Wed, 13 May 2009 08:26:27 +0000
changeset 767 6d2b32f305f9
parent 766 7a71a914afdb
child 769 a6931cd6309a
permissions -rw-r--r--
Started to use QtKinetic for Animation
     1 #ifndef MAPEDITOR_H
     2 #define MAPEDITOR_H
     3 
     4 #include <QGraphicsView>
     5 #include <QItemSelectionModel>
     6 
     7 #include <QtPropertyAnimation>	//! Not yet officially in Qt!
     8 
     9 #include "attribute.h"
    10 #include "ornamentedobj.h"
    11 #include "settings.h"
    12 #include "vymmodel.h"
    13 
    14 
    15 /*! \brief Main widget in vym to display and edit a map */
    16 
    17 
    18 class MapEditor : public QGraphicsView {	
    19     Q_OBJECT
    20 	Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor)
    21 	Q_PROPERTY(QPointF scrollBarPos READ getScrollBarPos WRITE setScrollBarPos)
    22 
    23 public:
    24     MapEditor(VymModel *vm);
    25 	~MapEditor();
    26 	VymModel* getModel();
    27 	QGraphicsScene * getScene();
    28 
    29 protected:
    30 	QPointF scrollBarPos;
    31 	QPointF scrollBarPosTarget;
    32 	QtPropertyAnimation scrollBarPosAnimation;
    33 public:
    34 	void setScrollBarPosTarget (const QRectF &rect);	//!  ensureVisible of rect
    35 	QPointF getScrollBarPosTarget ();
    36 	void setScrollBarPos (const QPointF &p);
    37 	QPointF getScrollBarPos();
    38 
    39 protected:
    40 	qreal zoomFactor;
    41 	qreal zoomFactorTarget;
    42 	QtPropertyAnimation zoomAnimation;
    43 public:
    44 	void setZoomFactorTarget (const qreal &zf);
    45 	qreal getZoomFactorTarget();
    46 	void setZoomFactor (const qreal &zf);
    47 	qreal getZoomFactor();
    48 
    49 public:
    50     void print();				//!< Print the map
    51 	void setAntiAlias (bool);	//!< Set or unset antialiasing
    52 	void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps
    53 public:
    54 	TreeItem *findMapItem (QPointF p,TreeItem *exclude);	//! find item in map at position p. Ignore item exclude 
    55 
    56 	AttributeTable* attributeTable();
    57     void testFunction1();				// just testing new stuff
    58     void testFunction2();				// just testing new stuff
    59 
    60 public slots:
    61 	void editHeading();
    62 	void editHeadingFinished();
    63 private:
    64 	bool editingHeading;
    65 	QLineEdit *lineEdit;
    66 
    67 protected:
    68 	virtual void contextMenuEvent ( QContextMenuEvent *e );
    69     virtual void keyPressEvent(QKeyEvent*);
    70     virtual void keyReleaseEvent(QKeyEvent*);
    71     virtual void mousePressEvent(QMouseEvent*);
    72     virtual void mouseMoveEvent(QMouseEvent*);
    73     virtual void mouseReleaseEvent(QMouseEvent*);
    74     virtual void mouseDoubleClickEvent(QMouseEvent*);
    75     virtual void resizeEvent( QResizeEvent * );
    76 
    77 	void dragEnterEvent (QDragEnterEvent *);
    78 	void dragMoveEvent (QDragMoveEvent *);
    79 	void dragLeaveEvent (QDragLeaveEvent *);
    80 	void dropEvent (QDropEvent *);
    81 
    82 
    83 private:
    84 	QGraphicsScene *mapScene;
    85 	VymModel *model;			//!< Vym Map, includding several mapCenters
    86 
    87 	bool adjustCanvasRequested;	// collect requests until end of user event
    88 	BranchObj *editingBO;		// entering Text into BO
    89 
    90     QCursor HandOpenCursor;		// cursor while moving canvas view
    91 	QCursor PickColorCursor;	// cursor while picking color 
    92 	QCursor CopyCursor;			// cursor while picking color 
    93 	QCursor XLinkCursor;		// cursor while picking color 
    94 	bool pickingColor;
    95 	bool drawingLink;			// true while creating a link
    96 	bool copyingObj;			// true while creating a link
    97 	XLinkObj* tmpXLink;
    98 
    99 	MapObj* movingObj;				// moving a MapObj
   100 	MapObj* linkingObj_src;			// part of a link
   101     QPointF movingObj_orgPos;		// org. pos of mouse before move
   102     QPointF movingObj_orgRelPos;	// org. relative pos of mouse before move
   103     QPointF movingObj_start;		// rel. pos of mouse to absPos 
   104     QPointF movingCont_start;		// inital pos of moving Content or
   105     QPointF movingVec;				// how far has Content moved
   106 
   107 	QPointF contextMenuPos;			// position where context event was triggered
   108 
   109     QPrinter* printer;				// Printing
   110 
   111 	AttributeTable *attrTable;
   112 
   113 	bool printFrame;			// Print frame around map
   114 	bool printFooter;			// Print footer below map
   115 
   116 	QPoint exportOffset;		// set before export, used in save
   117 
   118 //////////// Selection related
   119 signals:
   120 	void selectionChanged(const QItemSelection &, const QItemSelection &);
   121 
   122 private:	
   123 	QList <QGraphicsRectItem*> selboxList;
   124 	QColor selectionColor;
   125 
   126 public slots:
   127 	void updateSelection(const QItemSelection &,const QItemSelection &); // update selection
   128 	void updateData (const QModelIndex&); // update data
   129 public:
   130 	void setSelectionColor (QColor c);
   131 	QColor getSelectionColor ();
   132 
   133 };
   134 #endif
   135