QGIS API Documentation 4.3.0-Master (6a28b93578f)
Loading...
Searching...
No Matches
qgsprocessingguiregistry.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingguiregistry.cpp
3 ---------------------
4 begin : April 2018
5 copyright : (C) 2018 by Matthias Kuhn
6 email : matthias@opengis.ch
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
19
20#include "qgis.h"
21#include "qgslogger.h"
46
47#include <QString>
48
49#include "moc_qgsprocessingguiregistry.cpp"
50
51using namespace Qt::StringLiterals;
52
53//
54// QgsProcessingDialogFactory
55//
56
58
59//
60// QgsProcessingContextFactory
61//
62
64
65//
66// QgsProcessingGuiRegistry
67//
68
70{
71 addAlgorithmConfigurationWidgetFactory( new QgsFilterAlgorithmConfigurationWidgetFactory() );
72 addAlgorithmConfigurationWidgetFactory( new QgsConditionalBranchAlgorithmConfigurationWidgetFactory() );
73
74 addParameterWidgetFactory( new QgsProcessingAlignRasterLayersWidgetWrapper() );
75 addParameterWidgetFactory( new QgsProcessingBooleanWidgetWrapper() );
76 addParameterWidgetFactory( new QgsProcessingCrsWidgetWrapper() );
77 addParameterWidgetFactory( new QgsProcessingStringWidgetWrapper() );
78 addParameterWidgetFactory( new QgsProcessingNumericWidgetWrapper() );
79 addParameterWidgetFactory( new QgsProcessingDistanceWidgetWrapper() );
80 addParameterWidgetFactory( new QgsProcessingAreaWidgetWrapper() );
81 addParameterWidgetFactory( new QgsProcessingVolumeWidgetWrapper() );
82 addParameterWidgetFactory( new QgsProcessingDurationWidgetWrapper() );
83 addParameterWidgetFactory( new QgsProcessingScaleWidgetWrapper() );
84 addParameterWidgetFactory( new QgsProcessingRangeWidgetWrapper() );
85 addParameterWidgetFactory( new QgsProcessingAuthConfigWidgetWrapper() );
86 addParameterWidgetFactory( new QgsProcessingMatrixWidgetWrapper() );
87 addParameterWidgetFactory( new QgsProcessingFileWidgetWrapper() );
88 addParameterWidgetFactory( new QgsProcessingExpressionWidgetWrapper() );
89 addParameterWidgetFactory( new QgsProcessingEnumWidgetWrapper() );
90 addParameterWidgetFactory( new QgsProcessingLayoutWidgetWrapper() );
91 addParameterWidgetFactory( new QgsProcessingLayoutItemWidgetWrapper() );
92 addParameterWidgetFactory( new QgsProcessingPointWidgetWrapper() );
93 addParameterWidgetFactory( new QgsProcessingGeometryWidgetWrapper() );
94 addParameterWidgetFactory( new QgsProcessingColorWidgetWrapper() );
95 addParameterWidgetFactory( new QgsProcessingCoordinateOperationWidgetWrapper() );
96 addParameterWidgetFactory( new QgsProcessingFieldWidgetWrapper() );
97 addParameterWidgetFactory( new QgsProcessingMapThemeWidgetWrapper() );
98 addParameterWidgetFactory( new QgsProcessingDateTimeWidgetWrapper() );
99 addParameterWidgetFactory( new QgsProcessingProviderConnectionWidgetWrapper() );
100 addParameterWidgetFactory( new QgsProcessingDatabaseSchemaWidgetWrapper() );
101 addParameterWidgetFactory( new QgsProcessingDatabaseTableWidgetWrapper() );
102 addParameterWidgetFactory( new QgsProcessingExtentWidgetWrapper() );
103 addParameterWidgetFactory( new QgsProcessingMapLayerWidgetWrapper() );
104 addParameterWidgetFactory( new QgsProcessingVectorLayerWidgetWrapper() );
105 addParameterWidgetFactory( new QgsProcessingFeatureSourceWidgetWrapper() );
106 addParameterWidgetFactory( new QgsProcessingRasterLayerWidgetWrapper() );
107 addParameterWidgetFactory( new QgsProcessingMeshLayerWidgetWrapper() );
108 addParameterWidgetFactory( new QgsProcessingBandWidgetWrapper() );
109 addParameterWidgetFactory( new QgsProcessingMultipleLayerWidgetWrapper() );
110 addParameterWidgetFactory( new QgsProcessingVectorTileWriterLayersWidgetWrapper() );
111 addParameterWidgetFactory( new QgsProcessingFeatureSinkWidgetWrapper() );
112 addParameterWidgetFactory( new QgsProcessingVectorDestinationWidgetWrapper() );
113 addParameterWidgetFactory( new QgsProcessingRasterDestinationWidgetWrapper() );
114 addParameterWidgetFactory( new QgsProcessingFileDestinationWidgetWrapper() );
115 addParameterWidgetFactory( new QgsProcessingFolderDestinationWidgetWrapper() );
116 addParameterWidgetFactory( new QgsProcessingFieldMapWidgetWrapper() );
117 addParameterWidgetFactory( new QgsProcessingAggregateWidgetWrapper() );
118 addParameterWidgetFactory( new QgsProcessingTinInputLayersWidgetWrapper() );
119 addParameterWidgetFactory( new QgsProcessingDxfLayersWidgetWrapper() );
120 addParameterWidgetFactory( new QgsProcessingMeshDatasetGroupsWidgetWrapper() );
121 addParameterWidgetFactory( new QgsProcessingMeshDatasetTimeWidgetWrapper() );
122 addParameterWidgetFactory( new QgsProcessingPointCloudLayerWidgetWrapper() );
123 addParameterWidgetFactory( new QgsProcessingAnnotationLayerWidgetWrapper() );
124 addParameterWidgetFactory( new QgsProcessingPointCloudDestinationWidgetWrapper() );
125 addParameterWidgetFactory( new QgsProcessingPointCloudAttributeWidgetWrapper() );
126 addParameterWidgetFactory( new QgsProcessingVectorTileDestinationWidgetWrapper() );
127 addParameterWidgetFactory( new QgsProcessingRasterOptionsWidgetWrapper() );
128 addParameterWidgetFactory( new QgsProcessingHeatmapPixelSizeWidgetWrapper() );
129 addParameterWidgetFactory( new QgsProcessingReliefColorsWidgetWrapper() );
130 addParameterWidgetFactory( new QgsProcessingExecuteSqlWidgetWrapper() );
131 addParameterWidgetFactory( new QgsProcessingInterpolationPixelSizeWidgetWrapper() );
132 addParameterWidgetFactory( new QgsProcessingInterpolationSourceWidgetWrapper() );
133
134 mModelConfigWidgetFactory = std::make_unique< QgsProcessingGuiInternalModelConfigWidgetFactory >();
135 registerModelConfigWidgetFactory( mModelConfigWidgetFactory.get() );
136}
137
139{
140 for ( auto it = mProviderToolboxActions.constBegin(); it != mProviderToolboxActions.constEnd(); ++it )
141 {
142 qDeleteAll( it.value() );
143 }
144 mProviderToolboxActions.clear();
145
146 for ( auto it = mProviderToolboxContextActions.constBegin(); it != mProviderToolboxContextActions.constEnd(); ++it )
147 {
148 qDeleteAll( it.value() );
149 }
150 mProviderToolboxContextActions.clear();
151
152 const QList<QgsProcessingAlgorithmConfigurationWidgetFactory *> factories = mAlgorithmConfigurationWidgetFactories;
153 for ( QgsProcessingAlgorithmConfigurationWidgetFactory *factory : factories )
155 const QMap<QString, QgsProcessingParameterWidgetFactoryInterface *> paramFactories = mParameterWidgetFactories;
156 for ( auto it = paramFactories.constBegin(); it != paramFactories.constEnd(); ++it )
157 removeParameterWidgetFactory( it.value() );
158
159 unregisterModelConfigWidgetFactory( mModelConfigWidgetFactory.get() );
160 mModelConfigWidgetFactory.reset();
161}
162
164{
165 mAlgorithmConfigurationWidgetFactories.append( factory );
166}
167
169{
170 mAlgorithmConfigurationWidgetFactories.removeAll( factory );
171 delete factory;
172}
173
175{
176 for ( const auto *factory : mAlgorithmConfigurationWidgetFactories )
177 {
178 if ( factory->canCreateFor( algorithm ) )
179 {
180 std::unique_ptr<QgsProcessingAlgorithmConfigurationWidget> widget( factory->create( algorithm ) );
181 if ( widget )
182 widget->setAlgorithm( algorithm );
183 return widget.release();
184 }
185 }
186
187 return nullptr;
188}
189
191{
192 if ( !factory )
193 return false;
194
195 if ( mParameterWidgetFactories.contains( factory->parameterType() ) )
196 {
197 QgsLogger::warning( u"Duplicate parameter factory for %1 registered"_s.arg( factory->parameterType() ) );
198 return false;
199 }
200
201 mParameterWidgetFactories.insert( factory->parameterType(), factory );
202 return true;
203}
204
206{
207 if ( !factory )
208 return;
209
210 mParameterWidgetFactories.remove( factory->parameterType() );
211 delete factory;
212}
213
215{
216 mModelConfigWidgetFactories << factory;
217}
218
220{
221 mModelConfigWidgetFactories.removeAll( factory );
222}
223
225{
226 if ( !parameter )
227 return nullptr;
228
229 const QVariantMap metadata = parameter->metadata();
230 const QString widgetType = metadata.value( u"widget_wrapper"_s ).toMap().value( u"widget_type"_s ).toString();
231 const QString parameterType = !widgetType.isEmpty() ? widgetType : parameter->type();
232 if ( !mParameterWidgetFactories.contains( parameterType ) )
233 return nullptr;
234
235 if ( QgsProcessingParameterWidgetFactoryInterface *factory = mParameterWidgetFactories.value( parameterType ) )
236 {
237 return factory->createWidgetWrapper( parameter, type );
238 }
239 return nullptr;
240}
241
243 QgsProcessingModelAlgorithm *model, const QString &childId, const QgsProcessingParameterDefinition *parameter, QgsProcessingContext &context
244)
245{
246 if ( !parameter )
247 return nullptr;
248
249 const QString parameterType = parameter->type();
250 auto it = mParameterWidgetFactories.constFind( parameterType );
251 if ( it == mParameterWidgetFactories.constEnd() )
252 return nullptr;
253
254 return it.value()->createModelerWidgetWrapper( model, childId, parameter, context );
255}
256
258 const QString &type, QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition, const QgsProcessingAlgorithm *algorithm
259)
260{
261 auto it = mParameterWidgetFactories.constFind( type );
262 if ( it == mParameterWidgetFactories.constEnd() )
263 return nullptr;
264
265 return it.value()->createParameterDefinitionWidget( context, widgetContext, definition, algorithm );
266}
267
269 QgsProcessingModelComponent *component, QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext
270) const
271{
272 for ( auto it = mModelConfigWidgetFactories.constBegin(); it != mModelConfigWidgetFactories.constEnd(); ++it )
273 {
274 // factory may have been deleted without deregistering, don't crash!
275 if ( !it->data() )
276 continue;
277
278 if ( it->data()->supportsComponent( component ) )
279 {
280 if ( QgsProcessingModelConfigWidget *widget = it->data()->createWidget( component, context, widgetContext ) )
281 return widget;
282 }
283 }
284 return nullptr;
285}
286
288{
289 mWidgetContextGenerator = generator;
290}
291
293{
294 if ( mWidgetContextGenerator )
295 {
296 return mWidgetContextGenerator->createWidgetContext();
297 }
299}
300
302{
303 mProviderToolboxActions[providerId].append( action );
304}
305
307{
308 QList< QgsProcessingToolboxAction * > actions = mProviderToolboxActions.take( providerId );
309 qDeleteAll( actions );
310}
311
312QList<QgsProcessingToolboxAction *> QgsProcessingGuiRegistry::toolboxActionsForProvider( const QString &providerId ) const
313{
314 return mProviderToolboxActions.value( providerId );
315}
316
318{
319 mProviderToolboxContextActions[providerId].append( action );
320}
321
323{
324 QList< QgsProcessingToolboxContextAction * > actions = mProviderToolboxContextActions.take( providerId );
325 qDeleteAll( actions );
326}
327
329{
330 for ( auto it = mProviderToolboxContextActions.begin(); it != mProviderToolboxContextActions.end(); ++it )
331 {
332 if ( it.value().contains( action ) )
333 {
334 QList< QgsProcessingToolboxContextAction * > actions = it.value();
335 actions.removeAll( action );
336 mProviderToolboxContextActions.insert( it.key(), actions );
337 break;
338 }
339 }
340}
341
342QList<QgsProcessingToolboxContextAction *> QgsProcessingGuiRegistry::toolboxContextActions() const
343{
344 QList<QgsProcessingToolboxContextAction *> res;
345 for ( auto it = mProviderToolboxContextActions.constBegin(); it != mProviderToolboxContextActions.constEnd(); ++it )
346 {
347 res.append( it.value() );
348 }
349 return res;
350}
351
353{
354 mProcessingDialogFactory.reset( factory );
355}
356
358{
359 return mProcessingDialogFactory.get();
360}
361
363{
364 mContextFactory.reset( factory );
365}
366
368{
369 return mContextFactory.get();
370}
371
372QList<QgsProcessingToolboxContextAction *> QgsProcessingGuiRegistry::toolboxContextActionsForProvider( const QString &providerId ) const
373{
374 return mProviderToolboxContextActions.value( providerId );
375}
376
378bool QgsProcessingGuiInternalModelConfigWidgetFactory::supportsComponent( QgsProcessingModelComponent *component ) const
379{
380 if ( dynamic_cast< QgsProcessingModelGroupBox * >( component ) )
381 return true;
382
383 if ( dynamic_cast< QgsProcessingModelChildAlgorithm * >( component ) )
384 return true;
385
386 if ( dynamic_cast< QgsProcessingModelParameter * >( component ) )
387 return true;
388
389 if ( dynamic_cast< QgsProcessingModelOutput * >( component ) )
390 return true;
391
392 return false;
393}
394
395QgsProcessingModelConfigWidget *QgsProcessingGuiInternalModelConfigWidgetFactory::createWidget(
396 QgsProcessingModelComponent *component, QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext
397) const
398{
399 if ( QgsProcessingModelGroupBox *groupBox = dynamic_cast< QgsProcessingModelGroupBox * >( component ) )
400 {
401 QgsModelDesignerDialog *dialog = widgetContext.modelDesignerDialog();
402 const QString boxUuid = groupBox->uuid();
403
404 auto widget = new QgsModelGroupBoxDefinitionPanelWidget( *groupBox );
405 connect( widget, &QgsModelGroupBoxDefinitionPanelWidget::widgetChanged, this, [dialog, boxUuid, widget] {
406 QgsModelGraphicsScene *modelScene = dialog->modelScene();
407 QgsModelGroupBoxGraphicItem *graphicItem = dynamic_cast< QgsModelGroupBoxGraphicItem * >( modelScene->groupBoxItem( boxUuid ) );
408 if ( !graphicItem )
409 return; // should not happen
410
411 graphicItem->applyEdit( widget->groupBox() );
412 } );
413
414 return widget;
415 }
416 else if ( QgsProcessingModelChildAlgorithm *childAlg = dynamic_cast< QgsProcessingModelChildAlgorithm * >( component ) )
417 {
418 QgsModelDesignerDialog *dialog = widgetContext.modelDesignerDialog();
419 const QString childId = childAlg->childId();
420
421 std::unique_ptr< QgsProcessingAlgorithm > algorithm( childAlg->algorithm()->create() );
422 auto widget = new QgsProcessingModelerParametersWidget( algorithm.get(), widgetContext.model(), context, childId, childAlg->configuration(), nullptr );
423 widget->setComments( childAlg->comment()->description() );
424 widget->setCommentColor( childAlg->comment()->color() );
425
426 QgsProcessingParameterWidgetContext widgetContextCopy = widgetContext;
427 widgetContextCopy.setModelChildAlgorithmId( childId );
428 widget->setWidgetContext( widgetContextCopy );
429
430 connect( widget, &QgsProcessingModelConfigWidget::widgetChanged, this, [dialog, childId, widget] {
431 QgsModelGraphicsScene *modelScene = dialog->modelScene();
432 QgsModelChildAlgorithmGraphicItem *graphicItem = modelScene->childAlgorithmItem( childId );
433 if ( !graphicItem )
434 return; // should not happen
435
436 std::unique_ptr< QgsProcessingModelChildAlgorithm > updatedAlgorithm = widget->createAlgorithm();
437 if ( updatedAlgorithm )
438 {
439 graphicItem->applyEdit( *updatedAlgorithm );
440 }
441 } );
442
443 return widget;
444 }
445 else if ( QgsProcessingModelParameter *modelParam = dynamic_cast< QgsProcessingModelParameter * >( component ) )
446 {
447 QgsModelDesignerDialog *dialog = widgetContext.modelDesignerDialog();
448 QgsProcessingModelAlgorithm *model = widgetContext.model();
449
450 const QString componentName = modelParam->parameterName();
451 const QgsProcessingParameterDefinition *existingParam = model->parameterDefinition( componentName );
452 if ( !existingParam )
453 return nullptr;
454
455 const QString comment = modelParam->comment()->description();
456 const QColor commentColor = modelParam->comment()->color();
457 const QString oldName = existingParam->name();
458 const QString oldDescription = existingParam->description();
459
460 auto widget = new QgsProcessingParameterDefinitionPanelWidget( existingParam->type(), context, widgetContext, existingParam, model );
461 widget->setComments( comment );
462 widget->setCommentColor( commentColor );
463 if ( widgetContext.processingContextGenerator() )
464 {
465 widget->registerProcessingContextGenerator( widgetContext.processingContextGenerator() );
466 }
467
468 auto existingParamName = std::make_shared< QString >( existingParam->name() );
469
470 connect( widget, &QgsProcessingParameterDefinitionPanelWidget::widgetChanged, this, [dialog, componentName, oldDescription, oldName, existingParamName, widget] {
471 QgsModelGraphicsScene *modelScene = dialog->modelScene();
472 if ( !modelScene )
473 return;
474
475 QgsModelParameterGraphicItem *graphicItem = dynamic_cast< QgsModelParameterGraphicItem * >( modelScene->parameterItem( componentName ) );
476 if ( !graphicItem )
477 return; // should not happen
478
479 std::unique_ptr< QgsProcessingParameterDefinition > newParam( widget->createParameter( *existingParamName ) );
480 if ( !newParam )
481 return;
482
483 const QString comment = widget->comments();
484 const QColor commentColor = widget->commentColor();
485 *existingParamName = graphicItem->applyEdit( std::move( newParam ), oldDescription, oldName, comment, commentColor );
486 } );
487
488 return widget;
489 }
490 else if ( QgsProcessingModelOutput *modelOutput = dynamic_cast< QgsProcessingModelOutput * >( component ) )
491 {
492 QgsModelDesignerDialog *dialog = widgetContext.modelDesignerDialog();
493 QgsProcessingModelAlgorithm *model = widgetContext.model();
494
495 const QString childId = modelOutput->childId();
496 const QString childOutputName = modelOutput->childOutputName();
497
498 const QgsProcessingParameterDefinition *existingParam = model->modelParameterFromChildIdAndOutputName( childId, modelOutput->name() );
499 if ( !existingParam )
500 return nullptr;
501
502 const QString comment = modelOutput->comment()->description();
503 const QColor commentColor = modelOutput->comment()->color();
504
505 auto widget = new QgsProcessingParameterDefinitionPanelWidget( existingParam->type(), context, widgetContext, existingParam, model );
506 widget->setComments( comment );
507 widget->setCommentColor( commentColor );
508 if ( widgetContext.processingContextGenerator() )
509 {
510 widget->registerProcessingContextGenerator( widgetContext.processingContextGenerator() );
511 }
512
513 connect( widget, &QgsProcessingParameterDefinitionPanelWidget::widgetChanged, this, [dialog, childId, childOutputName, widget] {
514 QgsModelGraphicsScene *modelScene = dialog->modelScene();
515 if ( !modelScene )
516 return;
517
518 QgsModelOutputGraphicItem *graphicItem = dynamic_cast< QgsModelOutputGraphicItem * >( modelScene->outputItem( childId, childOutputName ) );
519 if ( !graphicItem )
520 return; // should not happen
521
522 std::unique_ptr< QgsProcessingParameterDefinition > newParam( widget->createParameter() );
523 if ( !newParam )
524 return;
525
526 graphicItem
527 ->applyEdit( newParam->description(), newParam->description(), newParam->defaultValue(), !newParam->flags().testFlag( Qgis::ProcessingParameterFlag::Optional ), widget->comments(), widget->commentColor() );
528 } );
529
530 return widget;
531 }
532
533 return nullptr;
534}
535
536
ProcessingMode
Types of modes which Processing widgets can be created for.
Definition qgis.h:3890
@ Optional
Parameter is optional.
Definition qgis.h:3986
A widget wrapper for Processing parameter value widgets.
static void warning(const QString &msg)
Goes to qWarning.
A widget which allows users to specify the properties of a model group box.
void widgetChanged()
Emitted when the widget state changes.
Abstract base class for widgets which allow users to specify the properties of a Processing parameter...
Interface base class for factories for algorithm configuration widgets.
A configuration widget for processing algorithms allows providing additional configuration options di...
Abstract base class for processing algorithms.
A factory for creating Processing contexts, aware of the GUI components which may influence this.
virtual ~QgsProcessingContextFactory()
Contains information about the context in which a processing algorithm is executed.
A factory for creating widgets and dialogs for Processing components.
virtual ~QgsProcessingDialogFactory()
QgsProcessingDialogFactory * dialogFactory()
Returns the application's processing dialog factory, if set.
void addAlgorithmConfigurationWidgetFactory(QgsProcessingAlgorithmConfigurationWidgetFactory *factory)
Add a new configuration widget factory for customized algorithm configuration widgets.
bool addParameterWidgetFactory(QgsProcessingParameterWidgetFactoryInterface *factory)
Adds a parameter widget factory to the registry, allowing widget creation for parameters of the match...
void deregisterProviderToolboxContextActions(const QString &providerId)
Deregisters all toolbox context menu actions for a provider.
QList< QgsProcessingToolboxContextAction * > toolboxContextActions() const
Returns a list of all toolbox context menu actions registered.
void removeAlgorithmConfigurationWidgetFactory(QgsProcessingAlgorithmConfigurationWidgetFactory *factory)
Remove a configuration widget factory for customized algorithm configuration widgets.
void registerProviderToolboxAction(const QString &providerId, QgsProcessingToolboxAction *action)
Registers a toolbox action for a provider.
void registerModelConfigWidgetFactory(QgsProcessingModelConfigWidgetFactory *factory)
Register a new factory class for creating panel widgets that can be shown in the Processing model des...
void unregisterModelConfigWidgetFactory(QgsProcessingModelConfigWidgetFactory *factory)
Unregister a previously registered factory for creating panel widgets that can be shown in the Proces...
QgsProcessingAlgorithmConfigurationWidget * algorithmConfigurationWidget(const QgsProcessingAlgorithm *algorithm) const
Gets the configuration widget for an algorithm.
QList< QgsProcessingToolboxContextAction * > toolboxContextActionsForProvider(const QString &providerId) const
Returns a list of all toolbox context menu actions registered for a provider.
void deregisterProviderToolboxActions(const QString &providerId)
Deregisters all toolbox actions for a provider.
QgsAbstractProcessingParameterWidgetWrapper * createParameterWidgetWrapper(const QgsProcessingParameterDefinition *parameter, Qgis::ProcessingMode type)
Creates a new parameter widget wrapper for the given parameter.
Q_DECL_DEPRECATED void deregisterProviderToolboxContextAction(QgsProcessingToolboxContextAction *action)
Deregisters a context menu action.
void registerWidgetContextGenerator(QgsProcessingWidgetContextGenerator *generator)
Register a Processing widget context generator class that will be used to retrieve a widget context w...
void setDialogFactory(QgsProcessingDialogFactory *factory)
Sets the application's processing dialog factory.
QgsProcessingAbstractParameterDefinitionWidget * createParameterDefinitionWidget(const QString &type, 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 a specific par...
QgsProcessingModelerParameterWidget * createModelerParameterWidget(QgsProcessingModelAlgorithm *model, const QString &childId, const QgsProcessingParameterDefinition *parameter, QgsProcessingContext &context)
Creates a new modeler parameter widget for the given parameter.
void setContextFactory(QgsProcessingContextFactory *factory)
Sets the application's Processing context factory.
void removeParameterWidgetFactory(QgsProcessingParameterWidgetFactoryInterface *factory)
Removes a parameter widget factory from the registry.
void registerProviderToolboxContextAction(const QString &providerId, QgsProcessingToolboxContextAction *action)
Registers a toolbox context menu action for a provider.
QgsProcessingContextFactory * contextFactory()
Returns the application's Processing context factory, if set.
QgsProcessingModelConfigWidget * createModelConfigWidgetForComponent(QgsProcessingModelComponent *component, QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext) const
Creates a new widget for configuring a Processing model component.
QgsProcessingParameterWidgetContext createWidgetContext() override
Register a Processing widget context.
QList< QgsProcessingToolboxAction * > toolboxActionsForProvider(const QString &providerId) const
Returns a list of all toolbox actions registered for a provider.
Factory class for creating panel widgets that can be shown in the Processing model designer dialog.
A panel widget that can be shown in the Processing model designer dialog for configuring part of the ...
A widget for customising the value of Processing algorithm parameters inside a Processing model.
A panel config widget combining parameter settings and comments for a child algorithm in a Processing...
A panel widget which allows users to specify the properties of a Processing parameter.
Base class for the definition of processing parameters.
QVariantMap metadata() const
Returns the parameter's freeform metadata.
QString description() const
Returns the description for the parameter.
virtual QString type() const =0
Unique parameter type name.
QString name() const
Returns the name of the parameter.
Contains settings which reflect the context in which a Processing parameter widget is shown.
QgsModelDesignerDialog * modelDesignerDialog() const
Returns the associated model designer dialog, if applicable.
void setModelChildAlgorithmId(const QString &id)
Sets the child algorithm id within the model which the parameter widget is associated with.
QgsProcessingModelAlgorithm * model() const
Returns the model which the parameter widget is associated with.
QgsProcessingContextGenerator * processingContextGenerator() const
Returns the Processing context generator class that will be used to retrieve a Processing context for...
An interface for Processing widget wrapper factories.
virtual QString parameterType() const =0
Returns the type string for the parameter type the factory is associated with.
A custom action to show in the Processing toolbox.
A custom action to show in the context menu for the Processing toolbox.
An interface for objects which can create Processing widget contexts.
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