~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/gui/qgscomposerview.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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>
 
22
 
 
23
class QKeyEvent;
 
24
class QMainWindow;
 
25
class QMouseEvent;
 
26
class QgsComposition;
 
27
class QgsComposerArrow;
 
28
class QgsComposerItem;
 
29
class QgsComposerLabel;
 
30
class QgsComposerLegend;
 
31
class QgsComposerMap;
 
32
class QgsComposerPicture;
 
33
class QgsComposerScaleBar;
 
34
class QgsComposerShape;
 
35
 
 
36
/** \ingroup MapComposer
 
37
 * \ingroup gui
 
38
 * Widget to display the composer items. Manages the composer tools and the
 
39
 * mouse/key events.
 
40
 * Creates the composer items according to the current map tools and keeps track
 
41
 * of the rubber band item.
 
42
 */
 
43
class GUI_EXPORT QgsComposerView: public QGraphicsView
 
44
{
 
45
    Q_OBJECT
 
46
 
 
47
  public:
 
48
 
 
49
    /**Current tool*/
 
50
    enum Tool
 
51
    {
 
52
      Select = 0,      // Select/Move item
 
53
      AddArrow,         //add arrow
 
54
      AddMap,          // add new map
 
55
      AddLegend, // add vector legend
 
56
      AddLabel,        // add label
 
57
      AddScalebar,     // add scalebar
 
58
      AddPicture,       // add raster/vector picture
 
59
      AddShape, //add shape item (ellipse, rectangle, triangle)
 
60
      MoveItemContent //move content of item (e.g. content of map)
 
61
    };
 
62
 
 
63
    QgsComposerView( QWidget* parent = 0, const char* name = 0, Qt::WFlags f = 0 );
 
64
 
 
65
    /**Add an item group containing the selected items*/
 
66
    void groupItems();
 
67
 
 
68
    /**Ungroups the selected items*/
 
69
    void ungroupItems();
 
70
 
 
71
    QgsComposerView::Tool currentTool() const {return mCurrentTool;}
 
72
    void setCurrentTool( QgsComposerView::Tool t ) {mCurrentTool = t;}
 
73
 
 
74
    /**Sets composition (derived from QGraphicsScene)*/
 
75
    void setComposition( QgsComposition* c );
 
76
    /**Returns the composition or 0 in case of error*/
 
77
    QgsComposition* composition();
 
78
 
 
79
    /**Adds an arrow item to the graphics scene and advices composer to create a widget for it (through signal)*/
 
80
    void addComposerArrow( QgsComposerArrow* arrow );
 
81
    /**Adds label to the graphics scene and advices composer to create a widget for it (through signal)*/
 
82
    void addComposerLabel( QgsComposerLabel* label );
 
83
    /**Adds map to the graphics scene and advices composer to create a widget for it (through signal)*/
 
84
    void addComposerMap( QgsComposerMap* map );
 
85
    /**Adds scale bar to the graphics scene and advices composer to create a widget for it (through signal)*/
 
86
    void addComposerScaleBar( QgsComposerScaleBar* scaleBar );
 
87
    /**Adds legend to the graphics scene and advices composer to create a widget for it (through signal)*/
 
88
    void addComposerLegend( QgsComposerLegend* legend );
 
89
    /**Adds picture to the graphics scene and advices composer to create a widget for it (through signal)*/
 
90
    void addComposerPicture( QgsComposerPicture* picture );
 
91
    /**Adds a composer shape to the graphics scene and acvices composer to create a widget for it (through signal)*/
 
92
    void addComposerShape( QgsComposerShape* shape );
 
93
 
 
94
    /**Returns the composer main window*/
 
95
    QMainWindow* composerWindow();
 
96
 
 
97
  protected:
 
98
    void mousePressEvent( QMouseEvent* );
 
99
    void mouseReleaseEvent( QMouseEvent* );
 
100
    void mouseMoveEvent( QMouseEvent* );
 
101
 
 
102
    void keyPressEvent( QKeyEvent * e );
 
103
    void keyReleaseEvent( QKeyEvent * e );
 
104
 
 
105
    void wheelEvent( QWheelEvent* event );
 
106
 
 
107
  private:
 
108
    /**Status of shift key (used for multiple selection)*/
 
109
    bool mShiftKeyPressed;
 
110
    /**Current composer tool*/
 
111
    QgsComposerView::Tool mCurrentTool;
 
112
    /**Rubber band item*/
 
113
    QGraphicsRectItem* mRubberBandItem;
 
114
    /**Rubber band item for arrows*/
 
115
    QGraphicsLineItem* mRubberBandLineItem;
 
116
    /**Item to move content*/
 
117
    QgsComposerItem* mMoveContentItem;
 
118
    /**Start position of content move*/
 
119
    QPointF mMoveContentStartPos;
 
120
    /**Start of rubber band creation*/
 
121
    QPointF mRubberBandStartPos;
 
122
 
 
123
  public slots:
 
124
    /**For QgsComposerItemGroup to send its signals to QgsComposer (or other classes that keep track of input widgets)*/
 
125
    void sendItemRemovedSignal( QgsComposerItem* item );
 
126
 
 
127
  signals:
 
128
    /**Is emitted when selected item changed. If 0, no item is selected*/
 
129
    void selectedItemChanged( const QgsComposerItem* selected );
 
130
    /**Is emitted when new composer arrow has been added to the view*/
 
131
    void composerArrowAdded( QgsComposerArrow* arrow );
 
132
    /**Is emitted when new composer label has been added to the view*/
 
133
    void composerLabelAdded( QgsComposerLabel* label );
 
134
    /**Is emitted when new composer map has been added to the view*/
 
135
    void composerMapAdded( QgsComposerMap* map );
 
136
    /**Is emitted when new composer scale bar has been added*/
 
137
    void composerScaleBarAdded( QgsComposerScaleBar* scalebar );
 
138
    /**Is emitted when a new composer legend has been added*/
 
139
    void composerLegendAdded( QgsComposerLegend* legend );
 
140
    /**Is emitted when a new composer picture has been added*/
 
141
    void composerPictureAdded( QgsComposerPicture* picture );
 
142
    /**Is emitted when a new composer shape has been added*/
 
143
    void composerShapeAdded( QgsComposerShape* shape );
 
144
    /**Is emitted when a composer item has been removed from the scene*/
 
145
    void itemRemoved( QgsComposerItem* );
 
146
    /**Current action (e.g. adding composer map) has been finished. The purpose of this signal is that
 
147
     QgsComposer may set the selection tool again*/
 
148
    void actionFinished();
 
149
};
 
150
 
 
151
#endif