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 QRectF getTotalBBox(); //!< Bounding box of all items in map
54 QPixmap getPixmap(); //!< Get a pixmap of the map
55 void setAntiAlias (bool); //!< Set or unset antialiasing
56 void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps
58 TreeItem *findMapItem (QPointF p,TreeItem *exclude); //! find item in map at position p. Ignore item exclude
60 AttributeTable* attributeTable(); // FIXME-3
61 void testFunction1(); // just testing new stuff
62 void testFunction2(); // just testing new stuff
65 BranchItem* getBranchDirectAbove(BranchItem *bi); //! get branch direct above bi (in TreeView)
66 BranchItem* getBranchAbove(BranchItem *bi); //! get branch above bi (in TreeView)
67 BranchItem* getBranchDirectBelow(BranchItem *bi); //! bet branch direct below bi (in TreeView)
68 BranchItem* getBranchBelow(BranchItem *bi); //! bet branch below bi (in TreeView)
69 BranchItem* getLeftBranch(BranchItem *bi); //! bet branch left of bi (in TreeView)
70 BranchItem* getRightBranch(BranchItem *bi); //! bet branch right of bi (in TreeView)
80 void editHeadingFinished();
86 virtual void contextMenuEvent ( QContextMenuEvent *e );
87 virtual void keyPressEvent(QKeyEvent*);
88 virtual void keyReleaseEvent(QKeyEvent*);
89 virtual void mousePressEvent(QMouseEvent*);
90 virtual void mouseMoveEvent(QMouseEvent*);
91 virtual void mouseReleaseEvent(QMouseEvent*);
92 virtual void mouseDoubleClickEvent(QMouseEvent*);
93 virtual void resizeEvent( QResizeEvent * );
95 void dragEnterEvent (QDragEnterEvent *);
96 void dragMoveEvent (QDragMoveEvent *);
97 void dragLeaveEvent (QDragLeaveEvent *);
98 void dropEvent (QDropEvent *);
102 QGraphicsScene *mapScene;
103 VymModel *model; //!< Vym Map, includding several mapCenters
105 bool adjustCanvasRequested; // collect requests until end of user event
106 BranchObj *editingBO; // entering Text into BO
108 QCursor HandOpenCursor; // cursor while moving canvas view
109 QCursor PickColorCursor; // cursor while picking color
110 QCursor CopyCursor; // cursor while picking color
111 QCursor XLinkCursor; // cursor while picking color
113 bool drawingLink; // true while creating a link
114 bool copyingObj; // true while creating a link
117 MapObj* movingObj; // moving a MapObj
118 MapObj* linkingObj_src; // part of a link
119 QPointF movingObj_orgPos; // org. pos of mouse before move
120 QPointF movingObj_orgRelPos; // org. relative pos of mouse before move
121 QPointF movingObj_start; // rel. pos of mouse to absPos
122 QPointF movingCont_start; // inital pos of moving Content or
123 QPointF movingVec; // how far has Content moved
125 QPointF contextMenuPos; // position where context event was triggered
127 QPrinter* printer; // Printing
129 AttributeTable *attrTable;
131 bool printFrame; // Print frame around map
132 bool printFooter; // Print footer below map
134 QPoint exportOffset; // set before export, used in save
136 //////////// Selection related
138 void selectionChanged(const QItemSelection &, const QItemSelection &);
141 QList <QGraphicsRectItem*> selboxList;
142 QColor selectionColor;
145 void updateSelection(QItemSelection ,QItemSelection); // update selection
146 void updateData (const QModelIndex&); // update data
148 void setSelectionColor (QColor c);
149 QColor getSelectionColor ();