mapeditor.h
author insilmaril
Mon, 27 Jul 2009 12:53:17 +0000
changeset 784 9db215a4ad53
parent 776 25e634a7e1dc
child 787 c6bb4fdcc55f
permissions -rw-r--r--
Playing with dbus, fixed name of TW translation file
     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 	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
    57 public:
    58 	TreeItem *findMapItem (QPointF p,TreeItem *exclude);	//! find item in map at position p. Ignore item exclude 
    59 
    60 	AttributeTable* attributeTable();	// FIXME-3
    61     void testFunction1();				// just testing new stuff
    62     void testFunction2();				// just testing new stuff
    63 
    64 public slots:
    65 	void cursorUp();
    66 	void cursorDown();
    67 	void cursorLeft();
    68 	void cursorRight();
    69 	void cursorFirst();
    70 	void cursorLast();
    71 	void editHeading();
    72 	void editHeadingFinished();
    73 private:
    74 	bool editingHeading;
    75 	QLineEdit *lineEdit;
    76 
    77 protected:
    78 	virtual void contextMenuEvent ( QContextMenuEvent *e );
    79     virtual void keyPressEvent(QKeyEvent*);
    80     virtual void keyReleaseEvent(QKeyEvent*);
    81     virtual void mousePressEvent(QMouseEvent*);
    82     virtual void mouseMoveEvent(QMouseEvent*);
    83     virtual void mouseReleaseEvent(QMouseEvent*);
    84     virtual void mouseDoubleClickEvent(QMouseEvent*);
    85     virtual void resizeEvent( QResizeEvent * );
    86 
    87 	void dragEnterEvent (QDragEnterEvent *);
    88 	void dragMoveEvent (QDragMoveEvent *);
    89 	void dragLeaveEvent (QDragLeaveEvent *);
    90 	void dropEvent (QDropEvent *);
    91 
    92 
    93 private:
    94 	QGraphicsScene *mapScene;
    95 	VymModel *model;			//!< Vym Map, includding several mapCenters
    96 
    97 	bool adjustCanvasRequested;	// collect requests until end of user event
    98 	BranchObj *editingBO;		// entering Text into BO
    99 
   100     QCursor HandOpenCursor;		// cursor while moving canvas view
   101 	QCursor PickColorCursor;	// cursor while picking color 
   102 	QCursor CopyCursor;			// cursor while picking color 
   103 	QCursor XLinkCursor;		// cursor while picking color 
   104 	bool pickingColor;
   105 	bool drawingLink;			// true while creating a link
   106 	bool copyingObj;			// true while creating a link
   107 	XLinkObj* tmpXLink;
   108 
   109 	MapObj* movingObj;				// moving a MapObj
   110 	MapObj* linkingObj_src;			// part of a link
   111     QPointF movingObj_orgPos;		// org. pos of mouse before move
   112     QPointF movingObj_orgRelPos;	// org. relative pos of mouse before move
   113     QPointF movingObj_start;		// rel. pos of mouse to absPos 
   114     QPointF movingCont_start;		// inital pos of moving Content or
   115     QPointF movingVec;				// how far has Content moved
   116 
   117 	QPointF contextMenuPos;			// position where context event was triggered
   118 
   119     QPrinter* printer;				// Printing
   120 
   121 	AttributeTable *attrTable;
   122 
   123 	bool printFrame;			// Print frame around map
   124 	bool printFooter;			// Print footer below map
   125 
   126 	QPoint exportOffset;		// set before export, used in save
   127 
   128 //////////// Selection related
   129 signals:
   130 	void selectionChanged(const QItemSelection &, const QItemSelection &);
   131 
   132 private:	
   133 	QList <QGraphicsRectItem*> selboxList;
   134 	QColor selectionColor;
   135 
   136 public slots:
   137 	void updateSelection(QItemSelection ,QItemSelection); // update selection
   138 	void updateData (const QModelIndex&); // update data
   139 public:
   140 	void setSelectionColor (QColor c);
   141 	QColor getSelectionColor ();
   142 };
   143 #endif
   144