24 #include "models/qgsprocessingmodelalgorithm.h" 
   28 #include <QHBoxLayout> 
   56   mBrowserModel = 
model;
 
   76   return mModelChildAlgorithmId;
 
  112   , mParameterDefinition( parameter )
 
  140     QHBoxLayout *hLayout = 
new QHBoxLayout();
 
  141     hLayout->setContentsMargins( 0, 0, 0, 0 );
 
  142     hLayout->addWidget( mWidget, 1 );
 
  144     hLayout->addWidget( mPropertyButton );
 
  146     mPropertyButton->registerEnabledWidget( mWidget, 
false );
 
  147     mPropertyButton->registerExpressionContextGenerator( 
this );
 
  183   return mParameterDefinition;
 
  188   if ( mPropertyButton && value.canConvert< 
QgsProperty >() )
 
  190     mPropertyButton->setToProperty( value.value< 
QgsProperty >() );
 
  194     if ( mPropertyButton )
 
  203   if ( mPropertyButton && mPropertyButton->isActive() )
 
  204     return mPropertyButton->toProperty();
 
  211   return QVariantMap();
 
  234       QString description = mParameterDefinition->
description();
 
  236         description = QObject::tr( 
"%1 [optional]" ).arg( description );
 
  237       std::unique_ptr< QLabel > label = qgis::make_unique< QLabel >( description );
 
  238       label->setToolTip( mParameterDefinition->
toolTip() );
 
  239       return label.release();
 
  247   if ( mPropertyButton )
 
  248     return mPropertyButton->vectorLayer();
 
  263           if ( wrapper->parameterDefinition()->name() == 
parameterDefinition()->dynamicLayerParameterName() )
 
  265             setDynamicParentLayerParameter( wrapper );
 
  289     std::unique_ptr< QgsExpressionContextScope > paramScope = qgis::make_unique< QgsExpressionContextScope >();
 
  291     for ( 
const QString &var : additional )
 
  293       paramScope->setVariable( var, QVariant() );
 
  299     highlighted.append( additional );
 
  314     setDynamicParentLayerParameter( wrapper );
 
  320   if ( mPropertyButton )
 
  324     std::unique_ptr< QgsProcessingContext > tmpContext;
 
  330       tmpContext = qgis::make_unique< QgsProcessingContext >();
 
  331       context = tmpContext.get();
 
  337       mPropertyButton->setVectorLayer( 
nullptr );
 
  343     std::unique_ptr< QgsMapLayer > ownedLayer( context->
takeResultLayer( layer->
id() ) );
 
  346       mDynamicLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
 
  347       layer = mDynamicLayer.get();
 
  354     mPropertyButton->setVectorLayer( layer );
 
  360   std::unique_ptr< QgsProcessingModelerParameterWidget > widget = qgis::make_unique< QgsProcessingModelerParameterWidget >( model, childId, parameter, context );
 
  363   return widget.release();
 
  375   return QList< int >();
 
  392   std::unique_ptr< QgsProcessingContext > tmpContext;
 
  393   if ( processingContextGenerator )
 
  398     tmpContext = qgis::make_unique< QgsProcessingContext >();
 
  399     context = tmpContext.get();
 
  404   if ( 
auto *lModel = widgetContext.
model() )
 
  417     QStringList highlightedVariables = childScope->
variableNames();
 
  418     QStringList highlightedFunctions = childScope->functionNames();
 
  419     highlightedVariables += algorithmScope->variableNames();
 
  420     highlightedVariables += lModel->variables().keys();
 
  421     highlightedFunctions += algorithmScope->functionNames();
 
  422     c.setHighlightedVariables( highlightedVariables );
 
  423     c.setHighlightedFunctions( highlightedFunctions );
 
  446   if ( mValue == value )
 
A model for showing available data sources and other items in a structured tree.
Single scope for storing variables and functions for use within a QgsExpressionContext.
QStringList variableNames() const
Returns a list of variable names contained within the scope.
static QgsExpressionContextScope * processingModelAlgorithmScope(const QgsProcessingModelAlgorithm *model, const QVariantMap ¶meters, QgsProcessingContext &context)
Creates a new scope which contains variables and functions relating to a processing model algorithm,...
static QgsExpressionContextScope * processingAlgorithmScope(const QgsProcessingAlgorithm *algorithm, const QVariantMap ¶meters, QgsProcessingContext &context)
Creates a new scope which contains variables and functions relating to a processing algorithm,...
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QStringList highlightedVariables() const
Returns the current list of variables highlighted within the context.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
A bar for displaying non-blocking messages to the user.
Abstract base class for processing algorithms.
An interface for objects which can create Processing contexts.
virtual QgsProcessingContext * processingContext()=0
This method needs to be reimplemented in all classes which implement this interface and return a Proc...
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
QgsMapLayer * takeResultLayer(const QString &id)
Takes the result map layer with matching id from the context and transfers ownership of it back to th...
Base class for all parameter definitions which represent file or layer destinations,...
WidgetType
Types of dialogs which Processing widgets can be created for.
@ Standard
Standard algorithm dialog.
@ Batch
Batch processing dialog.
Base class for the definition of processing parameters.
QStringList additionalExpressionContextVariables() const
Returns a list of additional expression context variables which are available for use when evaluating...
virtual QString toolTip() const
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
QgsProcessingAlgorithm * algorithm() const
Returns a pointer to the algorithm which owns this parameter.
QString description() const
Returns the description for the parameter.
QVariant defaultValueForGui() const
Returns the default value to use for the parameter in a GUI.
@ FlagOptional
Parameter is optional.
bool isDynamic() const
Returns true if the parameter supports is dynamic, and can support data-defined values (i....
QgsPropertyDefinition dynamicPropertyDefinition() const
Returns the property definition for dynamic properties.
Contains settings which reflect the context in which a Processing parameter widget is shown,...
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsProject * project() const
Returns the project associated with the widget.
QgsBrowserGuiModel * browserModel() const
Returns the browser model associated with the widget.
void setActiveLayer(QgsMapLayer *layer)
Sets the current active layer.
void setModelChildAlgorithmId(const QString &id)
Sets the child algorithm id within the model which the parameter widget is associated with.
void setProject(QgsProject *project)
Sets the project associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
void setBrowserModel(QgsBrowserGuiModel *model)
Sets the browser model associated with the widget.
QgsProcessingModelAlgorithm * model() const
Returns the model which the parameter widget is associated with.
void setMessageBar(QgsMessageBar *bar)
Sets the message bar associated with the widget.
QgsMapLayer * activeLayer() const
Returns the current active layer.
void setModel(QgsProcessingModelAlgorithm *model)
Sets the model which the parameter widget is associated with.
QString modelChildAlgorithmId() const
Returns the child algorithm ID within the model which the parameter widget is associated with.
An interface for objects which can create sets of parameter values for processing algorithms.
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
A store for object properties.
Represents a vector layer which manages a vector based data sets.
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
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 c