QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgsgraduatedsymbolrendererv2widget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgraduatedsymbolrendererv2widget.h
3  ---------------------
4  begin : December 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSGRADUATEDSYMBOLRENDERERV2WIDGET_H
17 #define QGSGRADUATEDSYMBOLRENDERERV2WIDGET_H
18 
20 #include "qgsrendererv2widget.h"
21 #include <QStandardItem>
22 #include <QProxyStyle>
23 
24 #include "ui_qgsgraduatedsymbolrendererv2widget.h"
25 
26 class GUI_EXPORT QgsGraduatedSymbolRendererV2Model : public QAbstractItemModel
27 {
28  Q_OBJECT
29  public:
30  QgsGraduatedSymbolRendererV2Model( QObject * parent = 0 );
31  Qt::ItemFlags flags( const QModelIndex & index ) const;
32  Qt::DropActions supportedDropActions() const;
33  QVariant data( const QModelIndex &index, int role ) const;
34  bool setData( const QModelIndex & index, const QVariant & value, int role );
35  QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
36  int rowCount( const QModelIndex &parent = QModelIndex() ) const;
37  int columnCount( const QModelIndex & = QModelIndex() ) const;
38  QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
39  QModelIndex parent( const QModelIndex &index ) const;
40  QStringList mimeTypes() const;
41  QMimeData *mimeData( const QModelIndexList &indexes ) const;
42  bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent );
43 
44  void setRenderer( QgsGraduatedSymbolRendererV2* renderer );
45 
46  QgsRendererRangeV2 rendererRange( const QModelIndex &index );
47  void addClass( QgsSymbolV2* symbol );
48  void addClass( QgsRendererRangeV2 range );
49  void deleteRows( QList<int> rows );
50  void removeAllRows( );
51  void sort( int column, Qt::SortOrder order = Qt::AscendingOrder );
52 
53  signals:
54  void rowsMoved();
55 
56  private:
58  QString mMimeFormat;
59 };
60 
61 // View style which shows drop indicator line between items
62 class QgsGraduatedSymbolRendererV2ViewStyle: public QProxyStyle
63 {
64  public:
65  QgsGraduatedSymbolRendererV2ViewStyle( QStyle* style = 0 );
66 
67  void drawPrimitive( PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const;
68 };
69 
70 class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget, private Ui::QgsGraduatedSymbolRendererV2Widget
71 {
72  Q_OBJECT
73 
74  public:
75  static QgsRendererV2Widget* create( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer );
76 
79 
80  virtual QgsFeatureRendererV2* renderer();
81 
82  public slots:
83  void changeGraduatedSymbol();
84  void graduatedColumnChanged( QString field );
85  void classifyGraduated();
86  void reapplyColorRamp();
87  void rangesDoubleClicked( const QModelIndex & idx );
88  void rangesClicked( const QModelIndex & idx );
89  void changeCurrentValue( QStandardItem * item );
90 
92  void addClass();
94  void deleteClasses();
96  void deleteAllClasses();
98  void toggleBoundariesLink( bool linked );
99 
100  void rotationFieldChanged( QString fldName );
101  void sizeScaleFieldChanged( QString fldName );
102  void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
103 
104  void showSymbolLevels();
105 
106  void rowsMoved();
107 
108  protected:
109  void updateUiFromRenderer();
110 
111  void updateGraduatedSymbolIcon();
112 
114  QList<int> selectedClasses();
115  QgsRangeList selectedRanges();
116 
117  void changeRangeSymbol( int rangeIdx );
118  void changeRange( int rangeIdx );
119 
120  QString createLabel( double lowerValue, double upperValue );
121 
122  void changeSelectedSymbols();
123 
124  QList<QgsSymbolV2*> selectedSymbols();
125  QgsSymbolV2* findSymbolForRange( double lowerBound, double upperBound, const QgsRangeList& ranges ) const;
126  void refreshSymbolView();
127 
128  void keyPressEvent( QKeyEvent* event );
129 
130  protected:
132 
134 
136 
138 
140 
142 };
143 
144 
145 #endif // QGSGRADUATEDSYMBOLRENDERERV2WIDGET_H
Definition: qgsgraduatedsymbolrendererv2widget.h:70
QList< QgsRendererRangeV2 > QgsRangeList
Definition: qgsgraduatedsymbolrendererv2.h:63
virtual QList< QgsSymbolV2 * > selectedSymbols()
Subclasses may provide the capability of changing multiple symbols at once by implementing the follow...
Definition: qgsrendererv2widget.h:61
static unsigned index
Definition: mersenne-twister.cpp:36
QgsRangeList mCopyBuffer
Definition: qgsgraduatedsymbolrendererv2widget.h:141
QgsGraduatedSymbolRendererV2ViewStyle(QStyle *style=0)
Definition: qgsgraduatedsymbolrendererv2widget.cpp:334
QgsSymbolV2 * mGraduatedSymbol
Definition: qgsgraduatedsymbolrendererv2widget.h:133
Definition: qgsgraduatedsymbolrendererv2.h:68
QgsRendererV2DataDefinedMenus * mDataDefinedMenus
Definition: qgsgraduatedsymbolrendererv2widget.h:137
Utility class for providing GUI for data-defined rendering.
Definition: qgsrendererv2widget.h:95
Definition: qgsgraduatedsymbolrendererv2.h:23
Definition: qgssymbolv2.h:43
void sort(double *heap, int *x, int *y, int N)
Definition: util.cpp:72
QgsGraduatedSymbolRendererV2 * mRenderer
Definition: qgsgraduatedsymbolrendererv2widget.h:131
Definition: qgsstylev2.h:66
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=0) const
Definition: qgsgraduatedsymbolrendererv2widget.cpp:338
ScaleMethod
Definition: qgssymbolv2.h:61
int mRowSelected
Definition: qgsgraduatedsymbolrendererv2widget.h:135
Base class for renderer settings widgets.
Definition: qgsrendererv2widget.h:38
Definition: qgsrendererv2.h:72
virtual void refreshSymbolView()
Definition: qgsrendererv2widget.h:62
Definition: qgsgraduatedsymbolrendererv2widget.h:62
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:470
virtual QgsFeatureRendererV2 * renderer()=0
return pointer to the renderer (no transfer of ownership)
Definition: qgsgraduatedsymbolrendererv2widget.h:26
QgsGraduatedSymbolRendererV2Model * mModel
Definition: qgsgraduatedsymbolrendererv2widget.h:139