4 #include <QGraphicsView>
5 #include <QItemSelectionModel>
7 #include <QPropertyAnimation>
11 #include "ornamentedobj.h"
18 /*! \brief Main widget in vym to display and edit a map */
21 class MapEditor : public QGraphicsView {
23 Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor)
24 Q_PROPERTY(QPointF scrollBarPos READ getScrollBarPos WRITE setScrollBarPos)
27 MapEditor(VymModel *vm);
30 QGraphicsScene * getScene();
34 QPointF scrollBarPosTarget;
35 QPropertyAnimation scrollBarPosAnimation;
37 void scrollTo (const QModelIndex &index);
38 void setScrollBarPosTarget (const QRectF &rect); //! ensureVisible of rect
39 QPointF getScrollBarPosTarget ();
40 void setScrollBarPos (const QPointF &p);
41 QPointF getScrollBarPos();
45 qreal zoomFactorTarget;
46 QPropertyAnimation zoomAnimation;
48 void setZoomFactorTarget (const qreal &zf);
49 qreal getZoomFactorTarget();
50 void setZoomFactor (const qreal &zf);
51 qreal getZoomFactor();
54 void print(); //!< Print the map
55 QRectF getTotalBBox(); //!< Bounding box of all items in map
56 QImage getImage (); //!< Get a pixmap of the map
57 void setAntiAlias (bool); //!< Set or unset antialiasing
58 void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps
60 void autoLayout(); //!< Auto layout of map by using collision detection
62 TreeItem *findMapItem (QPointF p,TreeItem *exclude); //! find item in map at position p. Ignore item exclude
64 AttributeTable* attributeTable(); // FIXME-3
65 void testFunction1(); // just testing new stuff
66 void testFunction2(); // just testing new stuff
69 BranchItem* getBranchDirectAbove(BranchItem *bi); //! get branch direct above bi (in TreeView)
70 BranchItem* getBranchAbove(BranchItem *bi); //! get branch above bi (in TreeView)
71 BranchItem* getBranchDirectBelow(BranchItem *bi); //! bet branch direct below bi (in TreeView)
72 BranchItem* getBranchBelow(BranchItem *bi); //! bet branch below bi (in TreeView)
73 BranchItem* getLeftBranch(BranchItem *bi); //! bet branch left of bi (in TreeView)
74 BranchItem* getRightBranch(BranchItem *bi); //! bet branch right of bi (in TreeView)
84 void editHeadingFinished();
90 virtual void contextMenuEvent ( QContextMenuEvent *e );
91 virtual void keyPressEvent(QKeyEvent*);
92 virtual void keyReleaseEvent(QKeyEvent*);
93 virtual void mousePressEvent(QMouseEvent*);
94 virtual void mouseMoveEvent(QMouseEvent*);
95 virtual void mouseReleaseEvent(QMouseEvent*);
96 virtual void mouseDoubleClickEvent(QMouseEvent*);
97 virtual void wheelEvent(QWheelEvent*);
99 virtual void resizeEvent( QResizeEvent * );
101 void dragEnterEvent (QDragEnterEvent *);
102 void dragMoveEvent (QDragMoveEvent *);
103 void dragLeaveEvent (QDragLeaveEvent *);
104 void dropEvent (QDropEvent *);
108 QGraphicsScene *mapScene;
109 VymModel *model; //!< Vym Map, includding several mapCenters
111 bool adjustCanvasRequested; // collect requests until end of user event
112 BranchObj *editingBO; // entering Text into BO
114 QCursor HandOpenCursor; // cursor while moving canvas view
115 QCursor PickColorCursor; // cursor while picking color
116 QCursor CopyCursor; // cursor while picking color
117 QCursor XLinkCursor; // cursor while picking color
119 bool drawingLink; // true while creating a link
120 bool copyingObj; // true while modModeCopy
121 bool objectMoved; // true if object was not clicked, but moved with mouse
124 MapObj* movingObj; // moving a MapObj
125 QPointF movingObj_orgPos; // org. pos of mouse before move
126 QPointF movingObj_orgRelPos; // org. relative pos of mouse before move
127 QPointF movingObj_start; // rel. pos of mouse to absPos
128 QPointF movingCont_start; // inital pos of moving Content or
129 QPointF movingVec; // how far has Content moved
131 QPointF contextMenuPos; // position where context event was triggered
133 QPrinter* printer; // Printing
135 AttributeTable *attrTable;
137 bool printFrame; // Print frame around map
138 bool printFooter; // Print footer below map
140 QPoint exportOffset; // set before export, used in save
142 //////////// Selection related
144 void selectionChanged(const QItemSelection &, const QItemSelection &);
147 QList <QGraphicsRectItem*> selboxList;
148 QColor selectionColor;
151 void updateSelection(QItemSelection ,QItemSelection); // update selection
152 void updateData (const QModelIndex&); // update data
154 void setSelectionColor (QColor c);
155 QColor getSelectionColor ();