QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
152 
153  private slots:
154 
155  void sourceMenuAboutToShow();
156  void sourceMenuActionTriggered( QAction *action );
157 
158  private:
159 
160  // IMPORTANT - must match order of widgets in the stacked widget!
161  enum SourceType
162  {
163  StaticValue = 0,
164  Expression = 1,
165  ModelParameter = 2,
166  ChildOutput = 3,
167  };
168 
169  SourceType currentSourceType() const;
170 
171  void setSourceType( QgsProcessingModelChildParameterSource::Source type );
172  void updateUi();
173 
174  QgsProcessingModelAlgorithm *mModel = nullptr;
175  const QString mChildId;
176  const QgsProcessingParameterDefinition *mParameterDefinition = nullptr;
177  QgsProcessingContext &mContext;
178 
179  QVariant mStaticValue;
180  QString mModelInputParameterName;
181  QString mOutputChildId;
182  QString mOutputName;
183  QString mExpression;
184 
185  QToolButton *mSourceButton = nullptr;
186  QMenu *mSourceMenu = nullptr;
187  QStackedWidget *mStackedWidget = nullptr;
188 
189  bool mHasStaticWrapper = false;
190  std::unique_ptr< QgsAbstractProcessingParameterWidgetWrapper > mStaticWidgetWrapper;
191  QgsExpressionLineEdit *mExpressionWidget = nullptr;
192  QComboBox *mModelInputCombo = nullptr;
193  QComboBox *mChildOutputCombo = nullptr;
194 
195  friend class TestProcessingGui;
196 };
197 
198 
199 #endif // QGSPROCESSINGMODELERPARAMETERWIDGET_H
A widget wrapper for Processing parameter value widgets.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
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:69
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.