QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
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, QScreen *screen = 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 QPointer< QScreen > mScreen;
74};
75
76// View style which shows drop indicator line between items
77class QgsGraduatedSymbolRendererViewStyle: public QgsProxyStyle
78{
79 Q_OBJECT
80
81 public:
82 explicit QgsGraduatedSymbolRendererViewStyle( QWidget *parent );
83
84 void drawPrimitive( PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr ) const override;
85};
86
88#endif
89
94class GUI_EXPORT QgsGraduatedSymbolRendererWidget : public QgsRendererWidget, private Ui::QgsGraduatedSymbolRendererWidget, private QgsExpressionContextGenerator
95{
96 Q_OBJECT
97
98 public:
99 static QgsRendererWidget *create( QgsVectorLayer *layer, QgsStyle *style, QgsFeatureRenderer *renderer ) SIP_FACTORY;
100
103
104 QgsFeatureRenderer *renderer() override;
105 void setContext( const QgsSymbolWidgetContext &context ) override;
106 void disableSymbolLevels() override SIP_SKIP;
107
108 public slots:
109 void graduatedColumnChanged( const QString &field );
110 void classifyGraduated();
111 void reapplyColorRamp();
112 void reapplySizes();
113 void rangesDoubleClicked( const QModelIndex &idx );
114 void rangesClicked( const QModelIndex &idx );
115 void changeCurrentValue( QStandardItem *item );
116
118 void addClass();
120 void deleteClasses();
122 void deleteAllClasses();
124 void toggleBoundariesLink( bool linked );
125
126 void labelFormatChanged();
127
128 void showSymbolLevels();
129
130 void rowsMoved();
131 void modelDataChanged();
132
138 void refreshRanges( bool reset );
139
140 protected:
141 void setSymbolLevels( const QgsLegendSymbolList &levels, bool enabled ) override;
142
143 private slots:
144 void mSizeUnitWidget_changed();
145 void methodComboBox_currentIndexChanged( int );
146 void updateMethodParameters();
147 void cleanUpSymbolSelector( QgsPanelWidget *container );
148 void updateSymbolsFromWidget();
149 void dataDefinedSizeLegend();
150 void changeGraduatedSymbol();
151 void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
152 void symmetryPointEditingFinished();
153 void classifyGraduatedImpl();
154
155 protected slots:
156
157 void pasteSymbolToSelection() override;
158
159 protected:
160 void updateUiFromRenderer( bool updateCount = true );
161 void connectUpdateHandlers();
162 void disconnectUpdateHandlers();
163 bool rowsOrdered();
164
166 QList<int> selectedClasses();
167 QgsRangeList selectedRanges();
168
169 void changeRangeSymbol( int rangeIdx );
170 void changeRange( int rangeIdx );
171
172 void changeSelectedSymbols();
174 void applyChangeToSymbol();
175
176 QList<QgsSymbol *> selectedSymbols() override;
177 QgsSymbol *findSymbolForRange( double lowerBound, double upperBound, const QgsRangeList &ranges ) const;
178 void refreshSymbolView() override;
179
180 void keyPressEvent( QKeyEvent *event ) override;
181
182 private:
183 enum MethodMode
184 {
185 ColorMode,
186 SizeMode
187 };
188
189 QgsExpressionContext createExpressionContext() const override;
190 void toggleMethodWidgets( MethodMode mode );
191
192 void clearParameterWidgets();
193
194 std::unique_ptr< QgsGraduatedSymbolRenderer > mRenderer;
195
196 std::unique_ptr< QgsSymbol > mGraduatedSymbol;
197
198 int mRowSelected;
199
200 QgsGraduatedSymbolRendererModel *mModel = nullptr;
201
202 QgsRangeList mCopyBuffer;
203
204 QgsDoubleValidator *mSymmetryPointValidator = nullptr;
205 QAction *mActionLevels = nullptr;
206 std::vector< std::unique_ptr< QgsAbstractProcessingParameterWidgetWrapper >> mParameterWidgetWrappers;
207
208 int mBlockUpdates = 0;
209
210 QTimer mUpdateTimer;
211};
212
213
214#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:94
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:554
QList< QgsLegendSymbolItem > QgsLegendSymbolList
QList< QgsRendererRange > QgsRangeList