QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsprocessingparameterswidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingparameterswidget.cpp
3 ------------------------------------
4 Date : March 2020
5 Copyright : (C) 2020 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17#include "moc_qgsprocessingparameterswidget.cpp"
20
22
23QgsProcessingParametersWidget::QgsProcessingParametersWidget( const QgsProcessingAlgorithm *algorithm, QWidget *parent )
24 : QgsPanelWidget( parent )
25 , mAlgorithm( algorithm )
26{
27 Q_ASSERT( mAlgorithm );
28
29 setupUi( this );
30
31 grpAdvanced->hide();
32 scrollAreaWidgetContents->setContentsMargins( 4, 4, 4, 4 );
33}
34
35const QgsProcessingAlgorithm *QgsProcessingParametersWidget::algorithm() const
36{
37 return mAlgorithm;
38}
39
40void QgsProcessingParametersWidget::initWidgets()
41{
42 // if there are advanced parameters - show corresponding groupbox
44 for ( const QgsProcessingParameterDefinition *param : defs )
45 {
46 if ( param->flags() & Qgis::ProcessingParameterFlag::Advanced )
47 {
48 grpAdvanced->show();
49 break;
50 }
51 }
52}
53
54void QgsProcessingParametersWidget::addParameterWidget( const QgsProcessingParameterDefinition *parameter, QWidget *widget, int stretch )
55{
57 mAdvancedGroupLayout->addWidget( widget, stretch );
58 else
59 mScrollAreaLayout->insertWidget( mScrollAreaLayout->count() - 2, widget, stretch );
60}
61
62void QgsProcessingParametersWidget::addParameterLabel( const QgsProcessingParameterDefinition *parameter, QWidget *label )
63{
65 mAdvancedGroupLayout->addWidget( label );
66 else
67 mScrollAreaLayout->insertWidget( mScrollAreaLayout->count() - 2, label );
68}
69
70void QgsProcessingParametersWidget::addOutputLabel( QWidget *label )
71{
72 mScrollAreaLayout->insertWidget( mScrollAreaLayout->count() - 1, label );
73}
74
75void QgsProcessingParametersWidget::addOutputWidget( QWidget *widget, int stretch )
76{
77 mScrollAreaLayout->insertWidget( mScrollAreaLayout->count() - 1, widget, stretch );
78}
79
80void QgsProcessingParametersWidget::addExtraWidget( QWidget *widget )
81{
82 mScrollAreaLayout->addWidget( widget );
83}
84
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
Base class for any widget that can be shown as a inline panel.
Abstract base class for processing algorithms.
QgsProcessingParameterDefinitions parameterDefinitions() const
Returns an ordered list of parameter definitions utilized by the algorithm.
Base class for the definition of processing parameters.
Qgis::ProcessingParameterFlags flags() const
Returns any flags associated with the parameter.
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
QList< const QgsProcessingParameterDefinition * > QgsProcessingParameterDefinitions
List of processing parameters.