mapeditor.h
author insilmaril
Thu, 18 Mar 2010 11:46:52 +0000
changeset 839 fbb927bbdda3
parent 837 5ecd0462f76b
child 841 46553c106c52
permissions -rw-r--r--
Version bump to 1.13.1 due to first release of 1.13.0 to openSUSE buildservice
     1 #ifndef MAPEDITOR_H
     2 #define MAPEDITOR_H
     3 
     4 #include <QGraphicsView>
     5 #include <QItemSelectionModel>
     6 
     7 #include <QPropertyAnimation>	
     8 
     9 #include "attribute.h"
    10 #include "ornamentedobj.h"
    11 #include "settings.h"
    12 #include "vymmodel.h"
    13 
    14 
    15 class XLinkItem;
    16 
    17 /*! \brief Main widget in vym to display and edit a map */
    18 
    19 
    20 class MapEditor : public QGraphicsView {	
    21     Q_OBJECT
    22 	Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor)
    23 	Q_PROPERTY(QPointF scrollBarPos READ getScrollBarPos WRITE setScrollBarPos)
    24 
    25 public:
    26     MapEditor(VymModel *vm);
    27 	~MapEditor();
    28 	VymModel* getModel();
    29 	QGraphicsScene * getScene();
    30 
    31 protected:
    32 	QPointF scrollBarPos;
    33 	QPointF scrollBarPosTarget;
    34 	QPropertyAnimation scrollBarPosAnimation;
    35 public:
    36 	void scrollTo (const QModelIndex &index);
    37 	void setScrollBarPosTarget (const QRectF &rect);	//!  ensureVisible of rect
    38 	QPointF getScrollBarPosTarget ();
    39 	void setScrollBarPos (const QPointF &p);
    40 	QPointF getScrollBarPos();
    41 
    42 protected:
    43 	qreal zoomFactor;
    44 	qreal zoomFactorTarget;
    45 	QPropertyAnimation zoomAnimation;
    46 public:
    47 	void setZoomFactorTarget (const qreal &zf);
    48 	qreal getZoomFactorTarget();
    49 	void setZoomFactor (const qreal &zf);
    50 	qreal getZoomFactor();
    51 
    52 public:
    53     void print();				//!< Print the map
    54 	QRectF getTotalBBox();		//!< Bounding box of all items in map
    55 	QImage getImage ();			//!< Get a pixmap of the map
    56 	void setAntiAlias (bool);	//!< Set or unset antialiasing
    57 	void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps
    58 	void setHideTmp (bool);		//!< Hide parts temporary
    59 public slots:	
    60 	void autoLayout();			//!< Auto layout of map by using collision detection
    61 public:
    62 	TreeItem *findMapItem (QPointF p,TreeItem *exclude);	//! find item in map at position p. Ignore item exclude 
    63 
    64 	AttributeTable* attributeTable();	// FIXME-3
    65     void testFunction1();				// just testing new stuff
    66     void testFunction2();				// just testing new stuff
    67 
    68 protected:	
    69 	BranchItem* getBranchDirectAbove(BranchItem *bi);	//!  get branch direct above bi (in TreeView) 
    70 	BranchItem* getBranchAbove(BranchItem *bi);			//! get branch above bi (in TreeView) 
    71 	BranchItem* getBranchDirectBelow(BranchItem *bi);	//!  bet branch direct below bi (in TreeView)
    72 	BranchItem* getBranchBelow(BranchItem *bi);			//! bet branch below bi (in TreeView)
    73 	BranchItem* getLeftBranch(BranchItem *bi);			//! bet branch left of bi (in TreeView)
    74 	BranchItem* getRightBranch(BranchItem *bi);			//! bet branch right of bi (in TreeView)
    75 
    76 public slots:
    77 	void cursorUp();
    78 	void cursorDown();
    79 	void cursorLeft();
    80 	void cursorRight();
    81 	void cursorFirst();
    82 	void cursorLast();
    83 	void editHeading();
    84 	void editHeadingFinished();
    85 private:
    86 	bool editingHeading;
    87 	QLineEdit *lineEdit;
    88 
    89 protected:
    90 	virtual void contextMenuEvent ( QContextMenuEvent *e );
    91     virtual void keyPressEvent(QKeyEvent*);
    92     virtual void keyReleaseEvent(QKeyEvent*);
    93     virtual void mousePressEvent(QMouseEvent*);
    94     virtual void mouseMoveEvent(QMouseEvent*);
    95     virtual void mouseReleaseEvent(QMouseEvent*);
    96     virtual void mouseDoubleClickEvent(QMouseEvent*);
    97     virtual void resizeEvent( QResizeEvent * );
    98 
    99 	void dragEnterEvent (QDragEnterEvent *);
   100 	void dragMoveEvent (QDragMoveEvent *);
   101 	void dragLeaveEvent (QDragLeaveEvent *);
   102 	void dropEvent (QDropEvent *);
   103 
   104 
   105 private:
   106 	QGraphicsScene *mapScene;
   107 	VymModel *model;			//!< Vym Map, includding several mapCenters
   108 
   109 	bool adjustCanvasRequested;	// collect requests until end of user event
   110 	BranchObj *editingBO;		// entering Text into BO
   111 
   112     QCursor HandOpenCursor;		// cursor while moving canvas view
   113 	QCursor PickColorCursor;	// cursor while picking color 
   114 	QCursor CopyCursor;			// cursor while picking color 
   115 	QCursor XLinkCursor;		// cursor while picking color 
   116 	bool pickingColor;
   117 	bool drawingLink;			// true while creating a link
   118 	bool copyingObj;			// true while modModeCopy
   119 	bool objectMoved;			// true if object was not clicked, but moved with mouse
   120 	XLinkItem* tmpXLink;
   121 
   122 	MapObj* movingObj;				// moving a MapObj
   123     QPointF movingObj_orgPos;		// org. pos of mouse before move
   124     QPointF movingObj_orgRelPos;	// org. relative pos of mouse before move
   125     QPointF movingObj_start;		// rel. pos of mouse to absPos 
   126     QPointF movingCont_start;		// inital pos of moving Content or
   127     QPointF movingVec;				// how far has Content moved
   128 
   129 	QPointF contextMenuPos;			// position where context event was triggered
   130 
   131     QPrinter* printer;				// Printing
   132 
   133 	AttributeTable *attrTable;
   134 
   135 	bool printFrame;			// Print frame around map
   136 	bool printFooter;			// Print footer below map
   137 
   138 	QPoint exportOffset;		// set before export, used in save
   139 
   140 //////////// Selection related
   141 signals:
   142 	void selectionChanged(const QItemSelection &, const QItemSelection &);
   143 
   144 private:	
   145 	QList <QGraphicsRectItem*> selboxList;
   146 	QColor selectionColor;
   147 
   148 public slots:
   149 	void updateSelection(QItemSelection ,QItemSelection); // update selection
   150 	void updateData (const QModelIndex&); // update data
   151 public:
   152 	void setSelectionColor (QColor c);
   153 	QColor getSelectionColor ();
   154 };
   155 #endif
   156