QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsprocessingwidgetwrapperimpl.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingwidgetwrapperimpl.h
3  ---------------------
4  begin : August 2018
5  copyright : (C) 2018 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 #ifndef QGSPROCESSINGWIDGETWRAPPERIMPL_H
20 #define QGSPROCESSINGWIDGETWRAPPERIMPL_H
21 
22 #define SIP_NO_FILE
24 
25 class QCheckBox;
26 class QComboBox;
27 class QLineEdit;
28 class QPlainTextEdit;
30 class QgsSpinBox;
31 class QgsDoubleSpinBox;
32 class QgsProcessingMatrixParameterPanel;
33 
35 
36 class GUI_EXPORT QgsProcessingBooleanWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
37 {
38  Q_OBJECT
39 
40  public:
41 
42  QgsProcessingBooleanWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
43  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
44 
45  // QgsProcessingParameterWidgetFactoryInterface
46  QString parameterType() const override;
48 
49  // QgsProcessingParameterWidgetWrapper interface
50  QWidget *createWidget() override SIP_FACTORY;
51  QLabel *createLabel() override SIP_FACTORY;
52 
53  protected:
54 
55  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
56  QVariant widgetValue() const override;
57 
58  QStringList compatibleParameterTypes() const override;
59 
60  QStringList compatibleOutputTypes() const override;
61 
62  QList< int > compatibleDataTypes() const override;
63 
64  private:
65 
66  QCheckBox *mCheckBox = nullptr;
67  QComboBox *mComboBox = nullptr;
68 
69  friend class TestProcessingGui;
70 };
71 
72 class GUI_EXPORT QgsProcessingCrsWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
73 {
74  Q_OBJECT
75 
76  public:
77 
78  QgsProcessingCrsWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
79  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
80 
81  // QgsProcessingParameterWidgetFactoryInterface
82  QString parameterType() const override;
83  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
84 
85  // QgsProcessingParameterWidgetWrapper interface
86  QWidget *createWidget() override SIP_FACTORY;
87 
88  protected:
89 
90  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
91  QVariant widgetValue() const override;
92 
93  QStringList compatibleParameterTypes() const override;
94  QStringList compatibleOutputTypes() const override;
95  QList< int > compatibleDataTypes() const override;
96  QString modelerExpressionFormatString() const override;
97 
98  private:
99 
100  QgsProjectionSelectionWidget *mProjectionSelectionWidget = nullptr;
101  QCheckBox *mUseProjectCrsCheckBox = nullptr;
102 
103  friend class TestProcessingGui;
104 };
105 
106 class GUI_EXPORT QgsProcessingStringWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
107 {
108  Q_OBJECT
109 
110  public:
111 
112  QgsProcessingStringWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
113  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
114 
115  // QgsProcessingParameterWidgetFactoryInterface
116  QString parameterType() const override;
117  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
118 
119  // QgsProcessingParameterWidgetWrapper interface
120  QWidget *createWidget() override SIP_FACTORY;
121 
122  protected:
123 
124  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
125  QVariant widgetValue() const override;
126 
127  QStringList compatibleParameterTypes() const override;
128 
129  QStringList compatibleOutputTypes() const override;
130 
131  QList< int > compatibleDataTypes() const override;
132 
133  private:
134 
135  QLineEdit *mLineEdit = nullptr;
136  QPlainTextEdit *mPlainTextEdit = nullptr;
137 
138  friend class TestProcessingGui;
139 };
140 
141 class GUI_EXPORT QgsProcessingNumericWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
142 {
143  Q_OBJECT
144 
145  public:
146 
147  QgsProcessingNumericWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
148  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
149 
150  // QgsProcessingParameterWidgetFactoryInterface
151  QString parameterType() const override;
152  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
153 
154  // QgsProcessingParameterWidgetWrapper interface
155  QWidget *createWidget() override SIP_FACTORY;
156 
157  protected:
158 
159  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
160  QVariant widgetValue() const override;
161 
162  QStringList compatibleParameterTypes() const override;
163 
164  QStringList compatibleOutputTypes() const override;
165 
166  QList< int > compatibleDataTypes() const override;
167 
168  protected:
169 
170  QgsSpinBox *mSpinBox = nullptr;
171  QgsDoubleSpinBox *mDoubleSpinBox = nullptr;
172 
173  private:
174 
175  static double calculateStep( double minimum, double maximum );
176 
177  bool mAllowingNull = false;
178 
179  friend class TestProcessingGui;
180 };
181 
182 
183 class GUI_EXPORT QgsProcessingDistanceWidgetWrapper : public QgsProcessingNumericWidgetWrapper
184 {
185  Q_OBJECT
186 
187  public:
188 
189  QgsProcessingDistanceWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
190  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
191 
192  // QgsProcessingParameterWidgetFactoryInterface
193  QString parameterType() const override;
194  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
195 
196  // QgsProcessingParameterWidgetWrapper interface
197  QWidget *createWidget() override SIP_FACTORY;
198  void postInitialize( const QList< QgsAbstractProcessingParameterWidgetWrapper * > &wrappers ) override;
199 
200  public slots:
201  void setUnitParameterValue( const QVariant &value );
202  void setUnits( QgsUnitTypes::DistanceUnit unit );
203 
204  protected:
205 
206  QVariant widgetValue() const override;
207 
208  private:
209 
210  QgsUnitTypes::DistanceUnit mBaseUnit = QgsUnitTypes::DistanceUnknownUnit;
211  QLabel *mLabel = nullptr;
212  QWidget *mWarningLabel = nullptr;
213  QComboBox *mUnitsCombo = nullptr;
214 
215  friend class TestProcessingGui;
216 };
217 
218 
219 class GUI_EXPORT QgsProcessingRangeWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
220 {
221  Q_OBJECT
222 
223  public:
224 
225  QgsProcessingRangeWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
226  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
227 
228  // QgsProcessingParameterWidgetFactoryInterface
229  QString parameterType() const override;
230  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
231 
232  // QgsProcessingParameterWidgetWrapper interface
233  QWidget *createWidget() override SIP_FACTORY;
234 
235  protected:
236 
237  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
238  QVariant widgetValue() const override;
239  QStringList compatibleParameterTypes() const override;
240  QStringList compatibleOutputTypes() const override;
241  QList< int > compatibleDataTypes() const override;
242  QString modelerExpressionFormatString() const override;
243 
244  protected:
245 
246  QgsDoubleSpinBox *mMinSpinBox = nullptr;
247  QgsDoubleSpinBox *mMaxSpinBox = nullptr;
248 
249  private:
250 
251  int mBlockChangedSignal = 0;
252 
253  friend class TestProcessingGui;
254 };
255 
256 
257 class GUI_EXPORT QgsProcessingMatrixWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
258 {
259  Q_OBJECT
260 
261  public:
262 
263  QgsProcessingMatrixWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
264  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
265 
266  // QgsProcessingParameterWidgetFactoryInterface
267  QString parameterType() const override;
268  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
269 
270  // QgsProcessingParameterWidgetWrapper interface
271  QWidget *createWidget() override SIP_FACTORY;
272 
273  protected:
274 
275  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
276  QVariant widgetValue() const override;
277 
278  QStringList compatibleParameterTypes() const override;
279  QStringList compatibleOutputTypes() const override;
280  QList< int > compatibleDataTypes() const override;
281  QString modelerExpressionFormatString() const override;
282 
283  private:
284 
285  QgsProcessingMatrixParameterPanel *mMatrixWidget = nullptr;
286 
287  friend class TestProcessingGui;
288 };
289 
291 
292 #endif // QGSPROCESSINGWIDGETWRAPPERIMPL_H
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
A widget wrapper for Processing parameter value widgets.
WidgetType
Types of dialogs which Processing widgets can be created for.
An interface for Processing widget wrapper factories.
Helper functions for various unit types.
Definition: qgsunittypes.h:37
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
Definition: qgsspinbox.h:42
virtual QgsAbstractProcessingParameterWidgetWrapper * createWidgetWrapper(const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type)=0
Creates a new widget wrapper for the specified parameter definition.
#define SIP_FACTORY
Definition: qgis_sip.h:69
A widget for selecting a projection.
virtual QString parameterType() const =0
Returns the type string for the parameter type the factory is associated with.
Base class for the definition of processing parameters.
virtual QWidget * createWidget()=0
Creates a new widget which allows customization of the parameter&#39;s value.
Contains information about the context in which a processing algorithm is executed.
Standard algorithm dialog.