QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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"
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 
195 
201  void setSourceType( QgsProcessingModelChildParameterSource::Source type );
202 
203  private slots:
204 
205  void sourceMenuAboutToShow();
206  void sourceMenuActionTriggered( QAction *action );
207 
208  private:
209 
210  // IMPORTANT - must match order of widgets in the stacked widget!
211  enum SourceType
212  {
213  StaticValue = 0,
214  Expression = 1,
215  ModelParameter = 2,
216  ChildOutput = 3,
217  ModelOutput = 4,
218  };
219 
220  SourceType currentSourceType() const;
221 
222  void updateUi();
223 
224  QgsProcessingModelAlgorithm *mModel = nullptr;
225  const QString mChildId;
226  const QgsProcessingParameterDefinition *mParameterDefinition = nullptr;
227  QgsProcessingContext &mContext;
228 
229  QVariant mStaticValue;
230  QString mModelInputParameterName;
231  QString mOutputChildId;
232  QString mOutputName;
233  QString mExpression;
234 
235  QToolButton *mSourceButton = nullptr;
236  QMenu *mSourceMenu = nullptr;
237  QStackedWidget *mStackedWidget = nullptr;
238 
239  bool mHasStaticWrapper = false;
240  std::unique_ptr< QgsAbstractProcessingParameterWidgetWrapper > mStaticWidgetWrapper;
241  QgsExpressionLineEdit *mExpressionWidget = nullptr;
242  QComboBox *mModelInputCombo = nullptr;
243  QComboBox *mChildOutputCombo = nullptr;
244  QgsFilterLineEdit *mModelOutputName = nullptr;
245 
246  friend class TestProcessingGui;
247 };
248 
249 
250 #endif // QGSPROCESSINGMODELERPARAMETERWIDGET_H
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
QgsProcessingParameterWidgetContext
Contains settings which reflect the context in which a Processing parameter widget is shown,...
Definition: qgsprocessingwidgetwrapper.h:115
QgsFilterLineEdit
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
Definition: qgsfilterlineedit.h:39
QgsProcessingParameterDefinition
Base class for the definition of processing parameters.
Definition: qgsprocessingparameters.h:334
QgsAbstractProcessingParameterWidgetWrapper
A widget wrapper for Processing parameter value widgets.
Definition: qgsprocessingwidgetwrapper.h:282
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition: qgsprocessingcontext.h:46
qgis_sip.h
QgsProcessingModelerParameterWidget
A widget for customising the value of Processing algorithm parameter inside a Processing model.
Definition: qgsprocessingmodelerparameterwidget.h:61
QgsExpressionContextGenerator::createExpressionContext
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsExpressionLineEdit
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
Definition: qgsexpressionlineedit.h:48
qgsprocessingcontext.h
qgsprocessingmodelchildparametersource.h
QgsExpressionContextGenerator
Abstract interface for generating an expression context.
Definition: qgsexpressioncontextgenerator.h:36
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsProcessingContextGenerator
An interface for objects which can create Processing contexts.
Definition: qgsprocessingwidgetwrapper.h:52