QGIS API Documentation  3.14.0-Pi (9f7028fd23)
Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
QgsAbstractProcessingParameterWidgetWrapper Class Referenceabstract

#include <qgsprocessingwidgetwrapper.h>

Inheritance diagram for QgsAbstractProcessingParameterWidgetWrapper:
Inheritance graph
[legend]

Signals

void widgetValueHasChanged (QgsAbstractProcessingParameterWidgetWrapper *wrapper)
 Emitted whenever the parameter value (as defined by the wrapped widget) is changed. More...
 

Public Member Functions

 QgsAbstractProcessingParameterWidgetWrapper (const QgsProcessingParameterDefinition *parameter=nullptr, QgsProcessingGui::WidgetType type=QgsProcessingGui::Standard, QObject *parent=nullptr)
 Constructor for QgsAbstractProcessingParameterWidgetWrapper, for the specified parameter definition and dialog type. More...
 
QgsExpressionContext createExpressionContext () const override
 This method needs to be reimplemented in all classes which implement this interface and return an expression context. More...
 
QLabel * createWrappedLabel ()
 Creates and returns a new label to accompany widgets created by the wrapper. More...
 
QWidget * createWrappedWidget (QgsProcessingContext &context)
 Creates and return a new wrapped widget which allows customization of the parameter's value. More...
 
virtual QVariantMap customProperties () const
 Returns any custom properties set by the wrapper. More...
 
const QgsProcessingParameterDefinitionparameterDefinition () const
 Returns the parameter definition associated with this wrapper. More...
 
QVariant parameterValue () const
 Returns the current value of the parameter. More...
 
virtual void postInitialize (const QList< QgsAbstractProcessingParameterWidgetWrapper * > &wrappers)
 Called after all wrappers have been created within a particular dialog or context, allowing the wrapper to connect to the wrappers of other, related parameters. More...
 
void registerProcessingContextGenerator (QgsProcessingContextGenerator *generator)
 Registers a Processing context generator class that will be used to retrieve a Processing context for the wrapper when required. More...
 
void registerProcessingParametersGenerator (QgsProcessingParametersGenerator *generator)
 Registers a Processing parameters generator class that will be used to retrieve algorithm parameters for the wrapper when required (e.g. More...
 
virtual void setDialog (QDialog *dialog)
 Sets the parent dialog in which the wrapper is shown. More...
 
void setParameterValue (const QVariant &value, QgsProcessingContext &context)
 Sets the current value for the parameter. More...
 
virtual void setWidgetContext (const QgsProcessingParameterWidgetContext &context)
 Sets the context in which the Processing parameter widget is shown, e.g., the parent model algorithm, a linked map canvas, and other relevant information which allows the widget to fine-tune its behavior. More...
 
virtual int stretch () const
 Returns the Qt layout "stretch" factor to use when adding this widget to a layout. More...
 
QgsProcessingGui::WidgetType type () const
 Returns the dialog type for which widgets and labels will be created by this wrapper. More...
 
const QgsProcessingParameterWidgetContextwidgetContext () const
 Returns the context in which the Processing parameter widget is shown, e.g., the parent model algorithm, a linked map canvas, and other relevant information which allows the widget to fine-tune its behavior. More...
 
QLabel * wrappedLabel ()
 Returns the current wrapped label, if any. More...
 
QWidget * wrappedWidget ()
 Returns the current wrapped widget, if any. More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 

Protected Member Functions

virtual QLabel * createLabel ()
 Creates a new label to accompany widgets created by the wrapper. More...
 
virtual QWidget * createWidget ()=0
 Creates a new widget which allows customization of the parameter's value. More...
 
virtual const QgsVectorLayerlinkedVectorLayer () const
 Returns the optional vector layer associated with this widget wrapper, or nullptr if no vector layer is applicable. More...
 
virtual void setWidgetValue (const QVariant &value, QgsProcessingContext &context)=0
 Sets the current value for the parameter to show in the widget. More...
 
virtual QVariant widgetValue () const =0
 Returns the current value of the parameter. More...
 

Protected Attributes

QgsProcessingParametersGeneratormParametersGenerator = nullptr
 
QgsProcessingContextGeneratormProcessingContextGenerator = nullptr
 
QgsProcessingParameterWidgetContext mWidgetContext
 

Friends

class TestProcessingGui
 

Detailed Description

A widget wrapper for Processing parameter value widgets.

Widget wrappers are used to create widgets for individual Processing parameters, and handle retrieving and setting the current value for those parameters.

Widget wrappers can be created for different dialog types, allowing different appearance and behavior of widgets depending on whether they are being created for use in a standard algorithm dialog, a batch processing dialog, or a modeler dialog.

Individual widget wrappers are not usually created directly, instead they are constructed through the central registry, via calls to QgsGui::processingGuiRegistry()->createParameterWidgetWrapper().

Since
QGIS 3.4

Definition at line 266 of file qgsprocessingwidgetwrapper.h.

Constructor & Destructor Documentation

◆ QgsAbstractProcessingParameterWidgetWrapper()

QgsAbstractProcessingParameterWidgetWrapper::QgsAbstractProcessingParameterWidgetWrapper ( const QgsProcessingParameterDefinition parameter = nullptr,
QgsProcessingGui::WidgetType  type = QgsProcessingGui::Standard,
QObject *  parent = nullptr 
)

Constructor for QgsAbstractProcessingParameterWidgetWrapper, for the specified parameter definition and dialog type.

Definition at line 109 of file qgsprocessingwidgetwrapper.cpp.

Member Function Documentation

◆ createExpressionContext()

QgsExpressionContext QgsAbstractProcessingParameterWidgetWrapper::createExpressionContext ( ) const
overridevirtual

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

Since
QGIS 3.0

Implements QgsExpressionContextGenerator.

Definition at line 285 of file qgsprocessingwidgetwrapper.cpp.

◆ createLabel()

QLabel * QgsAbstractProcessingParameterWidgetWrapper::createLabel ( )
protectedvirtual

Creates a new label to accompany widgets created by the wrapper.

The caller takes ownership of the returned label. Some parameter type and dialog type combinations will return nullptr for this method. If NULLPTR is returned, then no label should be shown for the parameter's widget (i.e. the label is embedded inside the widget itself).

See also
createWidget()

Definition at line 225 of file qgsprocessingwidgetwrapper.cpp.

◆ createWidget()

virtual QWidget* QgsAbstractProcessingParameterWidgetWrapper::createWidget ( )
protectedpure virtual

Creates a new widget which allows customization of the parameter's value.

The caller takes ownership of the returned widget.

See also
createLabel()

◆ createWrappedLabel()

QLabel * QgsAbstractProcessingParameterWidgetWrapper::createWrappedLabel ( )

Creates and returns a new label to accompany widgets created by the wrapper.

The caller takes ownership of the returned label. Some parameter type and dialog type combinations will return nullptr for this method. If NULLPTR is returned, then no label should be shown for the parameter's widget (i.e. the label is embedded inside the widget itself).

The wrapped label can be retrieved at a later stage by calling wrappedLabel().

See also
createWrappedWidget()

Definition at line 163 of file qgsprocessingwidgetwrapper.cpp.

◆ createWrappedWidget()

QWidget * QgsAbstractProcessingParameterWidgetWrapper::createWrappedWidget ( QgsProcessingContext context)

Creates and return a new wrapped widget which allows customization of the parameter's value.

The caller takes ownership of the returned widget. The wrapped widget can be retrieved at a later stage by calling wrappedWidget().

The supplied context is used while initializing the widget to the parameter's default value.

See also
createWrappedLabel()

Definition at line 131 of file qgsprocessingwidgetwrapper.cpp.

◆ customProperties()

QVariantMap QgsAbstractProcessingParameterWidgetWrapper::customProperties ( ) const
virtual

Returns any custom properties set by the wrapper.

Definition at line 210 of file qgsprocessingwidgetwrapper.cpp.

◆ linkedVectorLayer()

const QgsVectorLayer * QgsAbstractProcessingParameterWidgetWrapper::linkedVectorLayer ( ) const
protectedvirtual

Returns the optional vector layer associated with this widget wrapper, or nullptr if no vector layer is applicable.

This is used to correctly generate expression contexts within the GUI, e.g. to allow expression buttons and property override buttons to correctly show the appropriate vector layer fields.

Since
QGIS 3.6

Definition at line 246 of file qgsprocessingwidgetwrapper.cpp.

◆ parameterDefinition()

const QgsProcessingParameterDefinition * QgsAbstractProcessingParameterWidgetWrapper::parameterDefinition ( ) const

Returns the parameter definition associated with this wrapper.

Definition at line 182 of file qgsprocessingwidgetwrapper.cpp.

◆ parameterValue()

QVariant QgsAbstractProcessingParameterWidgetWrapper::parameterValue ( ) const

Returns the current value of the parameter.

See also
setParameterValue()

Definition at line 202 of file qgsprocessingwidgetwrapper.cpp.

◆ postInitialize()

void QgsAbstractProcessingParameterWidgetWrapper::postInitialize ( const QList< QgsAbstractProcessingParameterWidgetWrapper * > &  wrappers)
virtual

Called after all wrappers have been created within a particular dialog or context, allowing the wrapper to connect to the wrappers of other, related parameters.

Definition at line 253 of file qgsprocessingwidgetwrapper.cpp.

◆ registerProcessingContextGenerator()

void QgsAbstractProcessingParameterWidgetWrapper::registerProcessingContextGenerator ( QgsProcessingContextGenerator generator)

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

Definition at line 215 of file qgsprocessingwidgetwrapper.cpp.

◆ registerProcessingParametersGenerator()

void QgsAbstractProcessingParameterWidgetWrapper::registerProcessingParametersGenerator ( QgsProcessingParametersGenerator generator)

Registers a Processing parameters generator class that will be used to retrieve algorithm parameters for the wrapper when required (e.g.

when a wrapper needs access to other parameter's values).

Since
QGIS 3.14

Definition at line 220 of file qgsprocessingwidgetwrapper.cpp.

◆ setDialog()

void QgsAbstractProcessingParameterWidgetWrapper::setDialog ( QDialog *  dialog)
virtual

Sets the parent dialog in which the wrapper is shown.

Since
QGIS 3.8

Definition at line 306 of file qgsprocessingwidgetwrapper.cpp.

◆ setParameterValue()

void QgsAbstractProcessingParameterWidgetWrapper::setParameterValue ( const QVariant &  value,
QgsProcessingContext context 
)

Sets the current value for the parameter.

The context argument is used to specify the wider Processing context which the current value is associated with.

See also
parameterValue()

Definition at line 187 of file qgsprocessingwidgetwrapper.cpp.

◆ setWidgetContext()

void QgsAbstractProcessingParameterWidgetWrapper::setWidgetContext ( const QgsProcessingParameterWidgetContext context)
virtual

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

Subclasses should take care to call the base class method when reimplementing this method.

See also
widgetContext()

Definition at line 121 of file qgsprocessingwidgetwrapper.cpp.

◆ setWidgetValue()

virtual void QgsAbstractProcessingParameterWidgetWrapper::setWidgetValue ( const QVariant &  value,
QgsProcessingContext context 
)
protectedpure virtual

Sets the current value for the parameter to show in the widget.

The context argument is used to specify the wider Processing context which the current value is associated with.

See also
widgetValue()

◆ stretch()

int QgsAbstractProcessingParameterWidgetWrapper::stretch ( ) const
virtual

Returns the Qt layout "stretch" factor to use when adding this widget to a layout.

The default implementation returns 0.

Since
QGIS 3.14

Definition at line 280 of file qgsprocessingwidgetwrapper.cpp.

◆ type()

QgsProcessingGui::WidgetType QgsAbstractProcessingParameterWidgetWrapper::type ( ) const

Returns the dialog type for which widgets and labels will be created by this wrapper.

Definition at line 116 of file qgsprocessingwidgetwrapper.cpp.

◆ widgetContext()

const QgsProcessingParameterWidgetContext & QgsAbstractProcessingParameterWidgetWrapper::widgetContext ( ) const

Returns the context in which the Processing parameter widget is shown, e.g., the parent model algorithm, a linked map canvas, and other relevant information which allows the widget to fine-tune its behavior.

See also
setWidgetContext()

Definition at line 126 of file qgsprocessingwidgetwrapper.cpp.

◆ widgetValue()

virtual QVariant QgsAbstractProcessingParameterWidgetWrapper::widgetValue ( ) const
protectedpure virtual

Returns the current value of the parameter.

See also
setWidgetValue()

◆ widgetValueHasChanged

void QgsAbstractProcessingParameterWidgetWrapper::widgetValueHasChanged ( QgsAbstractProcessingParameterWidgetWrapper wrapper)
signal

Emitted whenever the parameter value (as defined by the wrapped widget) is changed.

◆ wrappedLabel()

QLabel * QgsAbstractProcessingParameterWidgetWrapper::wrappedLabel ( )

Returns the current wrapped label, if any.

See also
createWrappedLabel()

Definition at line 177 of file qgsprocessingwidgetwrapper.cpp.

◆ wrappedWidget()

QWidget * QgsAbstractProcessingParameterWidgetWrapper::wrappedWidget ( )

Returns the current wrapped widget, if any.

See also
createWrappedWidget()

Definition at line 172 of file qgsprocessingwidgetwrapper.cpp.

Friends And Related Function Documentation

◆ TestProcessingGui

friend class TestProcessingGui
friend

Definition at line 496 of file qgsprocessingwidgetwrapper.h.

Member Data Documentation

◆ mParametersGenerator

QgsProcessingParametersGenerator* QgsAbstractProcessingParameterWidgetWrapper::mParametersGenerator = nullptr
protected

Definition at line 477 of file qgsprocessingwidgetwrapper.h.

◆ mProcessingContextGenerator

QgsProcessingContextGenerator* QgsAbstractProcessingParameterWidgetWrapper::mProcessingContextGenerator = nullptr
protected

Definition at line 476 of file qgsprocessingwidgetwrapper.h.

◆ mWidgetContext

QgsProcessingParameterWidgetContext QgsAbstractProcessingParameterWidgetWrapper::mWidgetContext
protected

Definition at line 478 of file qgsprocessingwidgetwrapper.h.


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