QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 "qgsprocessingalgorithm.h"
19 
21 
22 QgsProcessingParametersWidget::QgsProcessingParametersWidget( const QgsProcessingAlgorithm *algorithm, QWidget *parent )
23  : QgsPanelWidget( parent )
24  , mAlgorithm( algorithm )
25 {
26  Q_ASSERT( mAlgorithm );
27 
28  setupUi( this );
29 
30  grpAdvanced->hide();
31  scrollAreaWidgetContents->setContentsMargins( 4, 4, 4, 4 );
32 }
33 
35 {
36  return mAlgorithm;
37 }
38 
39 void QgsProcessingParametersWidget::initWidgets()
40 {
41  // if there are advanced parameters - show corresponding groupbox
43  for ( const QgsProcessingParameterDefinition *param : defs )
44  {
46  {
47  grpAdvanced->show();
48  break;
49  }
50  }
51 }
52 
53 void QgsProcessingParametersWidget::addParameterWidget( const QgsProcessingParameterDefinition *parameter, QWidget *widget, int stretch )
54 {
56  mAdvancedGroupLayout->addWidget( widget, stretch );
57  else
58  mScrollAreaLayout->insertWidget( mScrollAreaLayout->count() - 2, widget, stretch );
59 }
60 
61 void QgsProcessingParametersWidget::addParameterLabel( const QgsProcessingParameterDefinition *parameter, QWidget *label )
62 {
64  mAdvancedGroupLayout->addWidget( label );
65  else
66  mScrollAreaLayout->insertWidget( mScrollAreaLayout->count() - 2, label );
67 }
68 
69 void QgsProcessingParametersWidget::addOutputLabel( QWidget *label )
70 {
71  mScrollAreaLayout->insertWidget( mScrollAreaLayout->count() - 1, label );
72 }
73 
74 void QgsProcessingParametersWidget::addOutputWidget( QWidget *widget, int stretch )
75 {
76  mScrollAreaLayout->insertWidget( mScrollAreaLayout->count() - 1, widget, stretch );
77 }
78 
79 void QgsProcessingParametersWidget::addExtraWidget( QWidget *widget )
80 {
81  mScrollAreaLayout->addWidget( widget );
82 }
83 
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.
@ FlagAdvanced
Parameter is an advanced parameter which should be hidden from users by default.
Flags 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.