QGIS API Documentation  3.21.0-Master (5b68dc587e)
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 <QWidget>
23 #include "qgis_gui.h"
24 #include "qgis_sip.h"
25 #include <QPointer>
26 #include "qgsprocessingcontext.h"
27 #include "processing/models/qgsprocessingmodelchildparametersource.h"
28 
32 class QgsProcessingModelAlgorithm;
35 class QgsFilterLineEdit;
36 
37 class QLabel;
38 class QToolButton;
39 class QMenu;
40 class QStackedWidget;
41 class QComboBox;
42 
61 class GUI_EXPORT QgsProcessingModelerParameterWidget : public QWidget, public QgsExpressionContextGenerator
62 {
63  Q_OBJECT
64 
65  public:
66 
80  QgsProcessingModelerParameterWidget( QgsProcessingModelAlgorithm *model,
81  const QString &childId,
82  const QgsProcessingParameterDefinition *parameter,
83  QgsProcessingContext &context,
84  QWidget *parent SIP_TRANSFERTHIS = nullptr );
85 
87 
93  void setWidgetContext( const QgsProcessingParameterWidgetContext &context );
94 
99  void registerProcessingContextGenerator( QgsProcessingContextGenerator *generator );
100 
115  void populateSources( const QStringList &compatibleParameterTypes,
116  const QStringList &compatibleOutputTypes,
117  const QList< int > &compatibleDataTypes );
118 
124  void setExpressionHelpText( const QString &text );
125 
129  const QgsProcessingParameterDefinition *parameterDefinition() const;
130 
136  QLabel *createLabel() SIP_FACTORY;
137 
143  virtual void setWidgetValue( const QgsProcessingModelChildParameterSource &value );
144 
151  void setWidgetValue( const QList< QgsProcessingModelChildParameterSource > &values );
152 
160  void setToModelOutput( const QString &value );
161 
169  bool isModelOutput() const;
170 
178  QString modelOutputName() const;
179 
185  virtual QVariant value() const;
186 
192  void setDialog( QDialog *dialog );
193 
194  QgsExpressionContext createExpressionContext() const override;
195 
196  private slots:
197 
198  void sourceMenuAboutToShow();
199  void sourceMenuActionTriggered( QAction *action );
200 
201  private:
202 
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 setSourceType( QgsProcessingModelChildParameterSource::Source type );
216  void updateUi();
217 
218  QgsProcessingModelAlgorithm *mModel = nullptr;
219  const QString mChildId;
220  const QgsProcessingParameterDefinition *mParameterDefinition = nullptr;
221  QgsProcessingContext &mContext;
222 
223  QVariant mStaticValue;
224  QString mModelInputParameterName;
225  QString mOutputChildId;
226  QString mOutputName;
227  QString mExpression;
228 
229  QToolButton *mSourceButton = nullptr;
230  QMenu *mSourceMenu = nullptr;
231  QStackedWidget *mStackedWidget = nullptr;
232 
233  bool mHasStaticWrapper = false;
234  std::unique_ptr< QgsAbstractProcessingParameterWidgetWrapper > mStaticWidgetWrapper;
235  QgsExpressionLineEdit *mExpressionWidget = nullptr;
236  QComboBox *mModelInputCombo = nullptr;
237  QComboBox *mChildOutputCombo = nullptr;
238  QgsFilterLineEdit *mModelOutputName = nullptr;
239 
240  friend class TestProcessingGui;
241 };
242 
243 
244 #endif // QGSPROCESSINGMODELERPARAMETERWIDGET_H
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...
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
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.
A widget for customising the value of Processing algorithm parameter inside a Processing model.
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:76