QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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 QgsProcessingContext &context,
70 const QgsProcessingParameterDefinition *definition = nullptr,
71 const QgsProcessingAlgorithm *algorithm = nullptr,
72 QWidget *parent SIP_TRANSFERTHIS = nullptr
73 );
74
82 virtual QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, Qgis::ProcessingParameterFlags flags ) const = 0 SIP_FACTORY;
83
94 virtual void setWidgetContext( const QgsProcessingParameterWidgetContext &context );
95
105
113
115
116 signals:
117
123 void changed();
124
125 private:
126 QgsProcessingContextGenerator *mContextGenerator = nullptr;
128};
129
130
137class GUI_EXPORT QgsProcessingParameterDefinitionWidget : public QWidget
138{
139 Q_OBJECT
140 public:
158 const QString &type,
159 QgsProcessingContext &context,
160 const QgsProcessingParameterWidgetContext &widgetContext,
161 const QgsProcessingParameterDefinition *definition = nullptr,
162 const QgsProcessingAlgorithm *algorithm = nullptr,
163 QWidget *parent SIP_TRANSFERTHIS = nullptr
164 );
165
171 QgsProcessingParameterDefinition *createParameter( const QString &name = QString() ) const SIP_FACTORY;
172
180
181 signals:
182
188 void changed();
189
190 private:
191 QString mType;
192 QgsProcessingAbstractParameterDefinitionWidget *mDefinitionWidget = nullptr;
193 QLineEdit *mDescriptionLineEdit = nullptr;
194 QCheckBox *mRequiredCheckBox = nullptr;
195 QCheckBox *mAdvancedCheckBox = nullptr;
196
198};
199
200
208{
209 Q_OBJECT
210 public:
227 const QString &type,
228 QgsProcessingContext &context,
229 const QgsProcessingParameterWidgetContext &widgetContext,
230 const QgsProcessingParameterDefinition *definition = nullptr,
231 const QgsProcessingAlgorithm *algorithm = nullptr,
232 QWidget *parent SIP_TRANSFERTHIS = nullptr
233 );
234
240 QgsProcessingParameterDefinition *createParameter( const QString &name = QString() ) const SIP_FACTORY;
241
246 void setComments( const QString &comments );
247
252 QString comments() const;
253
258 void setCommentColor( const QColor &color );
259
264 QColor commentColor() const;
265
269 void switchToCommentTab();
270
276
277 private:
278 QTabWidget *mTabWidget = nullptr;
279 QTextEdit *mCommentEdit = nullptr;
280 QgsColorButton *mCommentColorButton = nullptr;
282
284};
285
292class GUI_EXPORT QgsProcessingParameterDefinitionDialog : public QDialog
293{
294 Q_OBJECT
295 public:
313 const QString &type,
314 QgsProcessingContext &context,
315 const QgsProcessingParameterWidgetContext &widgetContext,
316 const QgsProcessingParameterDefinition *definition = nullptr,
317 const QgsProcessingAlgorithm *algorithm = nullptr,
318 QWidget *parent SIP_TRANSFERTHIS = nullptr
319 );
320
326 QgsProcessingParameterDefinition *createParameter( const QString &name = QString() ) const SIP_FACTORY;
327
333 void setComments( const QString &comments );
334
340 QString comments() const;
341
347 void setCommentColor( const QColor &color );
348
354 QColor commentColor() const;
355
359 void switchToCommentTab();
360
368
369 public slots:
370 void accept() override;
371
372 private:
374};
375
376
377#endif // QGSPROCESSINGPARAMETERDEFINITIONWIDGET_H
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
Definition qgis.h:3894
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