QGIS API Documentation 3.41.0-Master (d5b93354e9c)
Loading...
Searching...
No Matches
qgsprocessingfieldmapwidgetwrapper.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingfieldmapwidgetwrapper.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 QGSPROCESSINGFIELDMAPWIDGETWRAPPER_H
17#define QGSPROCESSINGFIELDMAPWIDGETWRAPPER_H
18
19#define SIP_NO_FILE
20
23
24#include "ui_qgsprocessingfieldsmappingpanelbase.h"
25
26class QLineEdit;
27class QToolButton;
28
30
31
32class GUI_EXPORT QgsProcessingFieldMapPanelWidget : public QgsPanelWidget, private Ui::QgsProcessingFieldMapPanelBase
33{
34 Q_OBJECT
35
36 public:
37 QgsProcessingFieldMapPanelWidget( 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 QgsFieldMappingModel *mModel = nullptr;
61
62 QgsVectorLayer *mLayer = nullptr;
63 bool mBlockChangedSignal = false;
64};
65
66
67class GUI_EXPORT QgsProcessingFieldMapParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
68{
69 Q_OBJECT
70 public:
71 QgsProcessingFieldMapParameterDefinitionWidget( QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition = nullptr, const QgsProcessingAlgorithm *algorithm = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
72 QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, Qgis::ProcessingParameterFlags flags ) const override;
73
74 private:
75 QComboBox *mParentLayerComboBox = nullptr;
76};
77
78
79class GUI_EXPORT QgsProcessingFieldMapWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
80{
81 Q_OBJECT
82
83 public:
84 QgsProcessingFieldMapWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr, QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard, QWidget *parent = nullptr );
85
86 // QgsProcessingParameterWidgetFactoryInterface
87 QString parameterType() const override;
89
90 // QgsProcessingParameterWidgetWrapper interface
91 QWidget *createWidget() override SIP_FACTORY;
92 QgsProcessingAbstractParameterDefinitionWidget *createParameterDefinitionWidget(
93 QgsProcessingContext &context,
94 const QgsProcessingParameterWidgetContext &widgetContext,
95 const QgsProcessingParameterDefinition *definition = nullptr,
96 const QgsProcessingAlgorithm *algorithm = nullptr
97 ) override;
98
99 void postInitialize( const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers ) override;
100 int stretch() const override;
101
102 public slots:
103 void setParentLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *parentWrapper );
104
105 protected:
106 void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
107 QVariant widgetValue() const override;
108
109 QStringList compatibleParameterTypes() const override;
110 QStringList compatibleOutputTypes() const override;
111 QString modelerExpressionFormatString() const override;
112 const QgsVectorLayer *linkedVectorLayer() const override;
113
114 private:
115 QgsProcessingFieldMapPanelWidget *mPanel = nullptr;
116 std::unique_ptr<QgsVectorLayer> mParentLayer;
117
118 friend class TestProcessingGui;
119};
120
121
123
124#endif // QGSPROCESSINGFIELDMAPWIDGETWRAPPER_H
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
Definition qgis.h:3544
A widget wrapper for Processing parameter value widgets.
Abstract interface for generating an expression context.
The QgsFieldMappingModel holds mapping information for mapping from one set of QgsFields to another,...
Base class for any widget that can be shown as a inline panel.
Abstract base class for widgets which allow users to specify the properties of a Processing parameter...
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
WidgetType
Types of dialogs which Processing widgets can be created for.
@ Standard
Standard algorithm dialog.
Base class for the definition of processing parameters.
Contains settings which reflect the context in which a Processing parameter widget is shown,...
An interface for Processing widget wrapper factories.
Represents a vector layer which manages a vector based data sets.
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:53
#define SIP_FACTORY
Definition qgis_sip.h:76