author | insilmaril |
Mon Jul 27 12:53:17 2009 +0000 (2009-07-27) | |
changeset 783 | 85dec6a8c12c |
parent 775 | 6e4b586aa88a |
child 784 | 9db215a4ad53 |
permissions | -rw-r--r-- |
insilmaril@0 | 1 |
#ifndef MAPEDITOR_H |
insilmaril@0 | 2 |
#define MAPEDITOR_H |
insilmaril@0 | 3 |
|
insilmaril@408 | 4 |
#include <QGraphicsView> |
insilmaril@726 | 5 |
#include <QItemSelectionModel> |
insilmaril@0 | 6 |
|
insilmaril@767 | 7 |
#include <QtPropertyAnimation> //! Not yet officially in Qt! |
insilmaril@767 | 8 |
|
insilmaril@616 | 9 |
#include "attribute.h" |
insilmaril@473 | 10 |
#include "ornamentedobj.h" |
insilmaril@366 | 11 |
#include "settings.h" |
insilmaril@645 | 12 |
#include "vymmodel.h" |
insilmaril@775 | 13 |
#include "xlinkobj.h" |
insilmaril@0 | 14 |
|
insilmaril@119 | 15 |
|
insilmaril@486 | 16 |
/*! \brief Main widget in vym to display and edit a map */ |
insilmaril@473 | 17 |
|
insilmaril@767 | 18 |
|
insilmaril@767 | 19 |
class MapEditor : public QGraphicsView { |
insilmaril@0 | 20 |
Q_OBJECT |
insilmaril@767 | 21 |
Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor) |
insilmaril@767 | 22 |
Q_PROPERTY(QPointF scrollBarPos READ getScrollBarPos WRITE setScrollBarPos) |
insilmaril@0 | 23 |
|
insilmaril@0 | 24 |
public: |
insilmaril@720 | 25 |
MapEditor(VymModel *vm); |
insilmaril@0 | 26 |
~MapEditor(); |
insilmaril@645 | 27 |
VymModel* getModel(); |
insilmaril@408 | 28 |
QGraphicsScene * getScene(); |
insilmaril@119 | 29 |
|
insilmaril@767 | 30 |
protected: |
insilmaril@767 | 31 |
QPointF scrollBarPos; |
insilmaril@767 | 32 |
QPointF scrollBarPosTarget; |
insilmaril@767 | 33 |
QtPropertyAnimation scrollBarPosAnimation; |
insilmaril@767 | 34 |
public: |
insilmaril@772 | 35 |
void scrollTo (const QModelIndex &index); |
insilmaril@767 | 36 |
void setScrollBarPosTarget (const QRectF &rect); //! ensureVisible of rect |
insilmaril@767 | 37 |
QPointF getScrollBarPosTarget (); |
insilmaril@767 | 38 |
void setScrollBarPos (const QPointF &p); |
insilmaril@767 | 39 |
QPointF getScrollBarPos(); |
insilmaril@767 | 40 |
|
insilmaril@767 | 41 |
protected: |
insilmaril@767 | 42 |
qreal zoomFactor; |
insilmaril@767 | 43 |
qreal zoomFactorTarget; |
insilmaril@767 | 44 |
QtPropertyAnimation zoomAnimation; |
insilmaril@767 | 45 |
public: |
insilmaril@767 | 46 |
void setZoomFactorTarget (const qreal &zf); |
insilmaril@767 | 47 |
qreal getZoomFactorTarget(); |
insilmaril@767 | 48 |
void setZoomFactor (const qreal &zf); |
insilmaril@767 | 49 |
qreal getZoomFactor(); |
insilmaril@767 | 50 |
|
insilmaril@0 | 51 |
public: |
insilmaril@491 | 52 |
void print(); //!< Print the map |
insilmaril@491 | 53 |
void setAntiAlias (bool); //!< Set or unset antialiasing |
insilmaril@491 | 54 |
void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps |
insilmaril@0 | 55 |
public: |
insilmaril@754 | 56 |
TreeItem *findMapItem (QPointF p,TreeItem *exclude); //! find item in map at position p. Ignore item exclude |
insilmaril@514 | 57 |
|
insilmaril@628 | 58 |
AttributeTable* attributeTable(); |
insilmaril@723 | 59 |
void testFunction1(); // just testing new stuff |
insilmaril@723 | 60 |
void testFunction2(); // just testing new stuff |
insilmaril@0 | 61 |
|
insilmaril@720 | 62 |
public slots: |
insilmaril@769 | 63 |
void cursorUp(); |
insilmaril@769 | 64 |
void cursorDown(); |
insilmaril@769 | 65 |
void cursorLeft(); |
insilmaril@769 | 66 |
void cursorRight(); |
insilmaril@769 | 67 |
void cursorFirst(); |
insilmaril@769 | 68 |
void cursorLast(); |
insilmaril@720 | 69 |
void editHeading(); |
insilmaril@720 | 70 |
void editHeadingFinished(); |
insilmaril@720 | 71 |
private: |
insilmaril@720 | 72 |
bool editingHeading; |
insilmaril@720 | 73 |
QLineEdit *lineEdit; |
insilmaril@720 | 74 |
|
insilmaril@0 | 75 |
protected: |
insilmaril@408 | 76 |
virtual void contextMenuEvent ( QContextMenuEvent *e ); |
insilmaril@398 | 77 |
virtual void keyPressEvent(QKeyEvent*); |
insilmaril@398 | 78 |
virtual void keyReleaseEvent(QKeyEvent*); |
insilmaril@408 | 79 |
virtual void mousePressEvent(QMouseEvent*); |
insilmaril@473 | 80 |
virtual void mouseMoveEvent(QMouseEvent*); |
insilmaril@408 | 81 |
virtual void mouseReleaseEvent(QMouseEvent*); |
insilmaril@408 | 82 |
virtual void mouseDoubleClickEvent(QMouseEvent*); |
insilmaril@473 | 83 |
virtual void resizeEvent( QResizeEvent * ); |
insilmaril@0 | 84 |
|
insilmaril@417 | 85 |
void dragEnterEvent (QDragEnterEvent *); |
insilmaril@417 | 86 |
void dragMoveEvent (QDragMoveEvent *); |
insilmaril@417 | 87 |
void dragLeaveEvent (QDragLeaveEvent *); |
insilmaril@417 | 88 |
void dropEvent (QDropEvent *); |
insilmaril@412 | 89 |
|
insilmaril@473 | 90 |
|
insilmaril@0 | 91 |
private: |
insilmaril@408 | 92 |
QGraphicsScene *mapScene; |
insilmaril@723 | 93 |
VymModel *model; //!< Vym Map, includding several mapCenters |
insilmaril@0 | 94 |
|
insilmaril@0 | 95 |
bool adjustCanvasRequested; // collect requests until end of user event |
insilmaril@0 | 96 |
BranchObj *editingBO; // entering Text into BO |
insilmaril@0 | 97 |
|
insilmaril@398 | 98 |
QCursor HandOpenCursor; // cursor while moving canvas view |
insilmaril@398 | 99 |
QCursor PickColorCursor; // cursor while picking color |
insilmaril@398 | 100 |
QCursor CopyCursor; // cursor while picking color |
insilmaril@398 | 101 |
QCursor XLinkCursor; // cursor while picking color |
insilmaril@83 | 102 |
bool pickingColor; |
insilmaril@83 | 103 |
bool drawingLink; // true while creating a link |
insilmaril@93 | 104 |
bool copyingObj; // true while creating a link |
insilmaril@95 | 105 |
XLinkObj* tmpXLink; |
insilmaril@366 | 106 |
|
insilmaril@720 | 107 |
MapObj* movingObj; // moving a MapObj |
insilmaril@83 | 108 |
MapObj* linkingObj_src; // part of a link |
insilmaril@408 | 109 |
QPointF movingObj_orgPos; // org. pos of mouse before move |
insilmaril@408 | 110 |
QPointF movingObj_orgRelPos; // org. relative pos of mouse before move |
insilmaril@408 | 111 |
QPointF movingObj_start; // rel. pos of mouse to absPos |
insilmaril@408 | 112 |
QPointF movingCont_start; // inital pos of moving Content or |
insilmaril@408 | 113 |
QPointF movingVec; // how far has Content moved |
insilmaril@684 | 114 |
|
insilmaril@720 | 115 |
QPointF contextMenuPos; // position where context event was triggered |
insilmaril@684 | 116 |
|
insilmaril@0 | 117 |
QPrinter* printer; // Printing |
insilmaril@0 | 118 |
|
insilmaril@628 | 119 |
AttributeTable *attrTable; |
insilmaril@628 | 120 |
|
insilmaril@0 | 121 |
bool printFrame; // Print frame around map |
insilmaril@0 | 122 |
bool printFooter; // Print footer below map |
insilmaril@0 | 123 |
|
insilmaril@720 | 124 |
QPoint exportOffset; // set before export, used in save |
insilmaril@0 | 125 |
|
insilmaril@728 | 126 |
//////////// Selection related |
insilmaril@728 | 127 |
signals: |
insilmaril@729 | 128 |
void selectionChanged(const QItemSelection &, const QItemSelection &); |
insilmaril@728 | 129 |
|
insilmaril@726 | 130 |
private: |
insilmaril@728 | 131 |
QList <QGraphicsRectItem*> selboxList; |
insilmaril@728 | 132 |
QColor selectionColor; |
insilmaril@728 | 133 |
|
insilmaril@728 | 134 |
public slots: |
insilmaril@776 | 135 |
void updateSelection(QItemSelection ,QItemSelection); // update selection |
insilmaril@753 | 136 |
void updateData (const QModelIndex&); // update data |
insilmaril@728 | 137 |
public: |
insilmaril@728 | 138 |
void setSelectionColor (QColor c); |
insilmaril@728 | 139 |
QColor getSelectionColor (); |
insilmaril@0 | 140 |
}; |
insilmaril@0 | 141 |
#endif |
insilmaril@0 | 142 |