QGIS API Documentation  2.7.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  void updateSymbology();
53  void updateLabels();
54 
55  signals:
56  void rowsMoved();
57 
58  private:
60  QString mMimeFormat;
61 };
62 
63 // View style which shows drop indicator line between items
64 class QgsGraduatedSymbolRendererV2ViewStyle: public QProxyStyle
65 {
66  public:
67  QgsGraduatedSymbolRendererV2ViewStyle( QStyle* style = 0 );
68 
69  void drawPrimitive( PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const;
70 };
71 
72 class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget, private Ui::QgsGraduatedSymbolRendererV2Widget
73 {
74  Q_OBJECT
75 
76  public:
77  static QgsRendererV2Widget* create( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer );
78 
81 
82  virtual QgsFeatureRendererV2* renderer();
83 
84  public slots:
85  void changeGraduatedSymbol();
86  void graduatedColumnChanged( QString field );
87  void classifyGraduated();
88  void reapplyColorRamp();
89  void rangesDoubleClicked( const QModelIndex & idx );
90  void rangesClicked( const QModelIndex & idx );
91  void changeCurrentValue( QStandardItem * item );
92 
94  void addClass();
96  void deleteClasses();
98  void deleteAllClasses();
100  void toggleBoundariesLink( bool linked );
101 
102  void rotationFieldChanged( QString fldName );
103  void sizeScaleFieldChanged( QString fldName );
104  void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
105  void labelFormatChanged();
106 
107  void showSymbolLevels();
108 
109  void rowsMoved();
110  void modelDataChanged();
111 
112  protected:
113  void updateUiFromRenderer( bool updateCount = true );
114  void connectUpdateHandlers();
115  void disconnectUpdateHandlers();
116  bool rowsOrdered();
117 
118  void updateGraduatedSymbolIcon();
119 
121  QList<int> selectedClasses();
122  QgsRangeList selectedRanges();
123 
124  void changeRangeSymbol( int rangeIdx );
125  void changeRange( int rangeIdx );
126 
127  void changeSelectedSymbols();
128 
129  QList<QgsSymbolV2*> selectedSymbols();
130  QgsSymbolV2* findSymbolForRange( double lowerBound, double upperBound, const QgsRangeList& ranges ) const;
131  void refreshSymbolView();
132 
133  void keyPressEvent( QKeyEvent* event );
134 
135  protected:
137 
139 
141 
143 
145 
147 };
148 
149 
150 #endif // QGSGRADUATEDSYMBOLRENDERERV2WIDGET_H
QList< QgsRendererRangeV2 > QgsRangeList
virtual QList< QgsSymbolV2 * > selectedSymbols()
Subclasses may provide the capability of changing multiple symbols at once by implementing the follow...
static unsigned index
Utility class for providing GUI for data-defined rendering.
void sort(double *heap, int *x, int *y, int N)
Definition: util.cpp:72
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=0) const
Base class for renderer settings widgets.
virtual void refreshSymbolView()
Represents a vector layer which manages a vector based data sets.
virtual QgsFeatureRendererV2 * renderer()=0
return pointer to the renderer (no transfer of ownership)