QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsprocessingparameterdefinitionwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingparameterdefinitionwidget.h
3  ----------------------------------------
4  begin : July 2019
5  copyright : (C) 2019 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 QGSPROCESSINGPARAMETERDEFINITIONWIDGET_H
20 #define QGSPROCESSINGPARAMETERDEFINITIONWIDGET_H
21 
22 #include <QWidget>
23 #include <QDialog>
24 
25 #include "qgis_gui.h"
26 #include "qgis_sip.h"
28 
30 class QLineEdit;
31 class QCheckBox;
32 class QTabWidget;
33 class QTextEdit;
34 class QgsColorButton;
35 
43 class GUI_EXPORT QgsProcessingAbstractParameterDefinitionWidget : public QWidget
44 {
45  Q_OBJECT
46 
47  public:
48 
64  const QgsProcessingParameterWidgetContext &widgetContext,
65  const QgsProcessingParameterDefinition *definition = nullptr,
66  const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
67 
75  virtual QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, QgsProcessingParameterDefinition::Flags flags ) const = 0 SIP_FACTORY;
76 };
77 
78 
85 class GUI_EXPORT QgsProcessingParameterDefinitionWidget: public QWidget
86 {
87  Q_OBJECT
88  public:
89 
106  QgsProcessingParameterDefinitionWidget( const QString &type,
107  QgsProcessingContext &context,
108  const QgsProcessingParameterWidgetContext &widgetContext,
109  const QgsProcessingParameterDefinition *definition = nullptr,
110  const QgsProcessingAlgorithm *algorithm = nullptr,
111  QWidget *parent SIP_TRANSFERTHIS = nullptr );
112 
118  QgsProcessingParameterDefinition *createParameter( const QString &name = QString() ) const SIP_FACTORY;
119 
120  private:
121 
122  QString mType;
123  QgsProcessingAbstractParameterDefinitionWidget *mDefinitionWidget = nullptr;
124  QLineEdit *mDescriptionLineEdit = nullptr;
125  QCheckBox *mRequiredCheckBox = nullptr;
126  QCheckBox *mAdvancedCheckBox = nullptr;
127 
129 
130 };
131 
138 class GUI_EXPORT QgsProcessingParameterDefinitionDialog: public QDialog
139 {
140  Q_OBJECT
141  public:
142 
159  QgsProcessingParameterDefinitionDialog( const QString &type,
160  QgsProcessingContext &context,
161  const QgsProcessingParameterWidgetContext &widgetContext,
162  const QgsProcessingParameterDefinition *definition = nullptr,
163  const QgsProcessingAlgorithm *algorithm = nullptr,
164  QWidget *parent SIP_TRANSFERTHIS = nullptr );
165 
171  QgsProcessingParameterDefinition *createParameter( const QString &name = QString() ) const SIP_FACTORY;
172 
178  void setComments( const QString &comments );
179 
185  QString comments() const;
186 
192  void setCommentColor( const QColor &color );
193 
199  QColor commentColor() const;
200 
204  void switchToCommentTab();
205 
206  public slots:
207  void accept() override;
208 
209  private:
210 
211  QTabWidget *mTabWidget = nullptr;
212  QTextEdit *mCommentEdit = nullptr;
213  QgsColorButton *mCommentColorButton = nullptr;
214  QgsProcessingParameterDefinitionWidget *mWidget = nullptr;
215 
216 };
217 
218 
219 #endif // QGSPROCESSINGPARAMETERDEFINITIONWIDGET_H
QgsProcessingParameterWidgetContext
Contains settings which reflect the context in which a Processing parameter widget is shown,...
Definition: qgsprocessingwidgetwrapper.h:100
algorithm
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
QgsProcessingParameterDefinitionWidget
A widget which allow users to specify the properties of a Processing parameter.
Definition: qgsprocessingparameterdefinitionwidget.h:86
QgsProcessingParameterDefinition
Base class for the definition of processing parameters.
Definition: qgsprocessingparameters.h:331
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition: qgsprocessingcontext.h:44
QgsProcessingAbstractParameterDefinitionWidget::createParameter
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.
qgis_sip.h
QgsProcessingAbstractParameterDefinitionWidget
Abstract base class for widgets which allow users to specify the properties of a Processing parameter...
Definition: qgsprocessingparameterdefinitionwidget.h:44
qgsprocessingparameters.h
QgsProcessingAlgorithm
Abstract base class for processing algorithms.
Definition: qgsprocessingalgorithm.h:52
QgsProcessingParameterDefinitionDialog
A dialog which allow users to specify the properties of a Processing parameter.
Definition: qgsprocessingparameterdefinitionwidget.h:139
QgsColorButton
A cross platform button subclass for selecting colors.
Definition: qgscolorbutton.h:36
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53