QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
20
21#include "moc_qgsprocessingparameterswidget.cpp"
22
24
25QgsProcessingParametersWidget::QgsProcessingParametersWidget( const QgsProcessingAlgorithm *algorithm, QWidget *parent )
26 : QgsPanelWidget( parent )
27 , mAlgorithm( algorithm )
28{
29 Q_ASSERT( mAlgorithm );
30
31 setupUi( this );
32
33 grpAdvanced->hide();
34 scrollAreaWidgetContents->setContentsMargins( 4, 4, 4, 4 );
35}
36
37const QgsProcessingAlgorithm *QgsProcessingParametersWidget::algorithm() const
38{
39 return mAlgorithm;
40}
41
42void QgsProcessingParametersWidget::initWidgets()
43{
44 // if there are advanced parameters - show corresponding groupbox
45 const QgsProcessingParameterDefinitions defs = mAlgorithm->parameterDefinitions();
46 for ( const QgsProcessingParameterDefinition *param : defs )
47 {
48 if ( param->flags() & Qgis::ProcessingParameterFlag::Advanced )
49 {
50 grpAdvanced->show();
51 break;
52 }
53 }
54}
55
56void QgsProcessingParametersWidget::addParameterWidget( const QgsProcessingParameterDefinition *parameter, QWidget *widget, int stretch )
57{
59 mAdvancedGroupLayout->addWidget( widget, stretch );
60 else
61 mScrollAreaLayout->insertWidget( mScrollAreaLayout->count() - 2, widget, stretch );
62}
63
64void QgsProcessingParametersWidget::addParameterLabel( const QgsProcessingParameterDefinition *parameter, QWidget *label )
65{
67 mAdvancedGroupLayout->addWidget( label );
68 else
69 mScrollAreaLayout->insertWidget( mScrollAreaLayout->count() - 2, label );
70}
71
72void QgsProcessingParametersWidget::addOutputLabel( QWidget *label )
73{
74 mScrollAreaLayout->insertWidget( mScrollAreaLayout->count() - 1, label );
75}
76
77void QgsProcessingParametersWidget::addOutputWidget( QWidget *widget, int stretch )
78{
79 mScrollAreaLayout->insertWidget( mScrollAreaLayout->count() - 1, widget, stretch );
80}
81
82void QgsProcessingParametersWidget::addExtraWidget( QWidget *widget )
83{
84 mScrollAreaLayout->addWidget( widget );
85}
86
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
Definition qgis.h:3763
Base class for any widget that can be shown as an inline panel.
Abstract base class for processing algorithms.
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.