QGIS API Documentation 4.3.0-Master (d57cc4a041c)
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( QWidget *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 void emitChangedSignal();
213
214 private:
215 // IMPORTANT - must match order of widgets in the stacked widget!
216 enum SourceType
217 {
218 StaticValue = 0,
219 Expression = 1,
220 ModelParameter = 2,
221 ChildOutput = 3,
222 ModelOutput = 4,
223 };
224
225 SourceType currentSourceType() const;
226
227 void updateUi();
228
229 QgsProcessingModelAlgorithm *mModel = nullptr;
230 const QString mChildId;
231 const QgsProcessingParameterDefinition *mParameterDefinition = nullptr;
232 QgsProcessingContext &mContext;
233
234 QVariant mStaticValue;
235 QString mModelInputParameterName;
236 QString mOutputChildId;
237 QString mOutputName;
238 QString mExpression;
239
240 QToolButton *mSourceButton = nullptr;
241 QMenu *mSourceMenu = nullptr;
242 QStackedWidget *mStackedWidget = nullptr;
243
244 bool mHasStaticWrapper = false;
245 std::unique_ptr<QgsAbstractProcessingParameterWidgetWrapper> mStaticWidgetWrapper;
246 QgsExpressionLineEdit *mExpressionWidget = nullptr;
247 QComboBox *mModelInputCombo = nullptr;
248 QComboBox *mChildOutputCombo = nullptr;
249 QgsFilterLineEdit *mModelOutputName = nullptr;
250
251 QList<Qgis::ProcessingModelChildParameterSource> mLimitedSources;
252
253 int mBlockChangesSignal = 0;
254
255 friend class TestProcessingGui;
256};
257
258
259#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...
void setDialog(QWidget *dialog)
Sets the parent dialog (or widget) in which the widget is shown.
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 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