QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsprocessingmodelerparameterwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingmodelerparameterwidget.h
3 -------------------------------------
4 begin : August 2018
5 copyright : (C) 2018 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
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
18
19#ifndef QGSPROCESSINGMODELERPARAMETERWIDGET_H
20#define QGSPROCESSINGMODELERPARAMETERWIDGET_H
21
22#include "qgis_gui.h"
23#include "qgis_sip.h"
26
27#include <QPointer>
28#include <QWidget>
29
33class QgsProcessingModelAlgorithm;
37
38class QLabel;
39class QToolButton;
40class QMenu;
41class QStackedWidget;
42class QComboBox;
43
63{
64 Q_OBJECT
65
66 public:
80 QgsProcessingModelerParameterWidget( QgsProcessingModelAlgorithm *model, const QString &childId, const QgsProcessingParameterDefinition *parameter, QgsProcessingContext &context, QWidget *parent SIP_TRANSFERTHIS = nullptr );
81
83
90
96
111 void populateSources( const QStringList &compatibleParameterTypes, const QStringList &compatibleOutputTypes, const QList<int> &compatibleDataTypes );
112
118 void setExpressionHelpText( const QString &text );
119
124
130 QLabel *createLabel() SIP_FACTORY;
131
137 virtual void setWidgetValue( const QgsProcessingModelChildParameterSource &value );
138
145 void setWidgetValue( const QList<QgsProcessingModelChildParameterSource> &values );
146
154 void setToModelOutput( const QString &value );
155
163 bool isModelOutput() const;
164
172 QString modelOutputName() const;
173
179 virtual QVariant value() const;
180
186 void setDialog( QDialog *dialog );
187
189
195 void setSourceType( Qgis::ProcessingModelChildParameterSource type );
196
197 private slots:
198
199 void sourceMenuAboutToShow();
200 void sourceMenuActionTriggered( QAction *action );
201
202 private:
203 // IMPORTANT - must match order of widgets in the stacked widget!
204 enum SourceType
205 {
206 StaticValue = 0,
207 Expression = 1,
208 ModelParameter = 2,
209 ChildOutput = 3,
210 ModelOutput = 4,
211 };
212
213 SourceType currentSourceType() const;
214
215 void updateUi();
216
217 QgsProcessingModelAlgorithm *mModel = nullptr;
218 const QString mChildId;
219 const QgsProcessingParameterDefinition *mParameterDefinition = nullptr;
220 QgsProcessingContext &mContext;
221
222 QVariant mStaticValue;
223 QString mModelInputParameterName;
224 QString mOutputChildId;
225 QString mOutputName;
226 QString mExpression;
227
228 QToolButton *mSourceButton = nullptr;
229 QMenu *mSourceMenu = nullptr;
230 QStackedWidget *mStackedWidget = nullptr;
231
232 bool mHasStaticWrapper = false;
233 std::unique_ptr<QgsAbstractProcessingParameterWidgetWrapper> mStaticWidgetWrapper;
234 QgsExpressionLineEdit *mExpressionWidget = nullptr;
235 QComboBox *mModelInputCombo = nullptr;
236 QComboBox *mChildOutputCombo = nullptr;
237 QgsFilterLineEdit *mModelOutputName = nullptr;
238
239 QList<Qgis::ProcessingModelChildParameterSource> mLimitedSources;
240 friend class TestProcessingGui;
241};
242
243
244#endif // QGSPROCESSINGMODELERPARAMETERWIDGET_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:56
A widget wrapper for Processing parameter value widgets.
Abstract interface for generating an expression context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
A widget which includes a line edit for entering expressions together with a button to open the expre...
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
An interface for objects which can create Processing contexts.
Contains information about the context in which a processing algorithm is executed.
QgsProcessingModelerParameterWidget(QgsProcessingModelAlgorithm *model, const QString &childId, const QgsProcessingParameterDefinition *parameter, QgsProcessingContext &context, QWidget *parent=nullptr)
Constructor for QgsProcessingModelerParameterWidget, for the specified parameter definition within th...
bool isModelOutput() const
Returns true if the widget is set to the model output mode.
QString modelOutputName() const
Returns the model output name, if isModelOutput() is true.
QLabel * createLabel()
Creates a label for use identifying the associated parameter.
virtual void setWidgetValue(const QgsProcessingModelChildParameterSource &value)
Sets the current value for the parameter.
void setSourceType(Qgis::ProcessingModelChildParameterSource type)
Sets the current source type for the parameter.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
virtual QVariant value() const
Returns the current value of the parameter.
void setDialog(QDialog *dialog)
Sets the parent dialog in which the widget is shown.
void setExpressionHelpText(const QString &text)
Set the expected expression format text, which is shown in the expression builder dialog for the widg...
void setWidgetContext(const QgsProcessingParameterWidgetContext &context)
Sets the context in which the modeler parameter widget is shown, e.g., the parent model algorithm and...
void registerProcessingContextGenerator(QgsProcessingContextGenerator *generator)
Registers a Processing context generator class that will be used to retrieve a Processing context for...
void populateSources(const QStringList &compatibleParameterTypes, const QStringList &compatibleOutputTypes, const QList< int > &compatibleDataTypes)
Populates the widget with available sources for the parameter's value, e.g.
void setToModelOutput(const QString &value)
Sets the widget to a model output, for destination parameters only.
const QgsProcessingParameterDefinition * parameterDefinition() const
Returns the parameter definition associated with this wrapper.
Base class for the definition of processing parameters.
Contains settings which reflect the context in which a Processing parameter widget is shown.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_FACTORY
Definition qgis_sip.h:84