QGIS API Documentation 3.99.0-Master (c22de0620c0)
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 signals:
198
204 void changed();
205
206 private slots:
207
208 void sourceMenuAboutToShow();
209 void sourceMenuActionTriggered( QAction *action );
210
211 private:
212 // IMPORTANT - must match order of widgets in the stacked widget!
213 enum SourceType
214 {
215 StaticValue = 0,
216 Expression = 1,
217 ModelParameter = 2,
218 ChildOutput = 3,
219 ModelOutput = 4,
220 };
221
222 SourceType currentSourceType() const;
223
224 void updateUi();
225
226 QgsProcessingModelAlgorithm *mModel = nullptr;
227 const QString mChildId;
228 const QgsProcessingParameterDefinition *mParameterDefinition = nullptr;
229 QgsProcessingContext &mContext;
230
231 QVariant mStaticValue;
232 QString mModelInputParameterName;
233 QString mOutputChildId;
234 QString mOutputName;
235 QString mExpression;
236
237 QToolButton *mSourceButton = nullptr;
238 QMenu *mSourceMenu = nullptr;
239 QStackedWidget *mStackedWidget = nullptr;
240
241 bool mHasStaticWrapper = false;
242 std::unique_ptr<QgsAbstractProcessingParameterWidgetWrapper> mStaticWidgetWrapper;
243 QgsExpressionLineEdit *mExpressionWidget = nullptr;
244 QComboBox *mModelInputCombo = nullptr;
245 QComboBox *mChildOutputCombo = nullptr;
246 QgsFilterLineEdit *mModelOutputName = nullptr;
247
248 QList<Qgis::ProcessingModelChildParameterSource> mLimitedSources;
249 friend class TestProcessingGui;
250};
251
252
253#endif // QGSPROCESSINGMODELERPARAMETERWIDGET_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:59
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 changed()
Emitted whenever the definition of the parameter is changed in the widget.
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:52
#define SIP_FACTORY
Definition qgis_sip.h:83