QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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:
81 QgsProcessingModelAlgorithm *model, const QString &childId, const QgsProcessingParameterDefinition *parameter, QgsProcessingContext &context, QWidget *parent SIP_TRANSFERTHIS = nullptr
82 );
83
85
92
98
113 void populateSources( const QStringList &compatibleParameterTypes, const QStringList &compatibleOutputTypes, const QList<int> &compatibleDataTypes );
114
120 void setExpressionHelpText( const QString &text );
121
126
132 QLabel *createLabel() SIP_FACTORY;
133
139 virtual void setWidgetValue( const QgsProcessingModelChildParameterSource &value );
140
147 void setWidgetValue( const QList<QgsProcessingModelChildParameterSource> &values );
148
156 void setToModelOutput( const QString &value );
157
165 bool isModelOutput() const;
166
174 QString modelOutputName() const;
175
181 virtual QVariant value() const;
182
188 void setDialog( QDialog *dialog );
189
191
197 void setSourceType( Qgis::ProcessingModelChildParameterSource type );
198
199 signals:
200
206 void changed();
207
208 private slots:
209
210 void sourceMenuAboutToShow();
211 void sourceMenuActionTriggered( QAction *action );
212
213 private:
214 // IMPORTANT - must match order of widgets in the stacked widget!
215 enum SourceType
216 {
217 StaticValue = 0,
218 Expression = 1,
219 ModelParameter = 2,
220 ChildOutput = 3,
221 ModelOutput = 4,
222 };
223
224 SourceType currentSourceType() const;
225
226 void updateUi();
227
228 QgsProcessingModelAlgorithm *mModel = nullptr;
229 const QString mChildId;
230 const QgsProcessingParameterDefinition *mParameterDefinition = nullptr;
231 QgsProcessingContext &mContext;
232
233 QVariant mStaticValue;
234 QString mModelInputParameterName;
235 QString mOutputChildId;
236 QString mOutputName;
237 QString mExpression;
238
239 QToolButton *mSourceButton = nullptr;
240 QMenu *mSourceMenu = nullptr;
241 QStackedWidget *mStackedWidget = nullptr;
242
243 bool mHasStaticWrapper = false;
244 std::unique_ptr<QgsAbstractProcessingParameterWidgetWrapper> mStaticWidgetWrapper;
245 QgsExpressionLineEdit *mExpressionWidget = nullptr;
246 QComboBox *mModelInputCombo = nullptr;
247 QComboBox *mChildOutputCombo = nullptr;
248 QgsFilterLineEdit *mModelOutputName = nullptr;
249
250 QList<Qgis::ProcessingModelChildParameterSource> mLimitedSources;
251 friend class TestProcessingGui;
252};
253
254
255#endif // QGSPROCESSINGMODELERPARAMETERWIDGET_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
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