QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
qgsgraduatedsymbolrendererwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgraduatedsymbolrendererwidget.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 QGSGRADUATEDSYMBOLRENDERERWIDGET_H
17#define QGSGRADUATEDSYMBOLRENDERERWIDGET_H
18
19#include <QStandardItem>
20
21
23#include "qgis_sip.h"
24#include "qgsrendererwidget.h"
25#include "qgsproxystyle.h"
27#include "qgsdoublevalidator.h"
28
29#include "qtimer.h"
30#include "ui_qgsgraduatedsymbolrendererwidget.h"
31
32#include "qgis_gui.h"
33
34
35#ifndef SIP_RUN
37
38class GUI_EXPORT QgsGraduatedSymbolRendererModel : public QAbstractItemModel
39{
40 Q_OBJECT
41 public:
42 QgsGraduatedSymbolRendererModel( QObject *parent = nullptr );
43 Qt::ItemFlags flags( const QModelIndex &index ) const override;
44 Qt::DropActions supportedDropActions() const override;
45 QVariant data( const QModelIndex &index, int role ) const override;
46 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
47 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
48 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
49 int columnCount( const QModelIndex & = QModelIndex() ) const override;
50 QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override;
51 QModelIndex parent( const QModelIndex &index ) const override;
52 QStringList mimeTypes() const override;
53 QMimeData *mimeData( const QModelIndexList &indexes ) const override;
54 bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
55
56 void setRenderer( QgsGraduatedSymbolRenderer *renderer );
57
58 QgsRendererRange rendererRange( const QModelIndex &index );
59 void addClass( QgsSymbol *symbol );
60 void addClass( const QgsRendererRange &range );
61 void deleteRows( QList<int> rows );
62 void removeAllRows();
63 void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override;
64 void updateSymbology();
65 void updateLabels();
66
67 signals:
68 void rowsMoved();
69
70 private:
71 QgsGraduatedSymbolRenderer *mRenderer = nullptr;
72 QString mMimeFormat;
73};
74
75// View style which shows drop indicator line between items
76class QgsGraduatedSymbolRendererViewStyle: public QgsProxyStyle
77{
78 Q_OBJECT
79
80 public:
81 explicit QgsGraduatedSymbolRendererViewStyle( QWidget *parent );
82
83 void drawPrimitive( PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr ) const override;
84};
85
87#endif
88
93class GUI_EXPORT QgsGraduatedSymbolRendererWidget : public QgsRendererWidget, private Ui::QgsGraduatedSymbolRendererWidget, private QgsExpressionContextGenerator
94{
95 Q_OBJECT
96
97 public:
98 static QgsRendererWidget *create( QgsVectorLayer *layer, QgsStyle *style, QgsFeatureRenderer *renderer ) SIP_FACTORY;
99
102
103 QgsFeatureRenderer *renderer() override;
104 void setContext( const QgsSymbolWidgetContext &context ) override;
105 void disableSymbolLevels() override SIP_SKIP;
106
107 public slots:
108 void graduatedColumnChanged( const QString &field );
109 void classifyGraduated();
110 void reapplyColorRamp();
111 void reapplySizes();
112 void rangesDoubleClicked( const QModelIndex &idx );
113 void rangesClicked( const QModelIndex &idx );
114 void changeCurrentValue( QStandardItem *item );
115
117 void addClass();
119 void deleteClasses();
121 void deleteAllClasses();
123 void toggleBoundariesLink( bool linked );
124
125 void labelFormatChanged();
126
127 void showSymbolLevels();
128
129 void rowsMoved();
130 void modelDataChanged();
131
137 void refreshRanges( bool reset );
138
139 protected:
140 void setSymbolLevels( const QgsLegendSymbolList &levels, bool enabled ) override;
141
142 private slots:
143 void mSizeUnitWidget_changed();
144 void methodComboBox_currentIndexChanged( int );
145 void updateMethodParameters();
146 void cleanUpSymbolSelector( QgsPanelWidget *container );
147 void updateSymbolsFromWidget();
148 void dataDefinedSizeLegend();
149 void changeGraduatedSymbol();
150 void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
151 void symmetryPointEditingFinished();
152 void classifyGraduatedImpl();
153
154 protected slots:
155
156 void pasteSymbolToSelection() override;
157
158 protected:
159 void updateUiFromRenderer( bool updateCount = true );
160 void connectUpdateHandlers();
161 void disconnectUpdateHandlers();
162 bool rowsOrdered();
163
165 QList<int> selectedClasses();
166 QgsRangeList selectedRanges();
167
168 void changeRangeSymbol( int rangeIdx );
169 void changeRange( int rangeIdx );
170
171 void changeSelectedSymbols();
173 void applyChangeToSymbol();
174
175 QList<QgsSymbol *> selectedSymbols() override;
176 QgsSymbol *findSymbolForRange( double lowerBound, double upperBound, const QgsRangeList &ranges ) const;
177 void refreshSymbolView() override;
178
179 void keyPressEvent( QKeyEvent *event ) override;
180
181 private:
182 enum MethodMode
183 {
184 ColorMode,
185 SizeMode
186 };
187
188 QgsExpressionContext createExpressionContext() const override;
189 void toggleMethodWidgets( MethodMode mode );
190
191 void clearParameterWidgets();
192
193 std::unique_ptr< QgsGraduatedSymbolRenderer > mRenderer;
194
195 std::unique_ptr< QgsSymbol > mGraduatedSymbol;
196
197 int mRowSelected;
198
199 QgsGraduatedSymbolRendererModel *mModel = nullptr;
200
201 QgsRangeList mCopyBuffer;
202
203 QgsDoubleValidator *mSymmetryPointValidator = nullptr;
204 QAction *mActionLevels = nullptr;
205 std::vector< std::unique_ptr< QgsAbstractProcessingParameterWidgetWrapper >> mParameterWidgetWrappers;
206
207 int mBlockUpdates = 0;
208
209 QTimer mUpdateTimer;
210};
211
212
213#endif // QGSGRADUATEDSYMBOLRENDERERWIDGET_H
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
Abstract interface for generating an expression context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Base class for any widget that can be shown as a inline panel.
A QProxyStyle subclass which correctly sets the base style to match the QGIS application style,...
Definition: qgsproxystyle.h:31
Base class for renderer settings widgets.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:93
Represents a vector layer which manages a vector based data sets.
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_FACTORY
Definition: qgis_sip.h:76
const QgsField & field
Definition: qgsfield.h:501
QList< QgsLegendSymbolItem > QgsLegendSymbolList
QList< QgsRendererRange > QgsRangeList