QGIS API Documentation  2.11.0-Master
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 
27 {
28  Q_OBJECT
29  public:
31  Qt::ItemFlags flags( const QModelIndex & index ) const override;
32  Qt::DropActions supportedDropActions() const override;
33  QVariant data( const QModelIndex &index, int role ) const override;
34  bool setData( const QModelIndex & index, const QVariant & value, int role ) override;
35  QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
36  int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
37  int columnCount( const QModelIndex & = QModelIndex() ) const override;
38  QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override;
39  QModelIndex parent( const QModelIndex &index ) const override;
40  QStringList mimeTypes() const override;
41  QMimeData *mimeData( const QModelIndexList &indexes ) const override;
42  bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
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 ) override;
52  void updateSymbology( bool resetModel = false );
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
65 {
66  public:
68 
69  void drawPrimitive( PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const override;
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() override;
83 
84  public slots:
85  void changeGraduatedSymbol();
86  void graduatedColumnChanged( QString field );
87  void classifyGraduated();
88  void reapplyColorRamp();
89  void reapplySizes();
90  void rangesDoubleClicked( const QModelIndex & idx );
91  void rangesClicked( const QModelIndex & idx );
92  void changeCurrentValue( QStandardItem * item );
93 
95  void addClass();
97  void deleteClasses();
99  void deleteAllClasses();
101  void toggleBoundariesLink( bool linked );
102 
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  void on_mSizeUnitWidget_changed();
112  void on_methodComboBox_currentIndexChanged( int );
113  void refreshRanges( bool reset = false );
114 
115  protected:
116  void updateUiFromRenderer( bool updateCount = true );
117  void connectUpdateHandlers();
118  void disconnectUpdateHandlers();
119  bool rowsOrdered();
120 
121  void updateGraduatedSymbolIcon();
122 
124  QList<int> selectedClasses();
125  QgsRangeList selectedRanges();
126 
127  void changeRangeSymbol( int rangeIdx );
128  void changeRange( int rangeIdx );
129 
130  void changeSelectedSymbols();
131 
133  QgsSymbolV2* findSymbolForRange( double lowerBound, double upperBound, const QgsRangeList& ranges ) const;
134  void refreshSymbolView() override;
135 
136  void keyPressEvent( QKeyEvent* event ) override;
137 
138  protected:
140 
142 
144 
146 
148 };
149 
150 
151 #endif // QGSGRADUATEDSYMBOLRENDERERV2WIDGET_H
virtual QList< QgsSymbolV2 * > selectedSymbols()
Subclasses may provide the capability of changing multiple symbols at once by implementing the follow...
static unsigned index
virtual int rowCount(const QModelIndex &parent) const =0
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
void create(WId window, bool initializeWindow, bool destroyOldWindow)
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
virtual QStringList mimeTypes() const
virtual void sort(int column, Qt::SortOrder order)
void rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
virtual Qt::DropActions supportedDropActions() const
virtual QVariant data(const QModelIndex &index, int role) const =0
virtual QMimeData * mimeData(const QModelIndexList &indexes) const
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=0) const override
typedef DropActions
virtual int columnCount(const QModelIndex &parent) const =0
virtual void keyPressEvent(QKeyEvent *event)
Base class for renderer settings widgets.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
virtual Qt::ItemFlags flags(const QModelIndex &index) const
virtual void refreshSymbolView()
QObject * parent() const
Represents a vector layer which manages a vector based data sets.
virtual QgsFeatureRendererV2 * renderer()=0
return pointer to the renderer (no transfer of ownership)
typedef ItemFlags