QGIS API Documentation 3.99.0-Master (a8f284845db)
Loading...
Searching...
No Matches
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 "qgis_gui.h"
23#include "qgis_sip.h"
26#include "qgspanelwidget.h"
29
30#include <QDialog>
31#include <QWidget>
32
34
35class QLineEdit;
36class QCheckBox;
37class QTabWidget;
38class QTextEdit;
39class QgsColorButton;
40
49{
50 Q_OBJECT
51
52 public:
68
76 virtual QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, Qgis::ProcessingParameterFlags flags ) const = 0 SIP_FACTORY;
77
88 virtual void setWidgetContext( const QgsProcessingParameterWidgetContext &context );
89
99
107
109
110 signals:
111
117 void changed();
118
119 private:
120 QgsProcessingContextGenerator *mContextGenerator = nullptr;
122};
123
124
131class GUI_EXPORT QgsProcessingParameterDefinitionWidget : public QWidget
132{
133 Q_OBJECT
134 public:
151 QgsProcessingParameterDefinitionWidget( const QString &type, QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition = nullptr, const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
152
158 QgsProcessingParameterDefinition *createParameter( const QString &name = QString() ) const SIP_FACTORY;
159
167
168 signals:
169
175 void changed();
176
177 private:
178 QString mType;
179 QgsProcessingAbstractParameterDefinitionWidget *mDefinitionWidget = nullptr;
180 QLineEdit *mDescriptionLineEdit = nullptr;
181 QCheckBox *mRequiredCheckBox = nullptr;
182 QCheckBox *mAdvancedCheckBox = nullptr;
183
185};
186
187
195{
196 Q_OBJECT
197 public:
213 QgsProcessingParameterDefinitionPanelWidget( const QString &type, QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition = nullptr, const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
214
220 QgsProcessingParameterDefinition *createParameter( const QString &name = QString() ) const SIP_FACTORY;
221
226 void setComments( const QString &comments );
227
232 QString comments() const;
233
238 void setCommentColor( const QColor &color );
239
244 QColor commentColor() const;
245
249 void switchToCommentTab();
250
256
257 private:
258 QTabWidget *mTabWidget = nullptr;
259 QTextEdit *mCommentEdit = nullptr;
260 QgsColorButton *mCommentColorButton = nullptr;
262
264};
265
272class GUI_EXPORT QgsProcessingParameterDefinitionDialog : public QDialog
273{
274 Q_OBJECT
275 public:
292 QgsProcessingParameterDefinitionDialog( const QString &type, QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition = nullptr, const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
293
299 QgsProcessingParameterDefinition *createParameter( const QString &name = QString() ) const SIP_FACTORY;
300
306 void setComments( const QString &comments );
307
313 QString comments() const;
314
320 void setCommentColor( const QColor &color );
321
327 QColor commentColor() const;
328
332 void switchToCommentTab();
333
341
342 public slots:
343 void accept() override;
344
345 private:
347};
348
349
350#endif // QGSPROCESSINGPARAMETERDEFINITIONWIDGET_H
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
Definition qgis.h:3863
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...
void changed()
Emitted whenever the definition of the parameter is changed in the widget.
QgsProcessingAbstractParameterDefinitionWidget(QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition=nullptr, const QgsProcessingAlgorithm *algorithm=nullptr, QWidget *parent=nullptr)
Creates a new QgsProcessingAbstractParameterDefinitionWidget, with the specified parent widget.
const QgsProcessingParameterWidgetContext & widgetContext() const
Returns the context in which the Processing definition widget is shown, e.g., the parent model algori...
virtual void setWidgetContext(const QgsProcessingParameterWidgetContext &context)
Sets the context in which the Processing definition widget is shown, e.g., the parent model algorithm...
virtual QgsProcessingParameterDefinition * createParameter(const QString &name, const QString &description, Qgis::ProcessingParameterFlags flags) const =0
Returns a new instance of a parameter definition, using the current settings defined in the dialog.
void registerProcessingContextGenerator(QgsProcessingContextGenerator *generator)
Registers a Processing context generator class that will be used to retrieve a Processing context for...
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.
QgsProcessingModelConfigWidget(QWidget *parent=nullptr)
Constructor for QgsProcessingModelConfigWidget().
void registerProcessingContextGenerator(QgsProcessingContextGenerator *generator)
Registers a Processing context generator class that will be used to retrieve a Processing context for...
void setComments(const QString &comments)
Sets the comments for the parameter.
void switchToCommentTab()
Switches the dialog to the comments tab.
QgsProcessingParameterDefinitionDialog(const QString &type, QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition=nullptr, const QgsProcessingAlgorithm *algorithm=nullptr, QWidget *parent=nullptr)
Constructor for QgsProcessingParameterDefinitionDialog, for a parameter of the specified type.
void setCommentColor(const QColor &color)
Sets the color for the comments for the parameter.
QgsProcessingParameterDefinition * createParameter(const QString &name=QString()) const
Returns a new instance of a parameter definition, using the current settings defined in the dialog.
QString comments() const
Returns the comments for the parameter.
QColor commentColor() const
Returns the color for the comments for the parameter.
A panel widget which allows users to specify the properties of a Processing parameter.
QColor commentColor() const
Returns the color for the comments for the parameter.
QgsProcessingParameterDefinition * createParameter(const QString &name=QString()) const
Returns a new instance of a parameter definition, using the current settings defined in the dialog.
void setComments(const QString &comments)
Sets the comments for the parameter.
void setCommentColor(const QColor &color)
Sets the color for the comments for the parameter.
void switchToCommentTab()
Switches the widget to the comments tab.
QString comments() const
Returns the comments for the parameter.
void registerProcessingContextGenerator(QgsProcessingContextGenerator *generator)
Registers a Processing context generator class that will be used to retrieve a Processing context for...
QgsProcessingParameterDefinitionPanelWidget(const QString &type, QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition=nullptr, const QgsProcessingAlgorithm *algorithm=nullptr, QWidget *parent=nullptr)
Constructor for QgsProcessingParameterDefinitionPanelWidget, for a parameter of the specified type.
A widget which allows users to specify the properties of a Processing parameter.
void registerProcessingContextGenerator(QgsProcessingContextGenerator *generator)
Registers a Processing context generator class that will be used to retrieve a Processing context for...
void changed()
Emitted whenever the definition of the parameter is changed in the widget.
QgsProcessingParameterDefinitionWidget(const QString &type, QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition=nullptr, const QgsProcessingAlgorithm *algorithm=nullptr, QWidget *parent=nullptr)
Constructor for QgsProcessingParameterDefinitionWidget, for a parameter of the specified type.
QgsProcessingParameterDefinition * createParameter(const QString &name=QString()) const
Returns a new instance of a parameter definition, using the current settings defined in the dialog.
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:52
#define SIP_FACTORY
Definition qgis_sip.h:83