QGIS API Documentation  3.6.0-Noosa (5873452)
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;
33 class QgsProcessingMatrixParameterPanel;
34 class QgsFileWidget;
37 
39 
40 class GUI_EXPORT QgsProcessingBooleanWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
41 {
42  Q_OBJECT
43 
44  public:
45 
46  QgsProcessingBooleanWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
47  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
48 
49  // QgsProcessingParameterWidgetFactoryInterface
50  QString parameterType() const override;
52 
53  // QgsProcessingParameterWidgetWrapper interface
54  QWidget *createWidget() override SIP_FACTORY;
55  QLabel *createLabel() override SIP_FACTORY;
56 
57  protected:
58 
59  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
60  QVariant widgetValue() const override;
61 
62  QStringList compatibleParameterTypes() const override;
63 
64  QStringList compatibleOutputTypes() const override;
65 
66  QList< int > compatibleDataTypes() const override;
67 
68  private:
69 
70  QCheckBox *mCheckBox = nullptr;
71  QComboBox *mComboBox = nullptr;
72 
73  friend class TestProcessingGui;
74 };
75 
76 class GUI_EXPORT QgsProcessingCrsWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
77 {
78  Q_OBJECT
79 
80  public:
81 
82  QgsProcessingCrsWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
83  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
84 
85  // QgsProcessingParameterWidgetFactoryInterface
86  QString parameterType() const override;
87  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
88 
89  // QgsProcessingParameterWidgetWrapper interface
90  QWidget *createWidget() override SIP_FACTORY;
91 
92  protected:
93 
94  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
95  QVariant widgetValue() const override;
96 
97  QStringList compatibleParameterTypes() const override;
98  QStringList compatibleOutputTypes() const override;
99  QList< int > compatibleDataTypes() const override;
100  QString modelerExpressionFormatString() const override;
101 
102  private:
103 
104  QgsProjectionSelectionWidget *mProjectionSelectionWidget = nullptr;
105  QCheckBox *mUseProjectCrsCheckBox = nullptr;
106 
107  friend class TestProcessingGui;
108 };
109 
110 class GUI_EXPORT QgsProcessingStringWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
111 {
112  Q_OBJECT
113 
114  public:
115 
116  QgsProcessingStringWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
117  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
118 
119  // QgsProcessingParameterWidgetFactoryInterface
120  QString parameterType() const override;
121  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
122 
123  // QgsProcessingParameterWidgetWrapper interface
124  QWidget *createWidget() override SIP_FACTORY;
125 
126  protected:
127 
128  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
129  QVariant widgetValue() const override;
130 
131  QStringList compatibleParameterTypes() const override;
132 
133  QStringList compatibleOutputTypes() const override;
134 
135  QList< int > compatibleDataTypes() const override;
136 
137  private:
138 
139  QLineEdit *mLineEdit = nullptr;
140  QPlainTextEdit *mPlainTextEdit = nullptr;
141 
142  friend class TestProcessingGui;
143 };
144 
145 
146 class GUI_EXPORT QgsProcessingAuthConfigWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
147 {
148  Q_OBJECT
149 
150  public:
151 
152  QgsProcessingAuthConfigWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
153  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
154 
155  // QgsProcessingParameterWidgetFactoryInterface
156  QString parameterType() const override;
157  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
158 
159  // QgsProcessingParameterWidgetWrapper interface
160  QWidget *createWidget() override SIP_FACTORY;
161 
162  protected:
163 
164  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
165  QVariant widgetValue() const override;
166 
167  QStringList compatibleParameterTypes() const override;
168 
169  QStringList compatibleOutputTypes() const override;
170 
171  QList< int > compatibleDataTypes() const override;
172 
173  private:
174 
175  QgsAuthConfigSelect *mAuthConfigSelect = nullptr;
176 
177  friend class TestProcessingGui;
178 };
179 
180 
181 class GUI_EXPORT QgsProcessingNumericWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
182 {
183  Q_OBJECT
184 
185  public:
186 
187  QgsProcessingNumericWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
188  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
189 
190  // QgsProcessingParameterWidgetFactoryInterface
191  QString parameterType() const override;
192  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
193 
194  // QgsProcessingParameterWidgetWrapper interface
195  QWidget *createWidget() override SIP_FACTORY;
196 
197  protected:
198 
199  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
200  QVariant widgetValue() const override;
201 
202  QStringList compatibleParameterTypes() const override;
203 
204  QStringList compatibleOutputTypes() const override;
205 
206  QList< int > compatibleDataTypes() const override;
207 
208  protected:
209 
210  QgsSpinBox *mSpinBox = nullptr;
211  QgsDoubleSpinBox *mDoubleSpinBox = nullptr;
212 
213  private:
214 
215  static double calculateStep( double minimum, double maximum );
216 
217  bool mAllowingNull = false;
218 
219  friend class TestProcessingGui;
220 };
221 
222 
223 class GUI_EXPORT QgsProcessingDistanceWidgetWrapper : public QgsProcessingNumericWidgetWrapper
224 {
225  Q_OBJECT
226 
227  public:
228 
229  QgsProcessingDistanceWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
230  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
231 
232  // QgsProcessingParameterWidgetFactoryInterface
233  QString parameterType() const override;
234  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
235 
236  // QgsProcessingParameterWidgetWrapper interface
237  QWidget *createWidget() override SIP_FACTORY;
238  void postInitialize( const QList< QgsAbstractProcessingParameterWidgetWrapper * > &wrappers ) override;
239 
240  public slots:
241  void setUnitParameterValue( const QVariant &value );
242  void setUnits( QgsUnitTypes::DistanceUnit unit );
243 
244  protected:
245 
246  QVariant widgetValue() const override;
247 
248  private:
249 
250  QgsUnitTypes::DistanceUnit mBaseUnit = QgsUnitTypes::DistanceUnknownUnit;
251  QLabel *mLabel = nullptr;
252  QWidget *mWarningLabel = nullptr;
253  QComboBox *mUnitsCombo = nullptr;
254 
255  friend class TestProcessingGui;
256 };
257 
258 
259 class GUI_EXPORT QgsProcessingRangeWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
260 {
261  Q_OBJECT
262 
263  public:
264 
265  QgsProcessingRangeWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
266  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
267 
268  // QgsProcessingParameterWidgetFactoryInterface
269  QString parameterType() const override;
270  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
271 
272  // QgsProcessingParameterWidgetWrapper interface
273  QWidget *createWidget() override SIP_FACTORY;
274 
275  protected:
276 
277  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
278  QVariant widgetValue() const override;
279  QStringList compatibleParameterTypes() const override;
280  QStringList compatibleOutputTypes() const override;
281  QList< int > compatibleDataTypes() const override;
282  QString modelerExpressionFormatString() const override;
283 
284  protected:
285 
286  QgsDoubleSpinBox *mMinSpinBox = nullptr;
287  QgsDoubleSpinBox *mMaxSpinBox = nullptr;
288 
289  private:
290 
291  int mBlockChangedSignal = 0;
292 
293  friend class TestProcessingGui;
294 };
295 
296 
297 class GUI_EXPORT QgsProcessingMatrixWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
298 {
299  Q_OBJECT
300 
301  public:
302 
303  QgsProcessingMatrixWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
304  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
305 
306  // QgsProcessingParameterWidgetFactoryInterface
307  QString parameterType() const override;
308  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
309 
310  // QgsProcessingParameterWidgetWrapper interface
311  QWidget *createWidget() override SIP_FACTORY;
312 
313  protected:
314 
315  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
316  QVariant widgetValue() const override;
317 
318  QStringList compatibleParameterTypes() const override;
319  QStringList compatibleOutputTypes() const override;
320  QList< int > compatibleDataTypes() const override;
321  QString modelerExpressionFormatString() const override;
322 
323  private:
324 
325  QgsProcessingMatrixParameterPanel *mMatrixWidget = nullptr;
326 
327  friend class TestProcessingGui;
328 };
329 
330 class GUI_EXPORT QgsProcessingFileWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
331 {
332  Q_OBJECT
333 
334  public:
335 
336  QgsProcessingFileWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
337  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
338 
339  // QgsProcessingParameterWidgetFactoryInterface
340  QString parameterType() const override;
341  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
342 
343  // QgsProcessingParameterWidgetWrapper interface
344  QWidget *createWidget() override SIP_FACTORY;
345 
346  protected:
347 
348  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
349  QVariant widgetValue() const override;
350 
351  QStringList compatibleParameterTypes() const override;
352 
353  QStringList compatibleOutputTypes() const override;
354 
355  QList< int > compatibleDataTypes() const override;
356  QString modelerExpressionFormatString() const override;
357 
358  private:
359 
360  QgsFileWidget *mFileWidget = nullptr;
361 
362  friend class TestProcessingGui;
363 };
364 
365 class GUI_EXPORT QgsProcessingExpressionWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
366 {
367  Q_OBJECT
368 
369  public:
370 
371  QgsProcessingExpressionWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
372  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
373 
374  // QgsProcessingParameterWidgetFactoryInterface
375  QString parameterType() const override;
376  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
377 
378  // QgsProcessingParameterWidgetWrapper interface
379  QWidget *createWidget() override SIP_FACTORY;
380  void postInitialize( const QList< QgsAbstractProcessingParameterWidgetWrapper * > &wrappers ) override;
381  public slots:
382  void setParentLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *parentWrapper );
383  protected:
384 
385  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
386  QVariant widgetValue() const override;
387 
388  QStringList compatibleParameterTypes() const override;
389 
390  QStringList compatibleOutputTypes() const override;
391 
392  QList< int > compatibleDataTypes() const override;
393  QString modelerExpressionFormatString() const override;
394  const QgsVectorLayer *linkedVectorLayer() const override;
395  private:
396 
397  QgsFieldExpressionWidget *mFieldExpWidget = nullptr;
398  QgsExpressionLineEdit *mExpLineEdit = nullptr;
399  std::unique_ptr< QgsVectorLayer > mParentLayer;
400 
401  friend class TestProcessingGui;
402 };
403 
405 
406 #endif // QGSPROCESSINGWIDGETWRAPPERIMPL_H
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
The QgsFieldExpressionWidget class reates a widget to choose fields and edit expressions It contains ...
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:38
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.
The QgsFileWidget class creates a widget for selecting a file or a folder.
Definition: qgsfilewidget.h:35
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
#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.
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
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.
Represents a vector layer which manages a vector based data sets.
Contains information about the context in which a processing algorithm is executed.
Selector widget for authentication configs.
Standard algorithm dialog.