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