QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsprocessingaggregatewidgetwrapper.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingaggregatewidgetwrapper.h
3  ---------------------
4  Date : June 2020
5  Copyright : (C) 2020 by Nyall Dawson
6  Email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSPROCESSINGAGGREGATEWIDGETWRAPPER_H
17 #define QGSPROCESSINGAGGREGATEWIDGETWRAPPER_H
18 
19 #define SIP_NO_FILE
20 
23 
24 #include "ui_qgsprocessingaggregatemappingpanelbase.h"
25 
26 class QLineEdit;
27 class QToolButton;
28 
30 
31 class GUI_EXPORT QgsProcessingAggregatePanelWidget : public QgsPanelWidget, private Ui::QgsProcessingAggregateMapPanelBase
32 {
33  Q_OBJECT
34 
35  public:
36  QgsProcessingAggregatePanelWidget( QWidget *parent = nullptr );
37 
38  void setLayer( QgsVectorLayer *layer );
39  QgsVectorLayer *layer();
40  QVariant value() const;
41  void setValue( const QVariant &value );
42 
47  void registerExpressionContextGenerator( const QgsExpressionContextGenerator *generator );
48 
49  signals:
50 
51  void changed();
52 
53  private slots:
54  void loadFieldsFromLayer();
55  void addField();
56  void loadLayerFields();
57 
58  private:
59  QgsAggregateMappingModel *mModel = nullptr;
60 
61  QgsVectorLayer *mLayer = nullptr;
62  bool mBlockChangedSignal = false;
63 };
64 
65 
66 class GUI_EXPORT QgsProcessingAggregateParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
67 {
68  Q_OBJECT
69  public:
70 
71  QgsProcessingAggregateParameterDefinitionWidget( QgsProcessingContext &context,
72  const QgsProcessingParameterWidgetContext &widgetContext,
73  const QgsProcessingParameterDefinition *definition = nullptr,
74  const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
75  QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, QgsProcessingParameterDefinition::Flags flags ) const override;
76 
77  private:
78 
79  QComboBox *mParentLayerComboBox = nullptr;
80 
81 };
82 
83 
84 class GUI_EXPORT QgsProcessingAggregateWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
85 {
86  Q_OBJECT
87 
88  public:
89 
90  QgsProcessingAggregateWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr,
91  QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
92 
93  // QgsProcessingParameterWidgetFactoryInterface
94  QString parameterType() const override;
96 
97  // QgsProcessingParameterWidgetWrapper interface
98  QWidget *createWidget() override SIP_FACTORY;
99  QgsProcessingAbstractParameterDefinitionWidget *createParameterDefinitionWidget(
100  QgsProcessingContext &context,
101  const QgsProcessingParameterWidgetContext &widgetContext,
102  const QgsProcessingParameterDefinition *definition = nullptr,
103  const QgsProcessingAlgorithm *algorithm = nullptr ) override;
104 
105  void postInitialize( const QList< QgsAbstractProcessingParameterWidgetWrapper * > &wrappers ) override;
106  int stretch() const override;
107 
108  public slots:
109  void setParentLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *parentWrapper );
110 
111  protected:
112 
113  void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
114  QVariant widgetValue() const override;
115 
116  QStringList compatibleParameterTypes() const override;
117  QStringList compatibleOutputTypes() const override;
118  QString modelerExpressionFormatString() const override;
119  const QgsVectorLayer *linkedVectorLayer() const override;
120  private:
121 
122  QgsProcessingAggregatePanelWidget *mPanel = nullptr;
123  std::unique_ptr< QgsVectorLayer > mParentLayer;
124 
125  friend class TestProcessingGui;
126 };
127 
128 
130 
131 #endif // QGSPROCESSINGAGGREGATEWIDGETWRAPPER_H
QgsProcessingParameterWidgetContext
Contains settings which reflect the context in which a Processing parameter widget is shown,...
Definition: qgsprocessingwidgetwrapper.h:100
QgsAbstractProcessingParameterWidgetWrapper::createWidget
virtual QWidget * createWidget()=0
Creates a new widget which allows customization of the parameter's value.
qgsprocessingparameterdefinitionwidget.h
algorithm
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
QgsProcessingParameterDefinition
Base class for the definition of processing parameters.
Definition: qgsprocessingparameters.h:331
QgsAbstractProcessingParameterWidgetWrapper
A widget wrapper for Processing parameter value widgets.
Definition: qgsprocessingwidgetwrapper.h:267
QgsProcessingParameterWidgetFactoryInterface::createWidgetWrapper
virtual QgsAbstractProcessingParameterWidgetWrapper * createWidgetWrapper(const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type)=0
Creates a new widget wrapper for the specified parameter definition.
QgsProcessingGui::Standard
@ Standard
Standard algorithm dialog.
Definition: qgsprocessinggui.h:40
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
geos::unique_ptr
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:30
QgsProcessingParameterWidgetFactoryInterface::parameterType
virtual QString parameterType() const =0
Returns the type string for the parameter type the factory is associated with.
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition: qgsprocessingcontext.h:44
QgsProcessingAbstractParameterDefinitionWidget::createParameter
virtual QgsProcessingParameterDefinition * createParameter(const QString &name, const QString &description, QgsProcessingParameterDefinition::Flags flags) const =0
Returns a new instance of a parameter definition, using the current settings defined in the dialog.
qgsprocessingwidgetwrapper.h
QgsProcessingAbstractParameterDefinitionWidget
Abstract base class for widgets which allow users to specify the properties of a Processing parameter...
Definition: qgsprocessingparameterdefinitionwidget.h:44
QgsProcessingGui::WidgetType
WidgetType
Types of dialogs which Processing widgets can be created for.
Definition: qgsprocessinggui.h:39
QgsProcessingParameterWidgetFactoryInterface
An interface for Processing widget wrapper factories.
Definition: qgsprocessingwidgetwrapper.h:515
QgsProcessingAlgorithm
Abstract base class for processing algorithms.
Definition: qgsprocessingalgorithm.h:52
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsAggregateMappingModel
The QgsAggregateMappingModel holds mapping information for defining sets of aggregates of fields from...
Definition: qgsprocessingaggregatewidgets.h:42
QgsExpressionContextGenerator
Abstract interface for generating an expression context.
Definition: qgsexpressioncontextgenerator.h:37
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53