QGIS API Documentation 4.3.0-Master (0cfde48c85b)
Loading...
Searching...
No Matches
qgsprocessingparameterswidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingparameterswidget.h
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
16#ifndef QGSPROCESSINGPARAMETERSWIDGET_H
17#define QGSPROCESSINGPARAMETERSWIDGET_H
18
19#include "ui_qgsprocessingparameterswidgetbase.h"
20
21#include "qgis.h"
22#include "qgis_gui.h"
25
26#include <QPointer>
27#include <QWidget>
28
31
33
40class GUI_EXPORT QgsProcessingParametersWidget : public QgsPanelWidget, public QgsProcessingParametersGenerator, public QgsProcessingContextGenerator, private Ui::QgsProcessingParametersWidgetBase
41{
42 Q_OBJECT
43
44 public:
48 QgsProcessingParametersWidget( const QgsProcessingAlgorithm *algorithm, bool inPlace, QgsMapLayer *activeLayer, QgsMessageBar *messageBar, QWidget *parent SIP_TRANSFERTHIS = nullptr );
49 ~QgsProcessingParametersWidget() override;
50
54 void initWidgets();
55
56 const QgsProcessingAlgorithm *algorithm() const;
57 QgsProcessingContext *processingContext() const override;
59
66 void registerProcessingContextGenerator( QgsProcessingContextGenerator *generator );
67
73 QList< QgsProcessingParametersGenerator::ParameterValidationResult > validate() const;
74
85 QVariantMap createAndValidateParameters( QgsProcessingParametersGenerator::Flags flags, QList< QgsProcessingParametersGenerator::ParameterValidationResult > &validationResults SIP_OUT ) const;
86
92 void setParameters( const QVariantMap &parameters );
93
99 QgsAbstractProcessingParameterWidgetWrapper *wrapper( const QString &name ) const;
100
106 QList< QgsAbstractProcessingParameterWidgetWrapper * > wrappers() const;
107
108 protected:
109 void addParameterWidget( const QgsProcessingParameterDefinition *parameter, QWidget *widget SIP_TRANSFER, int stretch = 0 );
110 void addParameterLabel( const QgsProcessingParameterDefinition *parameter, QWidget *label SIP_TRANSFER );
111
112 void addOutputLabel( QWidget *label SIP_TRANSFER );
113 void addOutputWidget( QWidget *widget SIP_TRANSFER, int stretch = 0 );
114
115 void addExtraWidget( QWidget *widget SIP_TRANSFER );
116
117 private slots:
118
119 void parameterChanged();
120
121 private:
122 QgsProcessingContextGenerator *mContextGenerator = nullptr;
123
124 const QgsProcessingAlgorithm *mAlgorithm = nullptr;
125 bool mInPlace = false;
126 QPointer< QgsMapLayer > mActiveLayer;
127 QgsMessageBar *mMessageBar = nullptr;
128
129 QVariantMap mExtraParameters;
130
131 QMap< QString, QgsAbstractProcessingParameterWidgetWrapper * > mWrappers;
132
133 friend class TestProcessingGui;
134};
135
137
138#endif // QGSPROCESSINGPARAMETERSWIDGET_H
Base class for any widget that can be shown as an inline panel.
Abstract base class for processing algorithms.
An interface for objects which can create Processing contexts.
virtual QgsProcessingContext * processingContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return a Proc...
Base class for the definition of processing parameters.
An interface for objects which can create sets of parameter values for processing algorithms.
virtual QVariantMap createProcessingParameters(QgsProcessingParametersGenerator::Flags flags=QgsProcessingParametersGenerator::Flags())=0
This method needs to be reimplemented in all classes which implement this interface and return a algo...
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
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_OUT
Definition qgis_sip.h:57