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