4 #include <QGraphicsView>
5 #include <QItemSelectionModel>
7 #include <QPropertyAnimation>
9 #include "ornamentedobj.h"
17 /*! \brief Main widget in vym to display and edit a map */
19 class MapEditor : public QGraphicsView {
28 MovingObjectWithoutLinking,
34 MapEditor(VymModel *vm);
37 QGraphicsScene *getScene();
38 MapEditor::EditorState getState();
40 // Animation of scrollbars
41 Q_PROPERTY(QPointF scrollBarPos READ getScrollBarPos WRITE setScrollBarPos)
45 QPointF scrollBarPosTarget;
46 QPropertyAnimation scrollBarPosAnimation;
48 QPointF vPan; //! Direction of panning during moving of object
49 QPoint pointerPos; //! Pointer position in widget coordinates
50 Qt::KeyboardModifiers pointerMod; //! modifiers of move event
56 void ensureAreaVisibleAnimated(const QRectF &area, bool maximizeArea = false);
57 void ensureSelectionVisibleAnimated(bool maximizeArea = false);
58 void scrollTo(const QModelIndex &index);
59 void setScrollBarPosTarget(QRectF rect); //! ensureVisible of rect
60 QPointF getScrollBarPosTarget();
61 void setScrollBarPos(const QPointF &p);
62 QPointF getScrollBarPos();
63 void animateScrollBars();
66 Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor)
70 qreal zoomFactorTarget;
71 QPropertyAnimation zoomAnimation;
74 void setZoomFactorTarget(const qreal &zf);
75 qreal getZoomFactorTarget();
76 void setZoomFactor(const qreal &zf);
77 qreal getZoomFactor();
79 // Animation of rotation
80 Q_PROPERTY(qreal angle READ getAngle WRITE setAngle)
85 QPropertyAnimation rotationAnimation;
88 void setAngleTarget(const qreal &a);
89 qreal getAngleTarget();
90 void setAngle(const qreal &a);
93 // Animation of viewCenter
94 Q_PROPERTY(QPointF viewCenter READ getViewCenter WRITE setViewCenter)
98 QPointF viewCenterTarget;
101 void setViewCenterTarget(
102 const QPointF &p, const qreal &zft, const qreal &at,
103 const int duration = 2000,
104 const QEasingCurve &easingCurve = QEasingCurve::OutQuint);
106 setViewCenterTarget(); //! Convenience function, center on selected item
107 QPointF getViewCenterTarget();
108 void setViewCenter(const QPointF &p);
109 QPointF getViewCenter();
110 QPropertyAnimation viewCenterAnimation;
112 void updateMatrix(); //! Sets transformation matrix with current rotation
121 void print(); //!< Print the map
122 QRectF getTotalBBox(); //!< Bounding box of all items in map
123 QImage getImage(QPointF &offset); //!< Get a pixmap of the map
124 void setAntiAlias(bool); //!< Set or unset antialiasing
125 void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps
127 void autoLayout(); //!< Auto layout of map by using collision detection
128 void testFunction1(); //! just testing new stuff
129 void testFunction2(); //! just testing new stuff
132 TreeItem *findMapItem(QPointF p,
133 TreeItem *exclude); //! find item in map at position
134 //! p. Ignore item exclude
137 BranchItem *getBranchDirectAbove(
138 BranchItem *bi); //! get branch direct above bi (in TreeView)
140 getBranchAbove(BranchItem *bi); //! get branch above bi (in TreeView)
141 BranchItem *getBranchDirectBelow(
142 BranchItem *bi); //! bet branch direct below bi (in TreeView)
144 getBranchBelow(BranchItem *bi); //! bet branch below bi (in TreeView)
146 getLeftBranch(TreeItem *ti); //! bet branch left of bi (in TreeView)
148 getRightBranch(TreeItem *ti); //! bet branch right of bi (in TreeView)
151 enum ToggleDirection {toggleUndefined, toggleUp, toggleDown};
152 ToggleDirection lastToggleDirection;
156 void cursorUpToggleSelection();
158 void cursorDownToggleSelection();
164 void editHeadingFinished();
170 void contextMenuEvent(QContextMenuEvent *e);
171 void keyPressEvent(QKeyEvent *);
172 void keyReleaseEvent(QKeyEvent *);
173 void startMovingView(QMouseEvent *);
174 void mousePressEvent(QMouseEvent *);
175 void mouseMoveEvent(QMouseEvent *);
177 void mouseReleaseEvent(QMouseEvent *);
178 void mouseDoubleClickEvent(QMouseEvent *);
179 void wheelEvent(QWheelEvent *);
180 void focusOutEvent(QFocusEvent *);
181 void resizeEvent(QResizeEvent *);
183 void dragEnterEvent(QDragEnterEvent *);
184 void dragMoveEvent(QDragMoveEvent *);
185 void dragLeaveEvent(QDragLeaveEvent *);
186 void dropEvent(QDropEvent *);
189 QGraphicsScene *mapScene;
190 VymModel *model; //!< Vym Map, includding several mapCenters
192 bool adjustCanvasRequested; // collect requests until end of user event
193 BranchObj *editingBO; // entering Text into BO
195 QCursor HandOpenCursor; // cursor while moving canvas view
196 QCursor PickColorCursor; // cursor while picking color
197 QCursor CopyCursor; // cursor while picking color
198 QCursor XLinkCursor; // cursor while picking color
201 void setState(EditorState);
202 bool objectMoved; // true if object was not clicked, but moved with mouse
204 // Temporary used for linkx
207 MapObj *movingObj; // moving a MapObj
208 QPointF movingObj_orgPos; // org. pos of mouse before move
209 QPointF movingObj_orgRelPos; // org. relative pos of mouse before move
210 QPointF movingObj_offset; // offset of mousepointer to object
211 QPointF movingCont_start; // inital pos of moving Content or
212 QPointF movingVec; // how far has Content moved
214 QPointF contextMenuPos; // position where context event was triggered
216 bool printFrame; // Print frame around map
217 bool printFooter; // Print footer below map
219 QPoint exportOffset; // set before export, used in save
221 //////////// Selection related
223 void selectionChanged(const QItemSelection &, const QItemSelection &);
226 QList<QGraphicsPathItem *> selPathList;
227 QColor selectionColor;
229 QBrush selectionBrush;
232 void updateSelection(QItemSelection, QItemSelection); // update selection
233 void updateData(const QModelIndex &); // update data
234 void togglePresentationMode();
237 void setSelectionPen(const QPen &p);
238 QPen getSelectionPen();
239 void setSelectionBrush(const QBrush &p);
240 QBrush getSelectionBrush();