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