QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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
35
36#ifndef SIP_RUN
38
39class GUI_EXPORT QgsGraduatedSymbolRendererModel : public QAbstractItemModel
40{
41 Q_OBJECT
42 public:
43 QgsGraduatedSymbolRendererModel( QObject *parent = nullptr, QScreen *screen = nullptr );
44 Qt::ItemFlags flags( const QModelIndex &index ) const override;
45 Qt::DropActions supportedDropActions() const override;
46 QVariant data( const QModelIndex &index, int role ) const override;
47 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
48 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
49 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
50 int columnCount( const QModelIndex & = QModelIndex() ) const override;
51 QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override;
52 QModelIndex parent( const QModelIndex &index ) const override;
53 QStringList mimeTypes() const override;
54 QMimeData *mimeData( const QModelIndexList &indexes ) const override;
55 bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
56
57 void setRenderer( QgsGraduatedSymbolRenderer *renderer );
58
59 QgsRendererRange rendererRange( const QModelIndex &index );
60 void addClass( QgsSymbol *symbol );
61 void addClass( const QgsRendererRange &range );
62 void deleteRows( QList<int> rows );
63 void removeAllRows();
64 void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override;
65 void updateSymbology();
66 void updateLabels();
67
68 signals:
69 void rowsMoved();
70
71 private:
72 QgsGraduatedSymbolRenderer *mRenderer = nullptr;
73 QString mMimeFormat;
74 QPointer< QScreen > mScreen;
75};
76
77// View style which shows drop indicator line between items
78class QgsGraduatedSymbolRendererViewStyle: public QgsProxyStyle
79{
80 Q_OBJECT
81
82 public:
83 explicit QgsGraduatedSymbolRendererViewStyle( QWidget *parent );
84
85 void drawPrimitive( PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr ) const override;
86};
87
89#endif
90
95class GUI_EXPORT QgsGraduatedSymbolRendererWidget : public QgsRendererWidget, private Ui::QgsGraduatedSymbolRendererWidget
96{
97 Q_OBJECT
98
99 public:
100 static QgsRendererWidget *create( QgsVectorLayer *layer, QgsStyle *style, QgsFeatureRenderer *renderer ) SIP_FACTORY;
101
104
105 QgsFeatureRenderer *renderer() override;
106 void setContext( const QgsSymbolWidgetContext &context ) override;
107 void disableSymbolLevels() override SIP_SKIP;
108 QgsExpressionContext createExpressionContext() const override;
109
110 public slots:
111 void graduatedColumnChanged( const QString &field );
112 void classifyGraduated();
113 void reapplyColorRamp();
114 void reapplySizes();
115 void rangesDoubleClicked( const QModelIndex &idx );
116 void rangesClicked( const QModelIndex &idx );
117 void changeCurrentValue( QStandardItem *item );
118
120 void addClass();
122 void deleteClasses();
124 void deleteAllClasses();
126 void toggleBoundariesLink( bool linked );
127
128 void labelFormatChanged();
129
130 void showSymbolLevels();
131
132 void rowsMoved();
133 void modelDataChanged();
134
140 void refreshRanges( bool reset );
141
142 protected:
143 void setSymbolLevels( const QgsLegendSymbolList &levels, bool enabled ) override;
144
145 private slots:
146 void mSizeUnitWidget_changed();
147 void methodComboBox_currentIndexChanged( int );
148 void updateMethodParameters();
149 void updateSymbolsFromWidget( QgsSymbolSelectorWidget *widget );
150 void dataDefinedSizeLegend();
151 void changeGraduatedSymbol();
152 void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
153 void symmetryPointEditingFinished();
154 void classifyGraduatedImpl();
155
156 protected slots:
157
158 void pasteSymbolToSelection() override;
159
160 protected:
161 void updateUiFromRenderer( bool updateCount = true );
162 void connectUpdateHandlers();
163 void disconnectUpdateHandlers();
164 bool rowsOrdered();
165
167 QList<int> selectedClasses();
168 QgsRangeList selectedRanges();
169
170 void changeRangeSymbol( int rangeIdx );
171 void changeRange( int rangeIdx );
172
173 void changeSelectedSymbols();
175 void applyChangeToSymbol();
176
177 QList<QgsSymbol *> selectedSymbols() override;
178 QgsSymbol *findSymbolForRange( double lowerBound, double upperBound, const QgsRangeList &ranges ) const;
179 void refreshSymbolView() override;
180
181 void keyPressEvent( QKeyEvent *event ) override;
182
183 private:
184 enum MethodMode
185 {
186 ColorMode,
187 SizeMode
188 };
189
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...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Abstract base class for all 2D vector feature renderers.
A vector feature renderer which uses numeric attributes to classify features into different ranges.
A QProxyStyle subclass which correctly sets the base style to match the QGIS application style,...
Base class for renderer settings widgets.
Symbol selector widget that can be used to select and build a symbol.
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:231
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
QList< QgsLegendSymbolItem > QgsLegendSymbolList
QList< QgsRendererRange > QgsRangeList