QGIS API Documentation  3.20.0-Odense (decaadbb31)
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"
30 
32 
33 class QLineEdit;
34 class QCheckBox;
35 class QTabWidget;
36 class QTextEdit;
37 class QgsColorButton;
38 
47 {
48  Q_OBJECT
49 
50  public:
51 
67  const QgsProcessingParameterWidgetContext &widgetContext,
68  const QgsProcessingParameterDefinition *definition = nullptr,
69  const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
70 
78  virtual QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, QgsProcessingParameterDefinition::Flags flags ) const = 0 SIP_FACTORY;
79 
90  virtual void setWidgetContext( const QgsProcessingParameterWidgetContext &context );
91 
100  const QgsProcessingParameterWidgetContext &widgetContext() const;
101 
108  void registerProcessingContextGenerator( QgsProcessingContextGenerator *generator );
109 
111 
112  private:
113 
114  QgsProcessingContextGenerator *mContextGenerator = nullptr;
116 };
117 
118 
125 class GUI_EXPORT QgsProcessingParameterDefinitionWidget: public QWidget
126 {
127  Q_OBJECT
128  public:
129 
146  QgsProcessingParameterDefinitionWidget( const QString &type,
147  QgsProcessingContext &context,
148  const QgsProcessingParameterWidgetContext &widgetContext,
149  const QgsProcessingParameterDefinition *definition = nullptr,
150  const QgsProcessingAlgorithm *algorithm = nullptr,
151  QWidget *parent SIP_TRANSFERTHIS = nullptr );
152 
158  QgsProcessingParameterDefinition *createParameter( const QString &name = QString() ) const SIP_FACTORY;
159 
166  void registerProcessingContextGenerator( QgsProcessingContextGenerator *generator );
167 
168  private:
169 
170  QString mType;
171  QgsProcessingAbstractParameterDefinitionWidget *mDefinitionWidget = nullptr;
172  QLineEdit *mDescriptionLineEdit = nullptr;
173  QCheckBox *mRequiredCheckBox = nullptr;
174  QCheckBox *mAdvancedCheckBox = nullptr;
175 
177 
178 };
179 
186 class GUI_EXPORT QgsProcessingParameterDefinitionDialog: public QDialog
187 {
188  Q_OBJECT
189  public:
190 
207  QgsProcessingParameterDefinitionDialog( const QString &type,
208  QgsProcessingContext &context,
209  const QgsProcessingParameterWidgetContext &widgetContext,
210  const QgsProcessingParameterDefinition *definition = nullptr,
211  const QgsProcessingAlgorithm *algorithm = nullptr,
212  QWidget *parent SIP_TRANSFERTHIS = nullptr );
213 
219  QgsProcessingParameterDefinition *createParameter( const QString &name = QString() ) const SIP_FACTORY;
220 
226  void setComments( const QString &comments );
227 
233  QString comments() const;
234 
240  void setCommentColor( const QColor &color );
241 
247  QColor commentColor() const;
248 
252  void switchToCommentTab();
253 
260  void registerProcessingContextGenerator( QgsProcessingContextGenerator *generator );
261 
262  public slots:
263  void accept() override;
264 
265  private:
266 
267  QTabWidget *mTabWidget = nullptr;
268  QTextEdit *mCommentEdit = nullptr;
269  QgsColorButton *mCommentColorButton = nullptr;
270  QgsProcessingParameterDefinitionWidget *mWidget = nullptr;
271 
272 };
273 
274 
275 #endif // QGSPROCESSINGPARAMETERDEFINITIONWIDGET_H
A cross platform button subclass for selecting colors.
Abstract interface for generating an expression context.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Abstract base class for widgets which allow users to specify the properties of a Processing parameter...
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.
Abstract base class for processing algorithms.
An interface for objects which can create Processing contexts.
Contains information about the context in which a processing algorithm is executed.
A dialog which allow users to specify the properties of a Processing parameter.
A widget which allow users to specify the properties of a Processing parameter.
Base class for the definition of processing parameters.
Contains settings which reflect the context in which a Processing parameter widget is shown,...
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
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_FACTORY
Definition: qgis_sip.h:76