QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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
25 #include "qgsmaptool.h"
26 
27 #include <QAbstractButton>
28 
29 class QCheckBox;
30 class QComboBox;
31 class QLineEdit;
32 class QPlainTextEdit;
33 class QToolButton;
34 class QButtonGroup;
36 class QgsSpinBox;
37 class QgsDoubleSpinBox;
39 class QgsProcessingMatrixParameterPanel;
40 class QgsFileWidget;
44 class QgsLayoutComboBox;
46 class QgsPrintLayout;
47 class QgsScaleWidget;
48 class QgsSnapIndicator;
49 class QgsFilterLineEdit;
50 class QgsColorButton;
51 
53 
54 class GUI_EXPORT QgsProcessingBooleanParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
55 {
56  Q_OBJECT
57  public:
58 
59  QgsProcessingBooleanParameterDefinitionWidget( QgsProcessingContext &context,
60  const QgsProcessingParameterWidgetContext &widgetContext,
61  const QgsProcessingParameterDefinition *definition = nullptr,
62  const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
63  QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, QgsProcessingParameterDefinition::Flags flags ) const override;
64 
65  private:
66 
67  QCheckBox *mDefaultCheckBox = nullptr;
68 
69 };
70 
71 class GUI_EXPORT QgsProcessingBooleanWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
72 {
73  Q_OBJECT
74 
75  public:
76 
77  QgsProcessingBooleanWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
78  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
79 
80  // QgsProcessingParameterWidgetFactoryInterface
81  QString parameterType() const override;
84  QgsProcessingContext &context,
85  const QgsProcessingParameterWidgetContext &widgetContext,
86  const QgsProcessingParameterDefinition *definition = nullptr,
87  const QgsProcessingAlgorithm *algorithm = nullptr ) override;
88 
89  // QgsProcessingParameterWidgetWrapper interface
90  QWidget *createWidget() override SIP_FACTORY;
91  QLabel *createLabel() override SIP_FACTORY;
92 
93  protected:
94 
95  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
96  QVariant widgetValue() const override;
97 
98  QStringList compatibleParameterTypes() const override;
99 
100  QStringList compatibleOutputTypes() const override;
101 
102  QList< int > compatibleDataTypes() const override;
103 
104  private:
105 
106  QCheckBox *mCheckBox = nullptr;
107  QComboBox *mComboBox = nullptr;
108 
109  friend class TestProcessingGui;
110 };
111 
112 class GUI_EXPORT QgsProcessingCrsWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
113 {
114  Q_OBJECT
115 
116  public:
117 
118  QgsProcessingCrsWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
119  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
120 
121  // QgsProcessingParameterWidgetFactoryInterface
122  QString parameterType() const override;
123  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
124 
125  // QgsProcessingParameterWidgetWrapper interface
126  QWidget *createWidget() override SIP_FACTORY;
127 
128  protected:
129 
130  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
131  QVariant widgetValue() const override;
132 
133  QStringList compatibleParameterTypes() const override;
134  QStringList compatibleOutputTypes() const override;
135  QList< int > compatibleDataTypes() const override;
136  QString modelerExpressionFormatString() const override;
137 
138  private:
139 
140  QgsProjectionSelectionWidget *mProjectionSelectionWidget = nullptr;
141  QCheckBox *mUseProjectCrsCheckBox = nullptr;
142 
143  friend class TestProcessingGui;
144 };
145 
146 
147 
148 class GUI_EXPORT QgsProcessingStringParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
149 {
150  Q_OBJECT
151  public:
152 
153  QgsProcessingStringParameterDefinitionWidget( QgsProcessingContext &context,
154  const QgsProcessingParameterWidgetContext &widgetContext,
155  const QgsProcessingParameterDefinition *definition = nullptr,
156  const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
157  QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, QgsProcessingParameterDefinition::Flags flags ) const override;
158 
159  private:
160 
161  QLineEdit *mDefaultLineEdit = nullptr;
162  QCheckBox *mMultiLineCheckBox = nullptr;
163 
164 };
165 
166 class GUI_EXPORT QgsProcessingStringWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
167 {
168  Q_OBJECT
169 
170  public:
171 
172  QgsProcessingStringWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
173  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
174 
175  // QgsProcessingParameterWidgetFactoryInterface
176  QString parameterType() const override;
177  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
179  QgsProcessingContext &context,
180  const QgsProcessingParameterWidgetContext &widgetContext,
181  const QgsProcessingParameterDefinition *definition = nullptr,
182  const QgsProcessingAlgorithm *algorithm = nullptr ) override;
183 
184  // QgsProcessingParameterWidgetWrapper interface
185  QWidget *createWidget() override SIP_FACTORY;
186 
187  protected:
188 
189  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
190  QVariant widgetValue() const override;
191 
192  QStringList compatibleParameterTypes() const override;
193 
194  QStringList compatibleOutputTypes() const override;
195 
196  QList< int > compatibleDataTypes() const override;
197 
198  private:
199 
200  QLineEdit *mLineEdit = nullptr;
201  QPlainTextEdit *mPlainTextEdit = nullptr;
202 
203  friend class TestProcessingGui;
204 };
205 
206 
207 class GUI_EXPORT QgsProcessingAuthConfigWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
208 {
209  Q_OBJECT
210 
211  public:
212 
213  QgsProcessingAuthConfigWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
214  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
215 
216  // QgsProcessingParameterWidgetFactoryInterface
217  QString parameterType() const override;
218  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
219 
220  // QgsProcessingParameterWidgetWrapper interface
221  QWidget *createWidget() override SIP_FACTORY;
222 
223  protected:
224 
225  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
226  QVariant widgetValue() const override;
227 
228  QStringList compatibleParameterTypes() const override;
229 
230  QStringList compatibleOutputTypes() const override;
231 
232  QList< int > compatibleDataTypes() const override;
233 
234  private:
235 
236  QgsAuthConfigSelect *mAuthConfigSelect = nullptr;
237 
238  friend class TestProcessingGui;
239 };
240 
241 
242 class GUI_EXPORT QgsProcessingNumericWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
243 {
244  Q_OBJECT
245 
246  public:
247 
248  QgsProcessingNumericWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
249  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
250 
251  // QgsProcessingParameterWidgetFactoryInterface
252  QString parameterType() const override;
253  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
254 
255  // QgsProcessingParameterWidgetWrapper interface
256  QWidget *createWidget() override SIP_FACTORY;
257 
258  protected:
259 
260  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
261  QVariant widgetValue() const override;
262 
263  QStringList compatibleParameterTypes() const override;
264 
265  QStringList compatibleOutputTypes() const override;
266 
267  QList< int > compatibleDataTypes() const override;
268 
269  protected:
270 
271  QgsSpinBox *mSpinBox = nullptr;
272  QgsDoubleSpinBox *mDoubleSpinBox = nullptr;
273 
274  private:
275 
276  static double calculateStep( double minimum, double maximum );
277 
278  bool mAllowingNull = false;
279 
280  friend class TestProcessingGui;
281 };
282 
283 
284 class GUI_EXPORT QgsProcessingDistanceWidgetWrapper : public QgsProcessingNumericWidgetWrapper
285 {
286  Q_OBJECT
287 
288  public:
289 
290  QgsProcessingDistanceWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
291  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
292 
293  // QgsProcessingParameterWidgetFactoryInterface
294  QString parameterType() const override;
295  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
296 
297  // QgsProcessingParameterWidgetWrapper interface
298  QWidget *createWidget() override SIP_FACTORY;
299  void postInitialize( const QList< QgsAbstractProcessingParameterWidgetWrapper * > &wrappers ) override;
300 
301  public slots:
302  void setUnitParameterValue( const QVariant &value );
303  void setUnits( QgsUnitTypes::DistanceUnit unit );
304 
305  protected:
306 
307  QVariant widgetValue() const override;
308 
309  private:
310 
311  QgsUnitTypes::DistanceUnit mBaseUnit = QgsUnitTypes::DistanceUnknownUnit;
312  QLabel *mLabel = nullptr;
313  QWidget *mWarningLabel = nullptr;
314  QComboBox *mUnitsCombo = nullptr;
315 
316  friend class TestProcessingGui;
317 };
318 
319 
320 class GUI_EXPORT QgsProcessingScaleWidgetWrapper : public QgsProcessingNumericWidgetWrapper
321 {
322  Q_OBJECT
323 
324  public:
325 
326  QgsProcessingScaleWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
327  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
328 
329  // QgsProcessingParameterWidgetFactoryInterface
330  QString parameterType() const override;
331  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
332 
333  // QgsProcessingParameterWidgetWrapper interface
334  QWidget *createWidget() override SIP_FACTORY;
335  void setWidgetContext( const QgsProcessingParameterWidgetContext &context ) override;
336  protected:
337 
338  QVariant widgetValue() const override;
339  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
340 
341  private:
342 
343  QgsScaleWidget *mScaleWidget = nullptr;
344 
345  friend class TestProcessingGui;
346 };
347 
348 class GUI_EXPORT QgsProcessingRangeWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
349 {
350  Q_OBJECT
351 
352  public:
353 
354  QgsProcessingRangeWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
355  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
356 
357  // QgsProcessingParameterWidgetFactoryInterface
358  QString parameterType() const override;
359  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
360 
361  // QgsProcessingParameterWidgetWrapper interface
362  QWidget *createWidget() override SIP_FACTORY;
363 
364  protected:
365 
366  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
367  QVariant widgetValue() const override;
368  QStringList compatibleParameterTypes() const override;
369  QStringList compatibleOutputTypes() const override;
370  QList< int > compatibleDataTypes() const override;
371  QString modelerExpressionFormatString() const override;
372 
373  protected:
374 
375  QgsDoubleSpinBox *mMinSpinBox = nullptr;
376  QgsDoubleSpinBox *mMaxSpinBox = nullptr;
377 
378  private:
379 
380  int mBlockChangedSignal = 0;
381 
382  friend class TestProcessingGui;
383 };
384 
385 
386 class GUI_EXPORT QgsProcessingMatrixWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
387 {
388  Q_OBJECT
389 
390  public:
391 
392  QgsProcessingMatrixWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
393  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
394 
395  // QgsProcessingParameterWidgetFactoryInterface
396  QString parameterType() const override;
397  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
398 
399  // QgsProcessingParameterWidgetWrapper interface
400  QWidget *createWidget() override SIP_FACTORY;
401 
402  protected:
403 
404  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
405  QVariant widgetValue() const override;
406 
407  QStringList compatibleParameterTypes() const override;
408  QStringList compatibleOutputTypes() const override;
409  QList< int > compatibleDataTypes() const override;
410  QString modelerExpressionFormatString() const override;
411 
412  private:
413 
414  QgsProcessingMatrixParameterPanel *mMatrixWidget = nullptr;
415 
416  friend class TestProcessingGui;
417 };
418 
419 class GUI_EXPORT QgsProcessingFileParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
420 {
421  Q_OBJECT
422  public:
423 
424  QgsProcessingFileParameterDefinitionWidget( QgsProcessingContext &context,
425  const QgsProcessingParameterWidgetContext &widgetContext,
426  const QgsProcessingParameterDefinition *definition = nullptr,
427  const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
428  QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, QgsProcessingParameterDefinition::Flags flags ) const override;
429 
430  private:
431 
432  QComboBox *mTypeComboBox = nullptr;
433  QComboBox *mFilterComboBox = nullptr;
434  QgsFileWidget *mDefaultFileWidget = nullptr;
435 
436 };
437 
438 class GUI_EXPORT QgsProcessingFileWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
439 {
440  Q_OBJECT
441 
442  public:
443 
444  QgsProcessingFileWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
445  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
446 
447  // QgsProcessingParameterWidgetFactoryInterface
448  QString parameterType() const override;
449  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
451  QgsProcessingContext &context,
452  const QgsProcessingParameterWidgetContext &widgetContext,
453  const QgsProcessingParameterDefinition *definition = nullptr,
454  const QgsProcessingAlgorithm *algorithm = nullptr ) override;
455 
456  // QgsProcessingParameterWidgetWrapper interface
457  QWidget *createWidget() override SIP_FACTORY;
458 
459  protected:
460 
461  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
462  QVariant widgetValue() const override;
463 
464  QStringList compatibleParameterTypes() const override;
465 
466  QStringList compatibleOutputTypes() const override;
467 
468  QList< int > compatibleDataTypes() const override;
469  QString modelerExpressionFormatString() const override;
470 
471  private:
472 
473  QgsFileWidget *mFileWidget = nullptr;
474 
475  friend class TestProcessingGui;
476 };
477 
478 class GUI_EXPORT QgsProcessingExpressionWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
479 {
480  Q_OBJECT
481 
482  public:
483 
484  QgsProcessingExpressionWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
485  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
486 
487  // QgsProcessingParameterWidgetFactoryInterface
488  QString parameterType() const override;
489  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
490 
491  // QgsProcessingParameterWidgetWrapper interface
492  QWidget *createWidget() override SIP_FACTORY;
493  void postInitialize( const QList< QgsAbstractProcessingParameterWidgetWrapper * > &wrappers ) override;
494  public slots:
495  void setParentLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *parentWrapper );
496  protected:
497 
498  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
499  QVariant widgetValue() const override;
500 
501  QStringList compatibleParameterTypes() const override;
502 
503  QStringList compatibleOutputTypes() const override;
504 
505  QList< int > compatibleDataTypes() const override;
506  QString modelerExpressionFormatString() const override;
507  const QgsVectorLayer *linkedVectorLayer() const override;
508  private:
509 
510  QgsFieldExpressionWidget *mFieldExpWidget = nullptr;
511  QgsExpressionLineEdit *mExpLineEdit = nullptr;
512  std::unique_ptr< QgsVectorLayer > mParentLayer;
513 
514  friend class TestProcessingGui;
515 };
516 
517 
518 class GUI_EXPORT QgsProcessingEnumCheckboxPanelWidget : public QWidget
519 {
520  Q_OBJECT
521 
522  public:
523 
524  QgsProcessingEnumCheckboxPanelWidget( QWidget *parent = nullptr, const QgsProcessingParameterEnum *param = nullptr, int columns = 2 );
525  QVariant value() const;
526  void setValue( const QVariant &value );
527 
528  signals:
529 
530  void changed();
531 
532  private slots:
533 
534  void showPopupMenu();
535  void selectAll();
536  void deselectAll();
537 
538  private:
539 
540  const QgsProcessingParameterEnum *mParam = nullptr;
541  QMap< QVariant, QAbstractButton * > mButtons;
542  QButtonGroup *mButtonGroup = nullptr;
543  int mColumns = 2;
544  bool mBlockChangedSignal = false;
545 
546  friend class TestProcessingGui;
547 };
548 
549 class GUI_EXPORT QgsProcessingEnumPanelWidget : public QWidget
550 {
551  Q_OBJECT
552 
553  public:
554 
555  QgsProcessingEnumPanelWidget( QWidget *parent = nullptr, const QgsProcessingParameterEnum *param = nullptr );
556  QVariant value() const { return mValue; }
557  void setValue( const QVariant &value );
558 
559  signals:
560 
561  void changed();
562 
563  private slots:
564 
565  void showDialog();
566 
567  private:
568 
569  void updateSummaryText();
570 
571  const QgsProcessingParameterEnum *mParam = nullptr;
572  QLineEdit *mLineEdit = nullptr;
573  QToolButton *mToolButton = nullptr;
574 
575  QVariantList mValue;
576 
577  friend class TestProcessingGui;
578 };
579 
580 
581 class GUI_EXPORT QgsProcessingEnumWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
582 {
583  Q_OBJECT
584 
585  public:
586 
587  QgsProcessingEnumWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
588  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
589 
590  // QgsProcessingParameterWidgetFactoryInterface
591  QString parameterType() const override;
592  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
593 
594  // QgsProcessingParameterWidgetWrapper interface
595  QWidget *createWidget() override SIP_FACTORY;
596 
597  protected:
598 
599  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
600  QVariant widgetValue() const override;
601 
602  QStringList compatibleParameterTypes() const override;
603 
604  QStringList compatibleOutputTypes() const override;
605 
606  QList< int > compatibleDataTypes() const override;
607  QString modelerExpressionFormatString() const override;
608  private:
609 
610  QComboBox *mComboBox = nullptr;
611  QgsProcessingEnumPanelWidget *mPanel = nullptr;
612  QgsProcessingEnumCheckboxPanelWidget *mCheckboxPanel = nullptr;
613 
614  friend class TestProcessingGui;
615 };
616 
617 
618 
619 class GUI_EXPORT QgsProcessingLayoutWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
620 {
621  Q_OBJECT
622 
623  public:
624 
625  QgsProcessingLayoutWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
626  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
627 
628  // QgsProcessingParameterWidgetFactoryInterface
629  QString parameterType() const override;
630  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
631 
632  // QgsProcessingParameterWidgetWrapper interface
633  QWidget *createWidget() override SIP_FACTORY;
634 
635  protected:
636 
637  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
638  QVariant widgetValue() const override;
639 
640  QStringList compatibleParameterTypes() const override;
641 
642  QStringList compatibleOutputTypes() const override;
643 
644  QList< int > compatibleDataTypes() const override;
645  QString modelerExpressionFormatString() const override;
646  private:
647 
648  QgsLayoutComboBox *mComboBox = nullptr;
649  QLineEdit *mLineEdit = nullptr;
650 
651  friend class TestProcessingGui;
652 };
653 
654 
655 
656 class GUI_EXPORT QgsProcessingLayoutItemParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
657 {
658  Q_OBJECT
659  public:
660 
661  QgsProcessingLayoutItemParameterDefinitionWidget( QgsProcessingContext &context,
662  const QgsProcessingParameterWidgetContext &widgetContext,
663  const QgsProcessingParameterDefinition *definition = nullptr,
664  const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
665  QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, QgsProcessingParameterDefinition::Flags flags ) const override;
666 
667  private:
668 
669  QComboBox *mParentLayoutComboBox = nullptr;
670 
671 };
672 
673 class GUI_EXPORT QgsProcessingLayoutItemWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
674 {
675  Q_OBJECT
676 
677  public:
678 
679  QgsProcessingLayoutItemWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
680  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
681 
682  // QgsProcessingParameterWidgetFactoryInterface
683  QString parameterType() const override;
684  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
686  QgsProcessingContext &context,
687  const QgsProcessingParameterWidgetContext &widgetContext,
688  const QgsProcessingParameterDefinition *definition = nullptr,
689  const QgsProcessingAlgorithm *algorithm = nullptr ) override;
690 
691  // QgsProcessingParameterWidgetWrapper interface
692  QWidget *createWidget() override SIP_FACTORY;
693  void postInitialize( const QList< QgsAbstractProcessingParameterWidgetWrapper * > &wrappers ) override;
694 
695 
696  public slots:
697  void setLayoutParameterValue( const QVariant &value );
698  void setLayout( QgsPrintLayout *layout );
699 
700  protected:
701 
702  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
703  QVariant widgetValue() const override;
704 
705  QStringList compatibleParameterTypes() const override;
706 
707  QStringList compatibleOutputTypes() const override;
708 
709  QList< int > compatibleDataTypes() const override;
710  QString modelerExpressionFormatString() const override;
711  private:
712 
713  QgsLayoutItemComboBox *mComboBox = nullptr;
714  QLineEdit *mLineEdit = nullptr;
715 
716  friend class TestProcessingGui;
717 };
718 
719 class GUI_EXPORT QgsProcessingPointMapTool : public QgsMapTool
720 {
721  Q_OBJECT
722  public:
723  QgsProcessingPointMapTool( QgsMapCanvas *canvas );
724  ~QgsProcessingPointMapTool() override;
725  void deactivate() override;
726  void canvasMoveEvent( QgsMapMouseEvent *e ) override;
727  void canvasPressEvent( QgsMapMouseEvent *e ) override;
728  void keyPressEvent( QKeyEvent *e ) override;
729 
730  signals:
731 
732  void clicked( const QgsPointXY &point );
733  void complete();
734 
735  private:
736 
737  std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
738  friend class TestProcessingGui;
739 };
740 
741 class GUI_EXPORT QgsProcessingPointPanel : public QWidget
742 {
743  Q_OBJECT
744 
745  public:
746 
747  QgsProcessingPointPanel( QWidget *parent );
748  void setMapCanvas( QgsMapCanvas *canvas );
749  void setAllowNull( bool allowNull );
750 
751  QVariant value() const;
752  void clear();
753  void setValue( const QgsPointXY &point, const QgsCoordinateReferenceSystem &crs );
754 
755  signals:
756 
757  void toggleDialogVisibility( bool visible );
758  void changed();
759 
760  private slots:
761 
762  void selectOnCanvas();
763  void updatePoint( const QgsPointXY &point );
764  void pointPicked();
765 
766  private:
767 
768  QgsFilterLineEdit *mLineEdit = nullptr;
769  QToolButton *mButton = nullptr;
770  QgsMapCanvas *mCanvas = nullptr;
772  QPointer< QgsMapTool > mPrevTool;
773  std::unique_ptr< QgsProcessingPointMapTool > mTool;
774  friend class TestProcessingGui;
775 };
776 
777 
778 class GUI_EXPORT QgsProcessingPointWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
779 {
780  Q_OBJECT
781 
782  public:
783 
784  QgsProcessingPointWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
785  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
786 
787  // QgsProcessingParameterWidgetFactoryInterface
788  QString parameterType() const override;
789  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
790 
791  // QgsProcessingParameterWidgetWrapper interface
792  QWidget *createWidget() override SIP_FACTORY;
793  void setWidgetContext( const QgsProcessingParameterWidgetContext &context ) override;
794  void setDialog( QDialog *dialog ) override;
795 
796  protected:
797 
798  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
799  QVariant widgetValue() const override;
800 
801  QStringList compatibleParameterTypes() const override;
802 
803  QStringList compatibleOutputTypes() const override;
804 
805  QList< int > compatibleDataTypes() const override;
806  QString modelerExpressionFormatString() const override;
807  private:
808 
809  QgsProcessingPointPanel *mPanel = nullptr;
810  QLineEdit *mLineEdit = nullptr;
811  QDialog *mDialog = nullptr;
812 
813  friend class TestProcessingGui;
814 };
815 
816 
817 class GUI_EXPORT QgsProcessingColorParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
818 {
819  Q_OBJECT
820  public:
821 
822  QgsProcessingColorParameterDefinitionWidget( QgsProcessingContext &context,
823  const QgsProcessingParameterWidgetContext &widgetContext,
824  const QgsProcessingParameterDefinition *definition = nullptr,
825  const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
826  QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, QgsProcessingParameterDefinition::Flags flags ) const override;
827 
828  private:
829 
830  QgsColorButton *mDefaultColorButton = nullptr;
831  QCheckBox *mAllowOpacity = nullptr;
832 
833 };
834 
835 class GUI_EXPORT QgsProcessingColorWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
836 {
837  Q_OBJECT
838 
839  public:
840 
841  QgsProcessingColorWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
842  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
843 
844  // QgsProcessingParameterWidgetFactoryInterface
845  QString parameterType() const override;
846  QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override;
848  QgsProcessingContext &context,
849  const QgsProcessingParameterWidgetContext &widgetContext,
850  const QgsProcessingParameterDefinition *definition = nullptr,
851  const QgsProcessingAlgorithm *algorithm = nullptr ) override;
852 
853  // QgsProcessingParameterWidgetWrapper interface
854  QWidget *createWidget() override SIP_FACTORY;
855 
856  protected:
857 
858  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
859  QVariant widgetValue() const override;
860 
861  QStringList compatibleParameterTypes() const override;
862 
863  QStringList compatibleOutputTypes() const override;
864 
865  QList< int > compatibleDataTypes() const override;
866  QString modelerExpressionFormatString() const override;
867  private:
868 
869  QgsColorButton *mColorButton = nullptr;
870  friend class TestProcessingGui;
871 };
872 
873 
875 
876 #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.
virtual QgsProcessingParameterDefinition * createParameter(const QString &name, const QString &description, QgsProcessingParameterDefinition::Flags flags) const =0
Returns a new instance of a parameter definition, using the current settings defined in the dialog...
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
Abstract base class for widgets which allow users to specify the properties of a Processing parameter...
A combobox which lets the user select map scale from predefined list and highlights nearest to curren...
WidgetType
Types of dialogs which Processing widgets can be created for.
An interface for Processing widget wrapper factories.
A class to represent a 2D point.
Definition: qgspointxy.h:43
Helper functions for various unit types.
Definition: qgsunittypes.h:38
A cross platform button subclass for selecting colors.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
Definition: qgsspinbox.h:42
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
QgsAuthConfigSelect(QWidget *parent=nullptr, const QString &dataprovider=QString())
Create a dialog for setting an associated authentication config, either from existing configs...
const QgsCoordinateReferenceSystem & crs
Abstract base class for processing algorithms.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:75
virtual QgsAbstractProcessingParameterWidgetWrapper * createWidgetWrapper(const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type)=0
Creates a new widget wrapper for the specified parameter definition.
The QgsLayoutItemComboBox class is a combo box which displays items of a matching type from a layout...
The QgsFileWidget class creates a widget for selecting a file or a folder.
Definition: qgsfilewidget.h:35
An enum based parameter for processing algorithms, allowing for selection from predefined values...
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
QLineEdit subclass with built in support for clearing the widget&#39;s value and handling custom null val...
#define SIP_FACTORY
Definition: qgis_sip.h:76
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
A widget for selecting a projection.
virtual QString parameterType() const =0
Returns the type string for the parameter type the factory is associated with.
Abstract base class for all map tools.
Definition: qgsmaptool.h:62
virtual QgsProcessingAbstractParameterDefinitionWidget * createParameterDefinitionWidget(QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition=nullptr, const QgsProcessingAlgorithm *algorithm=nullptr)
Creates a new parameter definition widget allowing for configuration of an instance of the parameter ...
Contains settings which reflect the context in which a Processing parameter widget is shown...
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
This class represents a coordinate reference system (CRS).
Base class for the definition of processing parameters.
Class that shows snapping marker on map canvas for the current snapping match.
virtual QWidget * createWidget()=0
Creates a new widget which allows customization of the parameter&#39;s value.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Represents a vector layer which manages a vector based data sets.
Contains information about the context in which a processing algorithm is executed.
The QgsLayoutComboBox class is a combo box which displays available layouts from a QgsLayoutManager...
Standard algorithm dialog.