Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 : blazek@itc.it
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 /* $Id$ */
18 #ifndef QGSCOMPOSERVIEW_H
19 #define QGSCOMPOSERVIEW_H
20 
21 #include <QGraphicsView>
23 
24 class QKeyEvent;
25 class QMainWindow;
26 class QMouseEvent;
27 class QgsComposition;
28 class QgsComposerArrow;
29 class QgsComposerItem;
30 class QgsComposerLabel;
31 class QgsComposerLegend;
32 class QgsComposerMap;
33 class QgsComposerPicture;
35 class QgsComposerShape;
37 
45 class GUI_EXPORT QgsComposerView: public QGraphicsView
46 {
47  Q_OBJECT
48 
49  public:
50 
52  enum Tool
53  {
54  Select = 0, // Select/Move item
55  AddArrow, //add arrow
56  AddMap, // add new map
57  AddLegend, // add vector legend
58  AddLabel, // add label
59  AddScalebar, // add scalebar
60  AddPicture, // add raster/vector picture
61  AddShape, //add shape item (ellipse, rectangle, triangle)
62  AddTable, //add attribute table
63  MoveItemContent //move content of item (e.g. content of map)
64  };
65 
66  QgsComposerView( QWidget* parent = 0, const char* name = 0, Qt::WFlags f = 0 );
67 
69  void groupItems();
70 
72  void ungroupItems();
73 
74  QgsComposerView::Tool currentTool() const {return mCurrentTool;}
75  void setCurrentTool( QgsComposerView::Tool t ) {mCurrentTool = t;}
76 
78  void setComposition( QgsComposition* c );
80  QgsComposition* composition();
81 
83  void addComposerArrow( QgsComposerArrow* arrow );
85  void addComposerLabel( QgsComposerLabel* label );
87  void addComposerMap( QgsComposerMap* map );
89  void addComposerScaleBar( QgsComposerScaleBar* scaleBar );
91  void addComposerLegend( QgsComposerLegend* legend );
93  void addComposerPicture( QgsComposerPicture* picture );
95  void addComposerShape( QgsComposerShape* shape );
97  void addComposerTable( QgsComposerAttributeTable* table );
98 
100  QMainWindow* composerWindow();
101 
102  void setPaintingEnabled( bool enabled ) { mPaintingEnabled = enabled; }
103  bool paintingEnabled() const { return mPaintingEnabled; }
104 
106  void pushAddRemoveCommand( QgsComposerItem* item, const QString& text, QgsAddRemoveItemCommand::State state = QgsAddRemoveItemCommand::Added );
107 
108  protected:
109  void mousePressEvent( QMouseEvent* );
110  void mouseReleaseEvent( QMouseEvent* );
111  void mouseMoveEvent( QMouseEvent* );
112  void mouseDoubleClickEvent( QMouseEvent* e );
113 
114  void keyPressEvent( QKeyEvent * e );
115  void keyReleaseEvent( QKeyEvent * e );
116 
117  void wheelEvent( QWheelEvent* event );
118 
119  void paintEvent( QPaintEvent* event );
120 
121 
122  private:
128  QGraphicsRectItem* mRubberBandItem;
130  QGraphicsLineItem* mRubberBandLineItem;
137 
139 
140  void connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c );
141 
142 
143  public slots:
145  void sendItemAddedSignal( QgsComposerItem* item );
146 
147  signals:
149  void selectedItemChanged( QgsComposerItem* selected );
151  void composerArrowAdded( QgsComposerArrow* arrow );
153  void composerLabelAdded( QgsComposerLabel* label );
155  void composerMapAdded( QgsComposerMap* map );
157  void composerScaleBarAdded( QgsComposerScaleBar* scalebar );
159  void composerLegendAdded( QgsComposerLegend* legend );
161  void composerPictureAdded( QgsComposerPicture* picture );
163  void composerShapeAdded( QgsComposerShape* shape );
165  void composerTableAdded( QgsComposerAttributeTable* table );
167  void itemRemoved( QgsComposerItem* );
170  void actionFinished();
171 };
172 
173 #endif