QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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, private QgsExpressionContextGenerator
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
109 public slots:
110 void graduatedColumnChanged( const QString &field );
111 void classifyGraduated();
112 void reapplyColorRamp();
113 void reapplySizes();
114 void rangesDoubleClicked( const QModelIndex &idx );
115 void rangesClicked( const QModelIndex &idx );
116 void changeCurrentValue( QStandardItem *item );
117
119 void addClass();
121 void deleteClasses();
123 void deleteAllClasses();
125 void toggleBoundariesLink( bool linked );
126
127 void labelFormatChanged();
128
129 void showSymbolLevels();
130
131 void rowsMoved();
132 void modelDataChanged();
133
139 void refreshRanges( bool reset );
140
141 protected:
142 void setSymbolLevels( const QgsLegendSymbolList &levels, bool enabled ) override;
143
144 private slots:
145 void mSizeUnitWidget_changed();
146 void methodComboBox_currentIndexChanged( int );
147 void updateMethodParameters();
148 void updateSymbolsFromWidget( QgsSymbolSelectorWidget *widget );
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...
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: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
QList< QgsLegendSymbolItem > QgsLegendSymbolList
QList< QgsRendererRange > QgsRangeList