4 #include <QGraphicsView>
5 #include <QItemSelectionModel>
7 #include <QtPropertyAnimation> //! Not yet officially in Qt!
10 #include "ornamentedobj.h"
15 /*! \brief Main widget in vym to display and edit a map */
18 class MapEditor : public QGraphicsView {
20 Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor)
21 Q_PROPERTY(QPointF scrollBarPos READ getScrollBarPos WRITE setScrollBarPos)
24 MapEditor(VymModel *vm);
27 QGraphicsScene * getScene();
31 QPointF scrollBarPosTarget;
32 QtPropertyAnimation scrollBarPosAnimation;
34 void scrollTo (const QModelIndex &index);
35 void setScrollBarPosTarget (const QRectF &rect); //! ensureVisible of rect
36 QPointF getScrollBarPosTarget ();
37 void setScrollBarPos (const QPointF &p);
38 QPointF getScrollBarPos();
42 qreal zoomFactorTarget;
43 QtPropertyAnimation zoomAnimation;
45 void setZoomFactorTarget (const qreal &zf);
46 qreal getZoomFactorTarget();
47 void setZoomFactor (const qreal &zf);
48 qreal getZoomFactor();
51 void print(); //!< Print the map
52 void setAntiAlias (bool); //!< Set or unset antialiasing
53 void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps
55 TreeItem *findMapItem (QPointF p,TreeItem *exclude); //! find item in map at position p. Ignore item exclude
57 AttributeTable* attributeTable();
58 void testFunction1(); // just testing new stuff
59 void testFunction2(); // just testing new stuff
69 void editHeadingFinished();
75 virtual void contextMenuEvent ( QContextMenuEvent *e );
76 virtual void keyPressEvent(QKeyEvent*);
77 virtual void keyReleaseEvent(QKeyEvent*);
78 virtual void mousePressEvent(QMouseEvent*);
79 virtual void mouseMoveEvent(QMouseEvent*);
80 virtual void mouseReleaseEvent(QMouseEvent*);
81 virtual void mouseDoubleClickEvent(QMouseEvent*);
82 virtual void resizeEvent( QResizeEvent * );
84 void dragEnterEvent (QDragEnterEvent *);
85 void dragMoveEvent (QDragMoveEvent *);
86 void dragLeaveEvent (QDragLeaveEvent *);
87 void dropEvent (QDropEvent *);
91 QGraphicsScene *mapScene;
92 VymModel *model; //!< Vym Map, includding several mapCenters
94 bool adjustCanvasRequested; // collect requests until end of user event
95 BranchObj *editingBO; // entering Text into BO
97 QCursor HandOpenCursor; // cursor while moving canvas view
98 QCursor PickColorCursor; // cursor while picking color
99 QCursor CopyCursor; // cursor while picking color
100 QCursor XLinkCursor; // cursor while picking color
102 bool drawingLink; // true while creating a link
103 bool copyingObj; // true while creating a link
106 MapObj* movingObj; // moving a MapObj
107 MapObj* linkingObj_src; // part of a link
108 QPointF movingObj_orgPos; // org. pos of mouse before move
109 QPointF movingObj_orgRelPos; // org. relative pos of mouse before move
110 QPointF movingObj_start; // rel. pos of mouse to absPos
111 QPointF movingCont_start; // inital pos of moving Content or
112 QPointF movingVec; // how far has Content moved
114 QPointF contextMenuPos; // position where context event was triggered
116 QPrinter* printer; // Printing
118 AttributeTable *attrTable;
120 bool printFrame; // Print frame around map
121 bool printFooter; // Print footer below map
123 QPoint exportOffset; // set before export, used in save
125 //////////// Selection related
127 void selectionChanged(const QItemSelection &, const QItemSelection &);
130 QList <QGraphicsRectItem*> selboxList;
131 QColor selectionColor;
134 void updateSelection(const QItemSelection &,const QItemSelection &); // update selection
135 void updateData (const QModelIndex&); // update data
137 void setSelectionColor (QColor c);
138 QColor getSelectionColor ();