QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
QgsProcessingModelerParameterWidget Class Reference

A widget for customising the value of Processing algorithm parameter inside a Processing model. More...

#include <qgsprocessingmodelerparameterwidget.h>

Inheritance diagram for QgsProcessingModelerParameterWidget:
Inheritance graph
[legend]

Public Member Functions

 QgsProcessingModelerParameterWidget (QgsProcessingModelAlgorithm *model, const QString &childId, const QgsProcessingParameterDefinition *parameter, QgsProcessingContext &context, QWidget *parent=nullptr)
 Constructor for QgsProcessingModelerParameterWidget, for the specified parameter definition within the given model.
 
 ~QgsProcessingModelerParameterWidget () override
 
QgsExpressionContext createExpressionContext () const override
 This method needs to be reimplemented in all classes which implement this interface and return an expression context.
 
QLabel * createLabel ()
 Creates a label for use identifying the associated parameter.
 
bool isModelOutput () const
 Returns true if the widget is set to the model output mode.
 
QString modelOutputName () const
 Returns the model output name, if isModelOutput() is true.
 
const QgsProcessingParameterDefinitionparameterDefinition () const
 Returns the parameter definition associated with this wrapper.
 
void populateSources (const QStringList &compatibleParameterTypes, const QStringList &compatibleOutputTypes, const QList< int > &compatibleDataTypes)
 Populates the widget with available sources for the parameter's value, e.g.
 
void registerProcessingContextGenerator (QgsProcessingContextGenerator *generator)
 Registers a Processing context generator class that will be used to retrieve a Processing context for the widget when required.
 
void setDialog (QDialog *dialog)
 Sets the parent dialog in which the widget is shown.
 
void setExpressionHelpText (const QString &text)
 Set the expected expression format text, which is shown in the expression builder dialog for the widget when in the "pre-calculated" expression mode.
 
void setSourceType (Qgis::ProcessingModelChildParameterSource type)
 Sets the current source type for the parameter.
 
void setToModelOutput (const QString &value)
 Sets the widget to a model output, for destination parameters only.
 
void setWidgetContext (const QgsProcessingParameterWidgetContext &context)
 Sets the context in which the modeler parameter widget is shown, e.g., the parent model algorithm and other relevant information which allows the widget to fine-tune its behavior.
 
virtual void setWidgetValue (const QgsProcessingModelChildParameterSource &value)
 Sets the current value for the parameter.
 
void setWidgetValue (const QList< QgsProcessingModelChildParameterSource > &values)
 Sets the current values for the parameter.
 
virtual QVariant value () const
 Returns the current value of the parameter.
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 

Friends

class TestProcessingGui
 

Detailed Description

A widget for customising the value of Processing algorithm parameter inside a Processing model.

The widget provides choice of the linked source for values for the parameter inside the model. E.g. parameters can be a static value, an evaluated expression results, the output from another child algorithm, or an input parameter for the model itself.

Individual modeler parameter widgets are not usually created directly, instead they are constructed through the central registry, via calls to QgsGui::processingGuiRegistry()->createModelerParameterWidget().

Since
QGIS 3.4

Definition at line 61 of file qgsprocessingmodelerparameterwidget.h.

Constructor & Destructor Documentation

◆ QgsProcessingModelerParameterWidget()

QgsProcessingModelerParameterWidget::QgsProcessingModelerParameterWidget ( QgsProcessingModelAlgorithm *  model,
const QString &  childId,
const QgsProcessingParameterDefinition parameter,
QgsProcessingContext context,
QWidget *  parent = nullptr 
)

Constructor for QgsProcessingModelerParameterWidget, for the specified parameter definition within the given model.

The ID of the child algorithm within the model must be specified via the childId argument. This value corresponds to the QgsProcessingModelChildAlgorithm::childId() string, which uniquely identifies which child algorithm the parameter is associated with inside the given model.

A Processing context must also be specified, which allows the widget to resolve parameter values which are context dependent. The context must last for the lifetime of the widget.

Definition at line 38 of file qgsprocessingmodelerparameterwidget.cpp.

◆ ~QgsProcessingModelerParameterWidget()

QgsProcessingModelerParameterWidget::~QgsProcessingModelerParameterWidget ( )
overridedefault

Member Function Documentation

◆ createExpressionContext()

QgsExpressionContext QgsProcessingModelerParameterWidget::createExpressionContext ( ) const
overridevirtual

This method needs to be reimplemented in all classes which implement this interface and return an expression context.

Implements QgsExpressionContextGenerator.

Definition at line 258 of file qgsprocessingmodelerparameterwidget.cpp.

◆ createLabel()

QLabel * QgsProcessingModelerParameterWidget::createLabel ( )

Creates a label for use identifying the associated parameter.

The caller takes ownership of the returned value.

Definition at line 157 of file qgsprocessingmodelerparameterwidget.cpp.

