QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 
36 class QLabel;
37 class QToolButton;
38 class QMenu;
39 class QStackedWidget;
40 class QComboBox;
41 
60 class GUI_EXPORT QgsProcessingModelerParameterWidget : public QWidget, public QgsExpressionContextGenerator
61 {
62  Q_OBJECT
63 
64  public:
65 
79  QgsProcessingModelerParameterWidget( QgsProcessingModelAlgorithm *model,
80  const QString &childId,
81  const QgsProcessingParameterDefinition *parameter,
82  QgsProcessingContext &context,
83  QWidget *parent SIP_TRANSFERTHIS = nullptr );
84 
86 
92  void setWidgetContext( const QgsProcessingParameterWidgetContext &context );
93 
98  void registerProcessingContextGenerator( QgsProcessingContextGenerator *generator );
99 
114  void populateSources( const QStringList &compatibleParameterTypes,
115  const QStringList &compatibleOutputTypes,
116  const QList< int > &compatibleDataTypes );
117 
123  void setExpressionHelpText( const QString &text );
124 
128  const QgsProcessingParameterDefinition *parameterDefinition() const;
129 
135  QLabel *createLabel() SIP_FACTORY;
136 
142  virtual void setWidgetValue( const QgsProcessingModelChildParameterSource &value );
143 
149  virtual QgsProcessingModelChildParameterSource value() const;
150 
156  void setDialog( QDialog *dialog );
157 
159 
160  private slots:
161 
162  void sourceMenuAboutToShow();
163  void sourceMenuActionTriggered( QAction *action );
164 
165  private:
166 
167  // IMPORTANT - must match order of widgets in the stacked widget!
168  enum SourceType
169  {
170  StaticValue = 0,
171  Expression = 1,
172  ModelParameter = 2,
173  ChildOutput = 3,
174  };
175 
176  SourceType currentSourceType() const;
177 
178  void setSourceType( QgsProcessingModelChildParameterSource::Source type );
179  void updateUi();
180 
181  QgsProcessingModelAlgorithm *mModel = nullptr;
182  const QString mChildId;
183  const QgsProcessingParameterDefinition *mParameterDefinition = nullptr;
184  QgsProcessingContext &mContext;
185 
186  QVariant mStaticValue;
187  QString mModelInputParameterName;
188  QString mOutputChildId;
189  QString mOutputName;
190  QString mExpression;
191 
192  QToolButton *mSourceButton = nullptr;
193  QMenu *mSourceMenu = nullptr;
194  QStackedWidget *mStackedWidget = nullptr;
195 
196  bool mHasStaticWrapper = false;
197  std::unique_ptr< QgsAbstractProcessingParameterWidgetWrapper > mStaticWidgetWrapper;
198  QgsExpressionLineEdit *mExpressionWidget = nullptr;
199  QComboBox *mModelInputCombo = nullptr;
200  QComboBox *mChildOutputCombo = nullptr;
201 
202  friend class TestProcessingGui;
203 };
204 
205 
206 #endif // QGSPROCESSINGMODELERPARAMETERWIDGET_H
A widget wrapper for Processing parameter value widgets.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
A widget for customising the value of Processing algorithm parameter inside a Processing model...
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
An interface for objects which can create Processing contexts.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
#define SIP_FACTORY
Definition: qgis_sip.h:76
Abstract interface for generating an expression context.
Contains settings which reflect the context in which a Processing parameter widget is shown...
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
Base class for the definition of processing parameters.
Contains information about the context in which a processing algorithm is executed.