QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
Loading...
Searching...
No Matches
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
20#include "ui_qgsprocessingaggregatemappingpanelbase.h"
21
24
25#define SIP_NO_FILE
26
27class QLineEdit;
28class QToolButton;
29
31
32class GUI_EXPORT QgsProcessingAggregatePanelWidget : public QgsPanelWidget, private Ui::QgsProcessingAggregateMapPanelBase
33{
34 Q_OBJECT
35
36 public:
37 QgsProcessingAggregatePanelWidget( QWidget *parent = nullptr );
38
39 void setLayer( QgsVectorLayer *layer );
40 QgsVectorLayer *layer();
41 QVariant value() const;
42 void setValue( const QVariant &value );
43
48 void registerExpressionContextGenerator( const QgsExpressionContextGenerator *generator );
49
50 signals:
51
52 void changed();
53
54 private slots:
55 void loadFieldsFromLayer();
56 void addField();
57 void loadLayerFields();
58
59 private:
60 QgsAggregateMappingModel *mModel = nullptr;
61
62 QgsVectorLayer *mLayer = nullptr;
63 bool mBlockChangedSignal = false;
64
65 bool mSkipConfirmDialog = false;
66 friend class TestProcessingGui;
67};
68
69
70class GUI_EXPORT QgsProcessingAggregateParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
71{
72 Q_OBJECT
73 public:
74 QgsProcessingAggregateParameterDefinitionWidget(
75 QgsProcessingContext &context,
76 const QgsProcessingParameterWidgetContext &widgetContext,
77 const QgsProcessingParameterDefinition *definition = nullptr,
78 const QgsProcessingAlgorithm *algorithm = nullptr,
79 QWidget *parent SIP_TRANSFERTHIS = nullptr
80 );
81 QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, Qgis::ProcessingParameterFlags flags ) const override;
82
83 private:
84 QComboBox *mParentLayerComboBox = nullptr;
85};
86
87
88class GUI_EXPORT QgsProcessingAggregateWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
89{
90 Q_OBJECT
91
92 public:
93 QgsProcessingAggregateWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr, Qgis::ProcessingMode type = Qgis::ProcessingMode::Standard, QWidget *parent = nullptr );
94
95 // QgsProcessingParameterWidgetFactoryInterface
96 QString parameterType() const override;
97 QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, Qgis::ProcessingMode type ) override SIP_FACTORY;
98
99 // QgsProcessingParameterWidgetWrapper interface
100 QWidget *createWidget() override SIP_FACTORY;
101 QgsProcessingAbstractParameterDefinitionWidget *createParameterDefinitionWidget(
102 QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition = nullptr, const QgsProcessingAlgorithm *algorithm = nullptr
103 ) 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 void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
113 QVariant widgetValue() const override;
114
115 QString modelerExpressionFormatString() const override;
116 const QgsVectorLayer *linkedVectorLayer() const override;
117
118 private:
119 QgsProcessingAggregatePanelWidget *mPanel = nullptr;
120 std::unique_ptr<QgsVectorLayer> mParentLayer;
121
122 friend class TestProcessingGui;
123};
124
125
127
128#endif // QGSPROCESSINGAGGREGATEWIDGETWRAPPER_H
ProcessingMode
Types of modes which Processing widgets can be created for.
Definition qgis.h:3786
@ Standard
Standard (single-run) algorithm mode.
Definition qgis.h:3787
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
Definition qgis.h:3894
A widget wrapper for Processing parameter value widgets.
Holds mapping information for defining sets of aggregates of fields from a QgsFields object.
Abstract interface for generating an expression context.
Base class for any widget that can be shown as an inline panel.
Abstract base class for widgets which allow users to specify the properties of a Processing parameter...
An interface for Processing widget wrapper factories.
Represents a vector layer which manages a vector based dataset.
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
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_FACTORY
Definition qgis_sip.h:83