QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 class GUI_EXPORT QgsGraduatedSymbolRendererV2Model : public QAbstractItemModel
29 {
30  Q_OBJECT
31  public:
32  QgsGraduatedSymbolRendererV2Model( QObject * parent = nullptr );
33  Qt::ItemFlags flags( const QModelIndex & index ) const override;
34  Qt::DropActions supportedDropActions() const override;
35  QVariant data( const QModelIndex &index, int role ) const override;
36  bool setData( const QModelIndex & index, const QVariant & value, int role ) override;
37  QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
38  int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
39  int columnCount( const QModelIndex & = QModelIndex() ) const override;
40  QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override;
41  QModelIndex parent( const QModelIndex &index ) const override;
42  QStringList mimeTypes() const override;
43  QMimeData *mimeData( const QModelIndexList &indexes ) const override;
44  bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
45 
46  void setRenderer( QgsGraduatedSymbolRendererV2* renderer );
47 
48  QgsRendererRangeV2 rendererRange( const QModelIndex &index );
49  void addClass( QgsSymbolV2* symbol );
50  void addClass( const QgsRendererRangeV2& range );
51  void deleteRows( QList<int> rows );
52  void removeAllRows();
53  void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override;
54  void updateSymbology( bool resetModel = false );
55  void updateLabels();
56 
57  signals:
58  void rowsMoved();
59 
60  private:
62  QString mMimeFormat;
63 };
64 
65 // View style which shows drop indicator line between items
66 class QgsGraduatedSymbolRendererV2ViewStyle: public QProxyStyle
67 {
68  Q_OBJECT
69 
70  public:
71  explicit QgsGraduatedSymbolRendererV2ViewStyle( QStyle* style = nullptr );
72 
73  void drawPrimitive( PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = nullptr ) const override;
74 };
75 
77 
81 class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget, private Ui::QgsGraduatedSymbolRendererV2Widget
82 {
83  Q_OBJECT
84 
85  public:
86  static QgsRendererV2Widget* create( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer );
87 
90 
91  virtual QgsFeatureRendererV2* renderer() override;
92 
93  public slots:
94  void changeGraduatedSymbol();
95  void graduatedColumnChanged( const QString& field );
96  void classifyGraduated();
97  void reapplyColorRamp();
98  void reapplySizes();
99  void rangesDoubleClicked( const QModelIndex & idx );
100  void rangesClicked( const QModelIndex & idx );
101  void changeCurrentValue( QStandardItem * item );
102 
104  void addClass();
106  void deleteClasses();
108  void deleteAllClasses();
110  void toggleBoundariesLink( bool linked );
111 
112  void sizeScaleFieldChanged( const QString& fldName );
113  void scaleMethodChanged( QgsSymbolV2::ScaleMethod scaleMethod );
114  void labelFormatChanged();
115 
116  void showSymbolLevels();
117 
118  void rowsMoved();
119  void modelDataChanged();
120  void on_mSizeUnitWidget_changed();
121  void on_methodComboBox_currentIndexChanged( int );
122  void refreshRanges( bool reset = false );
123 
124  private slots:
125  void cleanUpSymbolSelector( QgsPanelWidget* container );
126  void updateSymbolsFromWidget();
127 
128  protected:
129  void updateUiFromRenderer( bool updateCount = true );
130  void connectUpdateHandlers();
131  void disconnectUpdateHandlers();
132  bool rowsOrdered();
133 
134  void updateGraduatedSymbolIcon();
135 
137  QList<int> selectedClasses();
138  QgsRangeList selectedRanges();
139 
140  void changeRangeSymbol( int rangeIdx );
141  void changeRange( int rangeIdx );
142 
143  void changeSelectedSymbols();
144 
145  QList<QgsSymbolV2*> selectedSymbols() override;
146  QgsSymbolV2* findSymbolForRange( double lowerBound, double upperBound, const QgsRangeList& ranges ) const;
147  void refreshSymbolView() override;
148 
149  void keyPressEvent( QKeyEvent* event ) override;
150 
151  protected:
153 
155 
157 
158  QgsGraduatedSymbolRendererV2Model* mModel;
159 
161 };
162 
163 
164 #endif // QGSGRADUATEDSYMBOLRENDERERV2WIDGET_H
static unsigned index
virtual int rowCount(const QModelIndex &parent) const=0
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const=0
Base class for any widget that can be shown as a inline panel.
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
ScaleMethod
Scale method.
Definition: qgssymbolv2.h:90
typedef DropActions
virtual int columnCount(const QModelIndex &parent) const=0
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
QObject * parent() const
Represents a vector layer which manages a vector based data sets.
typedef ItemFlags