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