QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposerview.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerview.h
3  -------------------
4  begin : January 2005
5  copyright : (C) 2005 by Radim Blazek
6  email : [email protected]
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef QGSCOMPOSERVIEW_H
18 #define QGSCOMPOSERVIEW_H
19 
20 #include <QGraphicsView>
22 
23 class QDomDocument;
24 class QDomElement;
25 class QKeyEvent;
26 class QMainWindow;
27 class QMouseEvent;
28 class QgsComposition;
29 class QgsComposerArrow;
30 class QgsComposerItem;
31 class QgsComposerLabel;
32 class QgsComposerLegend;
33 class QgsComposerMap;
34 class QgsComposerPicture;
35 class QgsComposerRuler;
37 class QgsComposerShape;
39 
47 class GUI_EXPORT QgsComposerView: public QGraphicsView
48 {
49  Q_OBJECT
50 
51  public:
52 
54  enum Tool
55  {
56  Select = 0, // Select/Move item
57  AddArrow, //add arrow
59  AddMap, // add new map
60  AddLegend, // add vector legend
61  AddLabel, // add label
62  AddScalebar, // add scalebar
63  AddPicture, // add raster/vector picture
67  AddTable, //add attribute table
68  MoveItemContent, //move content of item (e.g. content of map)
69  Pan,
70  Zoom
71  };
72 
74  {
76  ClipboardModeCopy
77  };
78 
79  enum PasteMode
80  {
83  PasteModeInPlace
84  };
85 
87  {
90  ActiveUntilMouseRelease
91  };
92 
93  QgsComposerView( QWidget* parent = 0, const char* name = 0, Qt::WFlags f = 0 );
94 
96  void groupItems();
97 
99  void ungroupItems();
100 
102  void copyItems( ClipboardMode mode );
103 
105  void pasteItems( PasteMode mode );
106 
108  void deleteSelectedItems();
109 
111  void selectAll();
112 
114  void selectNone();
115 
117  void selectInvert();
118 
119  QgsComposerView::Tool currentTool() const {return mCurrentTool;}
120  void setCurrentTool( QgsComposerView::Tool t );
121 
123  void setComposition( QgsComposition* c );
125  QgsComposition* composition();
126 
128  QMainWindow* composerWindow();
129 
130  void setPaintingEnabled( bool enabled ) { mPaintingEnabled = enabled; }
131  bool paintingEnabled() const { return mPaintingEnabled; }
132 
134  void updateRulers();
135 
136  void setHorizontalRuler( QgsComposerRuler* r ) { mHorizontalRuler = r; }
137  void setVerticalRuler( QgsComposerRuler* r ) { mVerticalRuler = r; }
138 
140  void setZoomLevel( double zoomLevel );
141 
142  protected:
143  void mousePressEvent( QMouseEvent* );
144  void mouseReleaseEvent( QMouseEvent* );
145  void mouseMoveEvent( QMouseEvent* );
146  void mouseDoubleClickEvent( QMouseEvent* e );
147 
148  void keyPressEvent( QKeyEvent * e );
149  void keyReleaseEvent( QKeyEvent * e );
150 
151  void wheelEvent( QWheelEvent* event );
152 
153  void paintEvent( QPaintEvent* event );
154 
155  void hideEvent( QHideEvent* e );
156  void showEvent( QShowEvent* e );
157 
158  void resizeEvent( QResizeEvent* event );
159  void scrollContentsBy( int dx, int dy );
160 
161  private:
166 
168  QGraphicsRectItem* mRubberBandItem;
170  QGraphicsLineItem* mRubberBandLineItem;
177 
184 
186 
189 
191  void addShape( Tool currentTool );
192 
199 
202 
203  QPoint mMouseLastXY;
206 
208  QCursor defaultCursorForTool( Tool currentTool );
209 
211  void wheelZoom( QWheelEvent * event );
213  void updateRubberBand( QPointF & pos );
215  void removeRubberBand();
216 
218  void startMarqueeSelect( QPointF & scenePoint );
220  void endMarqueeSelect( QMouseEvent* e );
222  void startMarqueeZoom( QPointF & scenePoint );
224  void endMarqueeZoom( QMouseEvent* e );
225 
226  //void connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c );
227 
228  signals:
230  void selectedItemChanged( QgsComposerItem* selected );
232  void itemRemoved( QgsComposerItem* );
235  void actionFinished();
237  void cursorPosChanged( QPointF );
239  void zoomLevelChanged();
240 
242  void composerViewShow( QgsComposerView* );
244  void composerViewHide( QgsComposerView* );
245 };
246 
247 #endif