QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsprocessingwidgetwrapper.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingwidgetwrapper.cpp
3  ---------------------
4  begin : August 2018
5  copyright : (C) 2018 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 
23 #include "qgsexpressioncontext.h"
24 #include "models/qgsprocessingmodelalgorithm.h"
27 #include <QLabel>
28 #include <QHBoxLayout>
29 
30 //
31 // QgsProcessingParameterWidgetContext
32 //
33 
35 {
36  mMapCanvas = canvas;
37 }
38 
40 {
41  return mMapCanvas;
42 }
43 
45 {
46  mMessageBar = bar;
47 }
48 
50 {
51  return mMessageBar;
52 }
53 
55 {
56  mBrowserModel = model;
57 }
58 
60 {
61  return mBrowserModel;
62 }
63 
65 {
66  mProject = project;
67 }
68 
70 {
71  return mProject;
72 }
73 
75 {
76  return mModelChildAlgorithmId;
77 }
78 
79 void QgsProcessingParameterWidgetContext::setModelChildAlgorithmId( const QString &modelChildAlgorithmId )
80 {
81  mModelChildAlgorithmId = modelChildAlgorithmId;
82 }
83 
85 {
86  return mActiveLayer;
87 }
88 
90 {
91  mActiveLayer = activeLayer;
92 }
93 
94 QgsProcessingModelAlgorithm *QgsProcessingParameterWidgetContext::model() const
95 {
96  return mModel;
97 }
98 
99 void QgsProcessingParameterWidgetContext::setModel( QgsProcessingModelAlgorithm *model )
100 {
101  mModel = model;
102 }
103 
104 
105 //
106 // QgsAbstractProcessingParameterWidgetWrapper
107 //
108 
110  : QObject( parent )
111  , mType( type )
112  , mParameterDefinition( parameter )
113 {
114 }
115 
117 {
118  return mType;
119 }
120 
122 {
123  mWidgetContext = context;
124 }
125 
127 {
128  return mWidgetContext;
129 }
130 
132 {
133  if ( mWidget )
134  return mWidget;
135 
136  mWidget = createWidget();
137  QWidget *wrappedWidget = mWidget;
138  if ( mParameterDefinition->isDynamic() )
139  {
140  QHBoxLayout *hLayout = new QHBoxLayout();
141  hLayout->setContentsMargins( 0, 0, 0, 0 );
142  hLayout->addWidget( mWidget, 1 );
143  mPropertyButton = new QgsPropertyOverrideButton();
144  hLayout->addWidget( mPropertyButton );
145  mPropertyButton->init( 0, QgsProperty(), mParameterDefinition->dynamicPropertyDefinition() );
146  mPropertyButton->registerEnabledWidget( mWidget, false );
147  mPropertyButton->registerExpressionContextGenerator( this );
148 
149  wrappedWidget = new QWidget();
150  wrappedWidget->setLayout( hLayout );
151  }
152 
153  if ( !dynamic_cast<const QgsProcessingDestinationParameter * >( mParameterDefinition ) )
154  {
155  // an exception -- output widgets handle this themselves
156  setWidgetValue( mParameterDefinition->defaultValue(), context );
157  }
158 
159  return wrappedWidget;
160 }
161 
163 {
164  if ( mLabel )
165  return mLabel;
166 
167  mLabel = createLabel();
168  return mLabel;
169 }
170 
172 {
173  return mWidget;
174 }
175 
177 {
178  return mLabel;
179 }
180 
182 {
183  return mParameterDefinition;
184 }
185 
187 {
188  if ( mPropertyButton && value.canConvert< QgsProperty >() )
189  {
190  mPropertyButton->setToProperty( value.value< QgsProperty >() );
191  }
192  else
193  {
194  if ( mPropertyButton )
195  mPropertyButton->setToProperty( QgsProperty() );
196 
197  setWidgetValue( value, context );
198  }
199 }
200 
202 {
203  if ( mPropertyButton && mPropertyButton->isActive() )
204  return mPropertyButton->toProperty();
205  else
206  return widgetValue();
207 }
208 
210 {
211  return QVariantMap();
212 }
213 
215 {
216  mProcessingContextGenerator = generator;
217 }
218 
220 {
221  mParametersGenerator = generator;
222 }
223 
225 {
226  switch ( mType )
227  {
229  return nullptr;
230 
233  {
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();
240  }
241  }
242  return nullptr;
243 }
244 
246 {
247  if ( mPropertyButton )
248  return mPropertyButton->vectorLayer();
249  return nullptr;
250 }
251 
252 void QgsAbstractProcessingParameterWidgetWrapper::postInitialize( const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers )
253 {
254  switch ( mType )
255  {
258  {
259  if ( parameterDefinition()->isDynamic() )
260  {
261  for ( const QgsAbstractProcessingParameterWidgetWrapper *wrapper : wrappers )
262  {
263  if ( wrapper->parameterDefinition()->name() == parameterDefinition()->dynamicLayerParameterName() )
264  {
265  setDynamicParentLayerParameter( wrapper );
266  connect( wrapper, &QgsAbstractProcessingParameterWidgetWrapper::widgetValueHasChanged, this, &QgsAbstractProcessingParameterWidgetWrapper::parentLayerChanged );
267  break;
268  }
269  }
270  }
271  break;
272  }
273 
275  break;
276  }
277 }
278 
280 {
281  return 0;
282 }
283 
285 {
286  QgsExpressionContext context = QgsProcessingGuiUtils::createExpressionContext( mProcessingContextGenerator, mWidgetContext, mParameterDefinition ? mParameterDefinition->algorithm() : nullptr, linkedVectorLayer() );
287  if ( mParameterDefinition && !mParameterDefinition->additionalExpressionContextVariables().isEmpty() )
288  {
289  std::unique_ptr< QgsExpressionContextScope > paramScope = qgis::make_unique< QgsExpressionContextScope >();
290  const QStringList additional = mParameterDefinition->additionalExpressionContextVariables();
291  for ( const QString &var : additional )
292  {
293  paramScope->setVariable( var, QVariant() );
294  }
295  context.appendScope( paramScope.release() );
296 
297  // we always highlight additional variables for visibility
298  QStringList highlighted = context.highlightedVariables();
299  highlighted.append( additional );
300  context.setHighlightedVariables( highlighted );
301  }
302  return context;
303 }
304 
306 {
307 
308 }
309 
310 void QgsAbstractProcessingParameterWidgetWrapper::parentLayerChanged( QgsAbstractProcessingParameterWidgetWrapper *wrapper )
311 {
312  if ( wrapper )
313  {
314  setDynamicParentLayerParameter( wrapper );
315  }
316 }
317 
318 void QgsAbstractProcessingParameterWidgetWrapper::setDynamicParentLayerParameter( const QgsAbstractProcessingParameterWidgetWrapper *parentWrapper )
319 {
320  if ( mPropertyButton )
321  {
322  // evaluate value to layer
323  QgsProcessingContext *context = nullptr;
324  std::unique_ptr< QgsProcessingContext > tmpContext;
327 
328  if ( !context )
329  {
330  tmpContext = qgis::make_unique< QgsProcessingContext >();
331  context = tmpContext.get();
332  }
333 
334  QgsVectorLayer *layer = QgsProcessingParameters::parameterAsVectorLayer( parentWrapper->parameterDefinition(), parentWrapper->parameterValue(), *context );
335  if ( !layer )
336  {
337  mPropertyButton->setVectorLayer( nullptr );
338  return;
339  }
340 
341  // need to grab ownership of layer if required - otherwise layer may be deleted when context
342  // goes out of scope
343  std::unique_ptr< QgsMapLayer > ownedLayer( context->takeResultLayer( layer->id() ) );
344  if ( ownedLayer && ownedLayer->type() == QgsMapLayerType::VectorLayer )
345  {
346  mDynamicLayer.reset( qobject_cast< QgsVectorLayer * >( ownedLayer.release() ) );
347  layer = mDynamicLayer.get();
348  }
349  else
350  {
351  // don't need ownership of this layer - it wasn't owned by context (so e.g. is owned by the project)
352  }
353 
354  mPropertyButton->setVectorLayer( layer );
355  }
356 }
357 
359 {
360  std::unique_ptr< QgsProcessingModelerParameterWidget > widget = qgis::make_unique< QgsProcessingModelerParameterWidget >( model, childId, parameter, context );
361  widget->populateSources( compatibleParameterTypes(), compatibleOutputTypes(), compatibleDataTypes( parameter ) );
362  widget->setExpressionHelpText( modelerExpressionFormatString() );
363  return widget.release();
364 }
365 
368  const QgsProcessingAlgorithm * )
369 {
370  return nullptr;
371 }
372 
374 {
375  return QList< int >();
376 }
377 
379 {
380  return QString();
381 }
382 
383 //
384 // QgsProcessingGuiUtils
385 //
386 
388 QgsExpressionContext QgsProcessingGuiUtils::createExpressionContext( QgsProcessingContextGenerator *processingContextGenerator, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingAlgorithm *algorithm, const QgsVectorLayer *linkedLayer )
389 {
390  // Get a processing context to start with
391  QgsProcessingContext *context = nullptr;
392  std::unique_ptr< QgsProcessingContext > tmpContext;
393  if ( processingContextGenerator )
394  context = processingContextGenerator->processingContext();
395 
396  if ( !context )
397  {
398  tmpContext = qgis::make_unique< QgsProcessingContext >();
399  context = tmpContext.get();
400  }
401 
403 
404  if ( auto *lModel = widgetContext.model() )
405  {
406  c << QgsExpressionContextUtils::processingModelAlgorithmScope( lModel, QVariantMap(), *context );
407 
408  const QgsProcessingAlgorithm *alg = nullptr;
409  if ( lModel->childAlgorithms().contains( widgetContext.modelChildAlgorithmId() ) )
410  alg = lModel->childAlgorithm( widgetContext.modelChildAlgorithmId() ).algorithm();
411 
412  QgsExpressionContextScope *algorithmScope = QgsExpressionContextUtils::processingAlgorithmScope( alg ? alg : algorithm, QVariantMap(), *context );
413  c << algorithmScope;
414  QgsExpressionContextScope *childScope = lModel->createExpressionContextScopeForChildAlgorithm( widgetContext.modelChildAlgorithmId(), *context, QVariantMap(), QVariantMap() );
415  c << childScope;
416 
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 );
424  }
425  else
426  {
427  if ( algorithm )
428  c << QgsExpressionContextUtils::processingAlgorithmScope( algorithm, QVariantMap(), *context );
429  }
430 
431  if ( linkedLayer )
432  c << QgsExpressionContextUtils::layerScope( linkedLayer );
433 
434  return c;
435 }
437 
439  : QgsAbstractProcessingParameterWidgetWrapper( parameter, type, parent )
440 {
441 
442 }
443 
445 {
446  if ( mValue == value )
447  return;
448 
449  mValue = value;
450  emit widgetValueHasChanged( this );
451 }
452 
454 {
455  return mValue;
456 }
457 
459 {
460  return mLayer;
461 }
462 
464 {
465  mLayer = layer;
466 }
467 
469 {
470  return nullptr;
471 
472 }
473 
475 {
476  return nullptr;
477 }
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:370
QgsProcessingParameterWidgetContext::activeLayer
QgsMapLayer * activeLayer() const
Returns the current active layer.
Definition: qgsprocessingwidgetwrapper.cpp:84
QgsProcessingParameterWidgetContext
Contains settings which reflect the context in which a Processing parameter widget is shown,...
Definition: qgsprocessingwidgetwrapper.h:100
qgsexpressioncontextutils.h
QgsProcessingHiddenWidgetWrapper::setWidgetValue
void setWidgetValue(const QVariant &value, QgsProcessingContext &context) override
Sets the current value for the parameter to show in the widget.
Definition: qgsprocessingwidgetwrapper.cpp:444
QgsAbstractProcessingParameterWidgetWrapper::createWidget
virtual QWidget * createWidget()=0
Creates a new widget which allows customization of the parameter's value.
QgsProperty
A store for object properties.
Definition: qgsproperty.h:232
QgsProcessingParameterWidgetContext::setModelChildAlgorithmId
void setModelChildAlgorithmId(const QString &id)
Sets the child algorithm id within the model which the parameter widget is associated with.
Definition: qgsprocessingwidgetwrapper.cpp:79
QgsMapLayerType::VectorLayer
@ VectorLayer
QgsProcessingParameterDefinition::description
QString description() const
Returns the description for the parameter.
Definition: qgsprocessingparameters.h:474
QgsProcessingParameterWidgetContext::mapCanvas
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
Definition: qgsprocessingwidgetwrapper.cpp:39
algorithm
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
QgsProcessingContext::takeResultLayer
QgsMapLayer * takeResultLayer(const QString &id)
Takes the result map layer with matching id from the context and transfers ownership of it back to th...
Definition: qgsprocessingcontext.cpp:126
QgsProcessingParameterWidgetContext::setModel
void setModel(QgsProcessingModelAlgorithm *model)
Sets the model which the parameter widget is associated with.
Definition: qgsprocessingwidgetwrapper.cpp:99
QgsAbstractProcessingParameterWidgetWrapper::createWrappedWidget
QWidget * createWrappedWidget(QgsProcessingContext &context)
Creates and return a new wrapped widget which allows customization of the parameter's value.
Definition: qgsprocessingwidgetwrapper.cpp:131
QgsAbstractProcessingParameterWidgetWrapper::setWidgetContext
virtual void setWidgetContext(const QgsProcessingParameterWidgetContext &context)
Sets the context in which the Processing parameter widget is shown, e.g., the parent model algorithm,...
Definition: qgsprocessingwidgetwrapper.cpp:121
QgsExpressionContextUtils::layerScope
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Definition: qgsexpressioncontextutils.cpp:265
QgsAbstractProcessingParameterWidgetWrapper::registerProcessingParametersGenerator
void registerProcessingParametersGenerator(QgsProcessingParametersGenerator *generator)
Registers a Processing parameters generator class that will be used to retrieve algorithm parameters ...
Definition: qgsprocessingwidgetwrapper.cpp:219
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
QgsProcessingParameterWidgetContext::setMessageBar
void setMessageBar(QgsMessageBar *bar)
Sets the message bar associated with the widget.
Definition: qgsprocessingwidgetwrapper.cpp:44
QgsProcessingParameterDefinition::additionalExpressionContextVariables
QStringList additionalExpressionContextVariables() const
Returns a list of additional expression context variables which are available for use when evaluating...
Definition: qgsprocessingparameters.h:697
QgsAbstractProcessingParameterWidgetWrapper::mParametersGenerator
QgsProcessingParametersGenerator * mParametersGenerator
Definition: qgsprocessingwidgetwrapper.h:477
QgsProcessingParameterDefinition
Base class for the definition of processing parameters.
Definition: qgsprocessingparameters.h:331
QgsProcessingParameterDefinition::isDynamic
bool isDynamic() const
Returns true if the parameter supports is dynamic, and can support data-defined values (i....
Definition: qgsprocessingparameters.h:631
QgsAbstractProcessingParameterWidgetWrapper
A widget wrapper for Processing parameter value widgets.
Definition: qgsprocessingwidgetwrapper.h:267
QgsAbstractProcessingParameterWidgetWrapper::wrappedLabel
QLabel * wrappedLabel()
Returns the current wrapped label, if any.
Definition: qgsprocessingwidgetwrapper.cpp:176
QgsProcessingParameterWidgetContext::setActiveLayer
void setActiveLayer(QgsMapLayer *layer)
Sets the current active layer.
Definition: qgsprocessingwidgetwrapper.cpp:89
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:95
QgsProcessingGui::Standard
@ Standard
Standard algorithm dialog.
Definition: qgsprocessinggui.h:40
QgsExpressionContextScope::variableNames
QStringList variableNames() const
Returns a list of variable names contained within the scope.
Definition: qgsexpressioncontext.cpp:113
QgsPropertyOverrideButton
A button for controlling property overrides which may apply to a widget.
Definition: qgspropertyoverridebutton.h:51
QgsProcessingParameterWidgetContext::setMapCanvas
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
Definition: qgsprocessingwidgetwrapper.cpp:34
QgsAbstractProcessingParameterWidgetWrapper::stretch
virtual int stretch() const
Returns the Qt layout "stretch" factor to use when adding this widget to a layout.
Definition: qgsprocessingwidgetwrapper.cpp:279
QgsProcessingHiddenWidgetWrapper::widgetValue
QVariant widgetValue() const override
Returns the current value of the parameter.
Definition: qgsprocessingwidgetwrapper.cpp:453
QgsAbstractProcessingParameterWidgetWrapper::createWrappedLabel
QLabel * createWrappedLabel()
Creates and returns a new label to accompany widgets created by the wrapper.
Definition: qgsprocessingwidgetwrapper.cpp:162
QgsProcessingDestinationParameter
Base class for all parameter definitions which represent file or layer destinations,...
Definition: qgsprocessingparameters.h:2774
QgsProcessingParameterWidgetContext::modelChildAlgorithmId
QString modelChildAlgorithmId() const
Returns the child algorithm ID within the model which the parameter widget is associated with.
Definition: qgsprocessingwidgetwrapper.cpp:74
qgsexpressioncontext.h
QgsProcessingParameterWidgetContext::project
QgsProject * project() const
Returns the project associated with the widget.
Definition: qgsprocessingwidgetwrapper.cpp:69
QgsAbstractProcessingParameterWidgetWrapper::setWidgetValue
virtual void setWidgetValue(const QVariant &value, QgsProcessingContext &context)=0
Sets the current value for the parameter to show in the widget.
QgsProcessingParameterWidgetFactoryInterface::modelerExpressionFormatString
virtual QString modelerExpressionFormatString() const
Returns the expected expression format string for expression results for the parameter within model c...
Definition: qgsprocessingwidgetwrapper.cpp:378
qgsprocessingmodelerparameterwidget.h
QgsProcessingParameters::parameterAsVectorLayer
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
Definition: qgsprocessingparameters.cpp:946
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition: qgsprocessingcontext.h:44
QgsProcessingParameterDefinition::toolTip
virtual QString toolTip() const
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
Definition: qgsprocessingparameters.cpp:2391
QgsProcessingParameterDefinition::algorithm
QgsProcessingAlgorithm * algorithm() const
Returns a pointer to the algorithm which owns this parameter.
Definition: qgsprocessingparameters.cpp:2381
QgsProcessingGui::Batch
@ Batch
Batch processing dialog.
Definition: qgsprocessinggui.h:41
QgsProcessingParameterWidgetFactoryInterface::compatibleDataTypes
virtual QList< int > compatibleDataTypes(const QgsProcessingParameterDefinition *parameter) const
Returns a list of compatible Processing data types for inputs for this widget for the specified param...
Definition: qgsprocessingwidgetwrapper.cpp:373
QgsAbstractProcessingParameterWidgetWrapper::createExpressionContext
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Definition: qgsprocessingwidgetwrapper.cpp:284
QgsExpressionContextUtils::processingAlgorithmScope
static QgsExpressionContextScope * processingAlgorithmScope(const QgsProcessingAlgorithm *algorithm, const QVariantMap &parameters, QgsProcessingContext &context)
Creates a new scope which contains variables and functions relating to a processing algorithm,...
Definition: qgsexpressioncontextutils.cpp:770
qgsprocessingwidgetwrapper.h
QgsMessageBar
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
QgsAbstractProcessingParameterWidgetWrapper::QgsAbstractProcessingParameterWidgetWrapper
QgsAbstractProcessingParameterWidgetWrapper(const QgsProcessingParameterDefinition *parameter=nullptr, QgsProcessingGui::WidgetType type=QgsProcessingGui::Standard, QObject *parent=nullptr)
Constructor for QgsAbstractProcessingParameterWidgetWrapper, for the specified parameter definition a...
Definition: qgsprocessingwidgetwrapper.cpp:109
QgsProcessingModelerParameterWidget
A widget for customising the value of Processing algorithm parameter inside a Processing model.
Definition: qgsprocessingmodelerparameterwidget.h:62
QgsProcessingHiddenWidgetWrapper::linkedVectorLayer
const QgsVectorLayer * linkedVectorLayer() const override
Returns the optional vector layer associated with this widget wrapper, or nullptr if no vector layer ...
Definition: qgsprocessingwidgetwrapper.cpp:458
QgsExpressionContextUtils::processingModelAlgorithmScope
static QgsExpressionContextScope * processingModelAlgorithmScope(const QgsProcessingModelAlgorithm *model, const QVariantMap &parameters, QgsProcessingContext &context)
Creates a new scope which contains variables and functions relating to a processing model algorithm,...
Definition: qgsexpressioncontextutils.cpp:787
QgsMapLayer::id
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
Definition: qgsmaplayer.cpp:148
QgsProcessingParametersGenerator
An interface for objects which can create sets of parameter values for processing algorithms.
Definition: qgsprocessingwidgetwrapper.h:77
QgsProcessingGui::Modeler
@ Modeler
Modeler dialog.
Definition: qgsprocessinggui.h:42
QgsAbstractProcessingParameterWidgetWrapper::widgetValueHasChanged
void widgetValueHasChanged(QgsAbstractProcessingParameterWidgetWrapper *wrapper)
Emitted whenever the parameter value (as defined by the wrapped widget) is changed.
qgsprocessingwidgetwrapperimpl.h
QgsAbstractProcessingParameterWidgetWrapper::type
QgsProcessingGui::WidgetType type() const
Returns the dialog type for which widgets and labels will be created by this wrapper.
Definition: qgsprocessingwidgetwrapper.cpp:116
QgsAbstractProcessingParameterWidgetWrapper::linkedVectorLayer
virtual const QgsVectorLayer * linkedVectorLayer() const
Returns the optional vector layer associated with this widget wrapper, or nullptr if no vector layer ...
Definition: qgsprocessingwidgetwrapper.cpp:245
QgsAbstractProcessingParameterWidgetWrapper::registerProcessingContextGenerator
void registerProcessingContextGenerator(QgsProcessingContextGenerator *generator)
Registers a Processing context generator class that will be used to retrieve a Processing context for...
Definition: qgsprocessingwidgetwrapper.cpp:214
QgsExpressionContext::highlightedVariables
QStringList highlightedVariables() const
Returns the current list of variables highlighted within the context.
Definition: qgsexpressioncontext.cpp:319
QgsProcessingAbstractParameterDefinitionWidget
Abstract base class for widgets which allow users to specify the properties of a Processing parameter...
Definition: qgsprocessingparameterdefinitionwidget.h:44
QgsProcessingHiddenWidgetWrapper::setLinkedVectorLayer
void setLinkedVectorLayer(const QgsVectorLayer *layer)
Sets the vector layer linked to the wrapper.
Definition: qgsprocessingwidgetwrapper.cpp:463
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext.
Definition: qgsexpressioncontext.h:112
QgsExpressionContext::appendScope
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Definition: qgsexpressioncontext.cpp:490
QgsAbstractProcessingParameterWidgetWrapper::setParameterValue
void setParameterValue(const QVariant &value, QgsProcessingContext &context)
Sets the current value for the parameter.
Definition: qgsprocessingwidgetwrapper.cpp:186
QgsAbstractProcessingParameterWidgetWrapper::createLabel
virtual QLabel * createLabel()
Creates a new label to accompany widgets created by the wrapper.
Definition: qgsprocessingwidgetwrapper.cpp:224
qgsprocessingparameters.h
QgsAbstractProcessingParameterWidgetWrapper::wrappedWidget
QWidget * wrappedWidget()
Returns the current wrapped widget, if any.
Definition: qgsprocessingwidgetwrapper.cpp:171
QgsProcessingGui::WidgetType
WidgetType
Types of dialogs which Processing widgets can be created for.
Definition: qgsprocessinggui.h:39
QgsProcessingParameterDefinition::dynamicPropertyDefinition
QgsPropertyDefinition dynamicPropertyDefinition() const
Returns the property definition for dynamic properties.
Definition: qgsprocessingparameters.h:648
QgsProcessingAlgorithm
Abstract base class for processing algorithms.
Definition: qgsprocessingalgorithm.h:52
c
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
Definition: porting_processing.dox:1
QgsAbstractProcessingParameterWidgetWrapper::widgetValue
virtual QVariant widgetValue() const =0
Returns the current value of the parameter.
QgsProcessingParameterWidgetContext::setProject
void setProject(QgsProject *project)
Sets the project associated with the widget.
Definition: qgsprocessingwidgetwrapper.cpp:64
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsAbstractProcessingParameterWidgetWrapper::setDialog
virtual void setDialog(QDialog *dialog)
Sets the parent dialog in which the wrapper is shown.
Definition: qgsprocessingwidgetwrapper.cpp:305
QgsProcessingContext::expressionContext
QgsExpressionContext & expressionContext()
Returns the expression context.
Definition: qgsprocessingcontext.h:133
QgsAbstractProcessingParameterWidgetWrapper::parameterValue
QVariant parameterValue() const
Returns the current value of the parameter.
Definition: qgsprocessingwidgetwrapper.cpp:201
QgsProcessingHiddenWidgetWrapper::createWidget
QWidget * createWidget() override
Creates a new widget which allows customization of the parameter's value.
Definition: qgsprocessingwidgetwrapper.cpp:468
QgsProcessingParameterWidgetFactoryInterface::compatibleOutputTypes
virtual QStringList compatibleOutputTypes() const =0
Returns a list of compatible Processing output types for inputs for this parameter.
QgsAbstractProcessingParameterWidgetWrapper::mWidgetContext
QgsProcessingParameterWidgetContext mWidgetContext
Definition: qgsprocessingwidgetwrapper.h:478
QgsProcessingParameterWidgetFactoryInterface::createParameterDefinitionWidget
virtual QgsProcessingAbstractParameterDefinitionWidget * createParameterDefinitionWidget(QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition=nullptr, const QgsProcessingAlgorithm *algorithm=nullptr)
Creates a new parameter definition widget allowing for configuration of an instance of the parameter ...
Definition: qgsprocessingwidgetwrapper.cpp:366
QgsProcessingParameterWidgetContext::setBrowserModel
void setBrowserModel(QgsBrowserGuiModel *model)
Sets the browser model associated with the widget.
Definition: qgsprocessingwidgetwrapper.cpp:54
QgsExpressionContext::setHighlightedVariables
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
Definition: qgsexpressioncontext.cpp:324
QgsAbstractProcessingParameterWidgetWrapper::mProcessingContextGenerator
QgsProcessingContextGenerator * mProcessingContextGenerator
Definition: qgsprocessingwidgetwrapper.h:476
QgsProcessingHiddenWidgetWrapper::QgsProcessingHiddenWidgetWrapper
QgsProcessingHiddenWidgetWrapper(const QgsProcessingParameterDefinition *parameter=nullptr, QgsProcessingGui::WidgetType type=QgsProcessingGui::Standard, QObject *parent=nullptr)
Constructor for QgsProcessingHiddenWidgetWrapper, for the specified parameter definition and dialog t...
Definition: qgsprocessingwidgetwrapper.cpp:438
QgsProcessingParameterWidgetContext::model
QgsProcessingModelAlgorithm * model() const
Returns the model which the parameter widget is associated with.
Definition: qgsprocessingwidgetwrapper.cpp:94
QgsProcessingParameterWidgetFactoryInterface::compatibleParameterTypes
virtual QStringList compatibleParameterTypes() const =0
Returns a list of compatible Processing parameter types for inputs for this parameter.
QgsProcessingHiddenWidgetWrapper::createLabel
QLabel * createLabel() override
Creates a new label to accompany widgets created by the wrapper.
Definition: qgsprocessingwidgetwrapper.cpp:474
QgsProcessingContextGenerator::processingContext
virtual QgsProcessingContext * processingContext()=0
This method needs to be reimplemented in all classes which implement this interface and return a Proc...
QgsAbstractProcessingParameterWidgetWrapper::widgetContext
const QgsProcessingParameterWidgetContext & widgetContext() const
Returns the context in which the Processing parameter widget is shown, e.g., the parent model algorit...
Definition: qgsprocessingwidgetwrapper.cpp:126
QgsProcessingParameterDefinition::FlagOptional
@ FlagOptional
Parameter is optional.
Definition: qgsprocessingparameters.h:425
QgsProcessingParameterWidgetContext::browserModel
QgsBrowserGuiModel * browserModel() const
Returns the browser model associated with the widget.
Definition: qgsprocessingwidgetwrapper.cpp:59
QgsProcessingParameterDefinition::defaultValue
QVariant defaultValue() const
Returns the default value for the parameter.
Definition: qgsprocessingparameters.h:509
QgsProcessingParameterWidgetFactoryInterface::createModelerWidgetWrapper
virtual QgsProcessingModelerParameterWidget * createModelerWidgetWrapper(QgsProcessingModelAlgorithm *model, const QString &childId, const QgsProcessingParameterDefinition *parameter, QgsProcessingContext &context)
Creates a new modeler parameter widget for the given parameter.
Definition: qgsprocessingwidgetwrapper.cpp:358
QgsAbstractProcessingParameterWidgetWrapper::parameterDefinition
const QgsProcessingParameterDefinition * parameterDefinition() const
Returns the parameter definition associated with this wrapper.
Definition: qgsprocessingwidgetwrapper.cpp:181
QgsAbstractProcessingParameterWidgetWrapper::customProperties
virtual QVariantMap customProperties() const
Returns any custom properties set by the wrapper.
Definition: qgsprocessingwidgetwrapper.cpp:209
QgsBrowserGuiModel
A model for showing available data sources and other items in a structured tree.
Definition: qgsbrowserguimodel.h:38
qgspropertyoverridebutton.h
QgsProcessingContextGenerator
An interface for objects which can create Processing contexts.
Definition: qgsprocessingwidgetwrapper.h:53
QgsProcessingParameterWidgetContext::messageBar
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
Definition: qgsprocessingwidgetwrapper.cpp:49
QgsAbstractProcessingParameterWidgetWrapper::postInitialize
virtual void postInitialize(const QList< QgsAbstractProcessingParameterWidgetWrapper * > &wrappers)
Called after all wrappers have been created within a particular dialog or context,...
Definition: qgsprocessingwidgetwrapper.cpp:252