4 #include <QGraphicsView>
5 #include <QItemSelectionModel>
7 #include <QPropertyAnimation>
11 #include "ornamentedobj.h"
19 /*! \brief Main widget in vym to display and edit a map */
22 class MapEditor : public QGraphicsView {
37 MapEditor(VymModel *vm);
40 QGraphicsScene * getScene();
41 MapEditor::EditorState getState();
43 // Animation of scrollbars
44 Q_PROPERTY(QPointF scrollBarPos READ getScrollBarPos WRITE setScrollBarPos)
48 QPointF scrollBarPosTarget;
49 QPropertyAnimation scrollBarPosAnimation;
51 QPointF vPan; //! Direction of panning during moving of object
52 QPoint pointerPos; //! Pointer position in widget coordinates
53 Qt::KeyboardModifiers pointerMod; //! modifiers of move event
59 void scrollTo (const QModelIndex &index);
60 void setScrollBarPosTarget (QRectF rect); //! ensureVisible of rect
61 QPointF getScrollBarPosTarget ();
62 void setScrollBarPos (const QPointF &p);
63 QPointF getScrollBarPos();
64 void animateScrollBars();
67 Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor)
71 qreal zoomFactorTarget;
72 QPropertyAnimation zoomAnimation;
75 void setZoomFactorTarget (const qreal &zf);
76 qreal getZoomFactorTarget();
77 void setZoomFactor (const qreal &zf);
78 qreal getZoomFactor();
80 // Animation of rotation
81 Q_PROPERTY(qreal angle READ getAngle WRITE setAngle)
86 QPropertyAnimation rotationAnimation;
89 void setAngleTarget (const qreal &a);
90 qreal getAngleTarget();
91 void setAngle (const qreal &a);
95 // Animation of viewCenter
96 Q_PROPERTY (QPointF viewCenter READ getViewCenter WRITE setViewCenter)
100 QPointF viewCenterTarget;
103 void setViewCenterTarget (
107 const int duration=2000,
108 const QEasingCurve &easingCurve=QEasingCurve::OutQuint);
109 void setViewCenterTarget (); //! Convenience function, center on selected item
110 QPointF getViewCenterTarget();
111 void setViewCenter (const QPointF &p);
112 QPointF getViewCenter();
113 QPropertyAnimation viewCenterAnimation;
115 void updateMatrix(); //! Sets transformation matrix with current rotation and zoom values
123 void print(); //!< Print the map
124 QRectF getTotalBBox(); //!< Bounding box of all items in map
125 QImage getImage (QPointF &offset); //!< Get a pixmap of the map
126 void setAntiAlias (bool); //!< Set or unset antialiasing
127 void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps
129 void autoLayout(); //!< Auto layout of map by using collision detection
130 void testFunction1(); //! just testing new stuff
131 void testFunction2(); //! just testing new stuff
134 TreeItem *findMapItem (QPointF p,TreeItem *exclude); //! find item in map at position p. Ignore item exclude
136 AttributeTable* attributeTable(); // FIXME-3 Not used, testing only
139 BranchItem* getBranchDirectAbove(BranchItem *bi); //! get branch direct above bi (in TreeView)
140 BranchItem* getBranchAbove(BranchItem *bi); //! get branch above bi (in TreeView)
141 BranchItem* getBranchDirectBelow(BranchItem *bi); //! bet branch direct below bi (in TreeView)
142 BranchItem* getBranchBelow(BranchItem *bi); //! bet branch below bi (in TreeView)
143 BranchItem* getLeftBranch(BranchItem *bi); //! bet branch left of bi (in TreeView)
144 BranchItem* getRightBranch(BranchItem *bi); //! bet branch right of bi (in TreeView)
154 void editHeadingFinished();
159 virtual void contextMenuEvent ( QContextMenuEvent *e );
160 virtual void keyPressEvent(QKeyEvent*);
161 virtual void keyReleaseEvent(QKeyEvent*);
162 virtual void mousePressEvent(QMouseEvent*);
163 virtual void mouseMoveEvent(QMouseEvent*);
165 virtual void mouseReleaseEvent(QMouseEvent*);
166 virtual void mouseDoubleClickEvent(QMouseEvent*);
167 virtual void wheelEvent(QWheelEvent*);
168 virtual void focusOutEvent (QFocusEvent*);
169 virtual void resizeEvent( QResizeEvent * );
171 void dragEnterEvent (QDragEnterEvent *);
172 void dragMoveEvent (QDragMoveEvent *);
173 void dragLeaveEvent (QDragLeaveEvent *);
174 void dropEvent (QDropEvent *);
178 QGraphicsScene *mapScene;
179 VymModel *model; //!< Vym Map, includding several mapCenters
181 bool adjustCanvasRequested; // collect requests until end of user event
182 BranchObj *editingBO; // entering Text into BO
184 QCursor HandOpenCursor; // cursor while moving canvas view
185 QCursor PickColorCursor; // cursor while picking color
186 QCursor CopyCursor; // cursor while picking color
187 QCursor XLinkCursor; // cursor while picking color
190 void setState (EditorState);
191 bool objectMoved; // true if object was not clicked, but moved with mouse
193 // Temporary used for linkx
196 MapObj* movingObj; // moving a MapObj
197 QPointF movingObj_orgPos; // org. pos of mouse before move
198 QPointF movingObj_orgRelPos; // org. relative pos of mouse before move
199 QPointF movingObj_offset; // offset of mousepointer to object
200 QPointF movingCont_start; // inital pos of moving Content or
201 QPointF movingVec; // how far has Content moved
203 QPointF contextMenuPos; // position where context event was triggered
205 AttributeTable *attrTable;
207 bool printFrame; // Print frame around map
208 bool printFooter; // Print footer below map
210 QPoint exportOffset; // set before export, used in save
212 //////////// Selection related
214 void selectionChanged(const QItemSelection &, const QItemSelection &);
217 QList <QGraphicsPathItem*> selPathList;
218 QColor selectionColor;
221 void updateSelection(QItemSelection ,QItemSelection); // update selection
222 void updateData (const QModelIndex&); // update data
224 void setSelectionColor (QColor c);
225 QColor getSelectionColor ();