◆ isModelOutput()

bool QgsProcessingModelerParameterWidget::isModelOutput ( ) const

Returns true if the widget is set to the model output mode.

See also
setToModelOutput()
modelOutputName()
Since
QGIS 3.14

Definition at line 201 of file qgsprocessingmodelerparameterwidget.cpp.

◆ modelOutputName()

QString QgsProcessingModelerParameterWidget::modelOutputName ( ) const

Returns the model output name, if isModelOutput() is true.

See also
setToModelOutput()
isModelOutput()
Since
QGIS 3.14

Definition at line 206 of file qgsprocessingmodelerparameterwidget.cpp.

◆ parameterDefinition()

const QgsProcessingParameterDefinition * QgsProcessingModelerParameterWidget::parameterDefinition ( ) const

Returns the parameter definition associated with this wrapper.

Definition at line 152 of file qgsprocessingmodelerparameterwidget.cpp.

◆ populateSources()

void QgsProcessingModelerParameterWidget::populateSources ( const QStringList &  compatibleParameterTypes,
const QStringList &  compatibleOutputTypes,
const QList< int > &  compatibleDataTypes 
)

Populates the widget with available sources for the parameter's value, e.g.

adding the available child algorithm outputs and model input parameter choices.

In order to determine the available source, the compatibleParameterTypes and compatibleOutputTypes arguments are used. These lists correspond to the various available values for QgsProcessingParameterDefinition::type() (for compatibleParameterTypes) and the values for QgsProcessingOutputDefinition::type() (for compatibleOutputTypes).

The compatibleDataTypes list corresponds to the compatible data types from QgsProcessing::SourceType.

Definition at line 417 of file qgsprocessingmodelerparameterwidget.cpp.

◆ registerProcessingContextGenerator()

void QgsProcessingModelerParameterWidget::registerProcessingContextGenerator ( QgsProcessingContextGenerator generator)

Registers a Processing context generator class that will be used to retrieve a Processing context for the widget when required.

Definition at line 146 of file qgsprocessingmodelerparameterwidget.cpp.

◆ setDialog()

void QgsProcessingModelerParameterWidget::setDialog ( QDialog *  dialog)

Sets the parent dialog in which the widget is shown.

Since
QGIS 3.8

Definition at line 252 of file qgsprocessingmodelerparameterwidget.cpp.

◆ setExpressionHelpText()

void QgsProcessingModelerParameterWidget::setExpressionHelpText ( const QString &  text)

Set the expected expression format text, which is shown in the expression builder dialog for the widget when in the "pre-calculated" expression mode.

This is purely a text format and no expression validation is made against it.

Definition at line 455 of file qgsprocessingmodelerparameterwidget.cpp.

◆ setSourceType()

void QgsProcessingModelerParameterWidget::setSourceType ( Qgis::ProcessingModelChildParameterSource  type)

Sets the current source type for the parameter.

Since
QGIS 3.24

Definition at line 347 of file qgsprocessingmodelerparameterwidget.cpp.

◆ setToModelOutput()

void QgsProcessingModelerParameterWidget::setToModelOutput ( const QString &  value)

Sets the widget to a model output, for destination parameters only.

See also
isModelOutput()
modelOutputName()
Since
QGIS 3.14

Definition at line 194 of file qgsprocessingmodelerparameterwidget.cpp.

◆ setWidgetContext()

void QgsProcessingModelerParameterWidget::setWidgetContext ( const QgsProcessingParameterWidgetContext context)

Sets the context in which the modeler parameter widget is shown, e.g., the parent model algorithm and other relevant information which allows the widget to fine-tune its behavior.

Definition at line 140 of file qgsprocessingmodelerparameterwidget.cpp.

◆ setWidgetValue() [1/2]

void QgsProcessingModelerParameterWidget::setWidgetValue ( const QgsProcessingModelChildParameterSource &  value)
virtual

Sets the current value for the parameter.

See also
value()

Definition at line 165 of file qgsprocessingmodelerparameterwidget.cpp.

◆ setWidgetValue() [2/2]

void QgsProcessingModelerParameterWidget::setWidgetValue ( const QList< QgsProcessingModelChildParameterSource > &  values)

Sets the current values for the parameter.

See also
value()
Since
QGIS 3.14

Definition at line 179 of file qgsprocessingmodelerparameterwidget.cpp.

◆ value()

QVariant QgsProcessingModelerParameterWidget::value ( ) const
virtual

Returns the current value of the parameter.

See also
setWidgetValue()

Definition at line 211 of file qgsprocessingmodelerparameterwidget.cpp.

Friends And Related Symbol Documentation

◆ TestProcessingGui

friend class TestProcessingGui
friend

Definition at line 248 of file qgsprocessingmodelerparameterwidget.h.


The documentation for this class was generated from the following files: