QGIS API Documentation 3.41.0-Master (3291e9ff48b)
|
A widget wrapper for Processing parameter value widgets. More...
#include <qgsprocessingwidgetwrapper.h>
Signals | |
void | widgetValueHasChanged (QgsAbstractProcessingParameterWidgetWrapper *wrapper) |
Emitted whenever the parameter value (as defined by the wrapped widget) is changed. | |
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. | |
QgsExpressionContext | createExpressionContext () const override |
This method needs to be reimplemented in all classes which implement this interface and return an expression context. | |
QLabel * | createWrappedLabel () |
Creates and returns a new label to accompany widgets created by the wrapper. | |
QWidget * | createWrappedWidget (QgsProcessingContext &context) |
Creates and return a new wrapped widget which allows customization of the parameter's value. | |
virtual QVariantMap | customProperties () const |
Returns any custom properties set by the wrapper. | |
const QgsProcessingParameterDefinition * | parameterDefinition () const |
Returns the parameter definition associated with this wrapper. | |
QVariant | parameterValue () const |
Returns the current value of the parameter. | |
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. | |
virtual void | registerProcessingContextGenerator (QgsProcessingContextGenerator *generator) |
Registers a Processing context generator class that will be used to retrieve a Processing context for the wrapper when required. | |
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. | |
virtual void | setDialog (QDialog *dialog) |
Sets the parent dialog in which the wrapper is shown. | |
void | setParameterValue (const QVariant &value, QgsProcessingContext &context) |
Sets the current value for the parameter. | |
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. | |
virtual int | stretch () const |
Returns the Qt layout "stretch" factor to use when adding this widget to a layout. | |
QgsProcessingGui::WidgetType | type () const |
Returns the dialog type for which widgets and labels will be created by this wrapper. | |
const QgsProcessingParameterWidgetContext & | 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. | |
QLabel * | wrappedLabel () |
Returns the current wrapped label, if any. | |
QWidget * | wrappedWidget () |
Returns the current wrapped widget, if any. | |
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. | |
virtual QWidget * | createWidget ()=0 |
Creates a new widget which allows customization of the parameter's value. | |
virtual const QgsVectorLayer * | linkedVectorLayer () const |
Returns the optional vector layer associated with this widget wrapper, or nullptr if no vector layer is applicable. | |
virtual void | setWidgetValue (const QVariant &value, QgsProcessingContext &context)=0 |
Sets the current value for the parameter to show in the widget. | |
virtual QVariant | widgetValue () const =0 |
Returns the current value of the parameter. | |
Protected Attributes | |
QgsProcessingParametersGenerator * | mParametersGenerator = nullptr |
QgsProcessingContextGenerator * | mProcessingContextGenerator = nullptr |
QgsProcessingParameterWidgetContext | mWidgetContext |
Friends | |
class | TestProcessingGui |
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().
Definition at line 278 of file qgsprocessingwidgetwrapper.h.
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.
|
overridevirtual |
This method needs to be reimplemented in all classes which implement this interface and return an expression context.
Implements QgsExpressionContextGenerator.
Definition at line 285 of file qgsprocessingwidgetwrapper.cpp.
|
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).
Reimplemented in QgsProcessingHiddenWidgetWrapper.
Definition at line 224 of file qgsprocessingwidgetwrapper.cpp.
|
protectedpure virtual |
Creates a new widget which allows customization of the parameter's value.
The caller takes ownership of the returned widget.
Implemented in QgsProcessingHiddenWidgetWrapper.
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().
Definition at line 162 of file qgsprocessingwidgetwrapper.cpp.
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.
Definition at line 131 of file qgsprocessingwidgetwrapper.cpp.
|
virtual |
Returns any custom properties set by the wrapper.
Definition at line 209 of file qgsprocessingwidgetwrapper.cpp.
|
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.
Reimplemented in QgsProcessingHiddenWidgetWrapper.
Definition at line 246 of file qgsprocessingwidgetwrapper.cpp.
const QgsProcessingParameterDefinition * QgsAbstractProcessingParameterWidgetWrapper::parameterDefinition | ( | ) | const |
Returns the parameter definition associated with this wrapper.
Definition at line 181 of file qgsprocessingwidgetwrapper.cpp.
QVariant QgsAbstractProcessingParameterWidgetWrapper::parameterValue | ( | ) | const |
Returns the current value of the parameter.
Definition at line 201 of file qgsprocessingwidgetwrapper.cpp.
|
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.
|
virtual |
Registers a Processing context generator class that will be used to retrieve a Processing context for the wrapper when required.
Care must be taken to call the base class implementation if overwrite this method.
Definition at line 214 of file qgsprocessingwidgetwrapper.cpp.
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).
Definition at line 219 of file qgsprocessingwidgetwrapper.cpp.
|
virtual |
Sets the parent dialog in which the wrapper is shown.
Definition at line 306 of file qgsprocessingwidgetwrapper.cpp.
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.
Definition at line 186 of file qgsprocessingwidgetwrapper.cpp.
|
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.
Definition at line 121 of file qgsprocessingwidgetwrapper.cpp.
|
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.
Implemented in QgsProcessingHiddenWidgetWrapper.
|
virtual |
Returns the Qt layout "stretch" factor to use when adding this widget to a layout.
The default implementation returns 0.
Definition at line 280 of file qgsprocessingwidgetwrapper.cpp.
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.
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.
Definition at line 126 of file qgsprocessingwidgetwrapper.cpp.
|
protectedpure virtual |
Returns the current value of the parameter.
Implemented in QgsProcessingHiddenWidgetWrapper.
|
signal |
Emitted whenever the parameter value (as defined by the wrapped widget) is changed.
QLabel * QgsAbstractProcessingParameterWidgetWrapper::wrappedLabel | ( | ) |
Returns the current wrapped label, if any.
Definition at line 176 of file qgsprocessingwidgetwrapper.cpp.
QWidget * QgsAbstractProcessingParameterWidgetWrapper::wrappedWidget | ( | ) |
Returns the current wrapped widget, if any.
Definition at line 171 of file qgsprocessingwidgetwrapper.cpp.
|
friend |
Definition at line 510 of file qgsprocessingwidgetwrapper.h.
|
protected |
Definition at line 491 of file qgsprocessingwidgetwrapper.h.
|
protected |
Definition at line 490 of file qgsprocessingwidgetwrapper.h.
|
protected |
Definition at line 492 of file qgsprocessingwidgetwrapper.h.