mapeditor.h
author convert-repo
Fri, 23 Jul 2010 16:43:49 +0000
changeset 849 988f1908a7c4
parent 847 43268373032d
permissions -rw-r--r--
update tags
     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 "xlink.h"
    11 #include "ornamentedobj.h"
    12 #include "settings.h"
    13 #include "vymmodel.h"
    14 
    15 
    16 class XLinkItem;
    17 
    18 /*! \brief Main widget in vym to display and edit a map */
    19 
    20 
    21 class MapEditor : public QGraphicsView {	
    22     Q_OBJECT
    23 	Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor)
    24 	Q_PROPERTY(QPointF scrollBarPos READ getScrollBarPos WRITE setScrollBarPos)
    25 
    26 public:
    27     MapEditor(VymModel *vm);
    28 	~MapEditor();
    29 	VymModel* getModel();
    30 	QGraphicsScene * getScene();
    31 
    32 protected:
    33 	QPointF scrollBarPos;
    34 	QPointF scrollBarPosTarget;
    35 	QPropertyAnimation scrollBarPosAnimation;
    36 public:
    37 	void scrollTo (const QModelIndex &index);
    38 	void setScrollBarPosTarget (const QRectF &rect);	//!  ensureVisible of rect
    39 	QPointF getScrollBarPosTarget ();
    40 	void setScrollBarPos (const QPointF &p);
    41 	QPointF getScrollBarPos();
    42 
    43 protected:
    44 	qreal zoomFactor;
    45 	qreal zoomFactorTarget;
    46 	QPropertyAnimation zoomAnimation;
    47 public:
    48 	void setZoomFactorTarget (const qreal &zf);
    49 	qreal getZoomFactorTarget();
    50 	void setZoomFactor (const qreal &zf);
    51 	qreal getZoomFactor();
    52 
    53 public:
    54     void print();				//!< Print the map
    55 	QRectF getTotalBBox();		//!< Bounding box of all items in map
    56 	QImage getImage ();			//!< Get a pixmap of the map
    57 	void setAntiAlias (bool);	//!< Set or unset antialiasing
    58 	void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps
    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 wheelEvent(QWheelEvent*);
    98 
    99     virtual void resizeEvent( QResizeEvent * );
   100 
   101 	void dragEnterEvent (QDragEnterEvent *);
   102 	void dragMoveEvent (QDragMoveEvent *);
   103 	void dragLeaveEvent (QDragLeaveEvent *);
   104 	void dropEvent (QDropEvent *);
   105 
   106 
   107 private:
   108 	QGraphicsScene *mapScene;
   109 	VymModel *model;			//!< Vym Map, includding several mapCenters
   110 
   111 	bool adjustCanvasRequested;	// collect requests until end of user event
   112 	BranchObj *editingBO;		// entering Text into BO
   113 
   114     QCursor HandOpenCursor;		// cursor while moving canvas view
   115 	QCursor PickColorCursor;	// cursor while picking color 
   116 	QCursor CopyCursor;			// cursor while picking color 
   117 	QCursor XLinkCursor;		// cursor while picking color 
   118 	bool pickingColor;
   119 	bool drawingLink;			// true while creating a link
   120 	bool copyingObj;			// true while modModeCopy
   121 	bool objectMoved;			// true if object was not clicked, but moved with mouse
   122 	Link* tmpLink;
   123 
   124 	MapObj* movingObj;				// moving a MapObj
   125     QPointF movingObj_orgPos;		// org. pos of mouse before move
   126     QPointF movingObj_orgRelPos;	// org. relative pos of mouse before move
   127     QPointF movingObj_start;		// rel. pos of mouse to absPos 
   128     QPointF movingCont_start;		// inital pos of moving Content or
   129     QPointF movingVec;				// how far has Content moved
   130 
   131 	QPointF contextMenuPos;			// position where context event was triggered
   132 
   133     QPrinter* printer;				// Printing
   134 
   135 	AttributeTable *attrTable;
   136 
   137 	bool printFrame;			// Print frame around map
   138 	bool printFooter;			// Print footer below map
   139 
   140 	QPoint exportOffset;		// set before export, used in save
   141 
   142 //////////// Selection related
   143 signals:
   144 	void selectionChanged(const QItemSelection &, const QItemSelection &);
   145 
   146 private:	
   147 	QList <QGraphicsRectItem*> selboxList;
   148 	QColor selectionColor;
   149 
   150 public slots:
   151 	void updateSelection(QItemSelection ,QItemSelection); // update selection
   152 	void updateData (const QModelIndex&); // update data
   153 public:
   154 	void setSelectionColor (QColor c);
   155 	QColor getSelectionColor ();
   156 };
   157 #endif
   158