QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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
20#include "ui_qgsprocessingfieldsmappingpanelbase.h"
21
24
25#define SIP_NO_FILE
26
27class QLineEdit;
28class QToolButton;
29
31
32
33class GUI_EXPORT QgsProcessingFieldMapPanelWidget : public QgsPanelWidget, private Ui::QgsProcessingFieldMapPanelBase
34{
35 Q_OBJECT
36
37 public:
38 QgsProcessingFieldMapPanelWidget( QWidget *parent = nullptr );
39
40 void setLayer( QgsVectorLayer *layer );
41 QgsVectorLayer *layer();
42 QVariant value() const;
43 void setValue( const QVariant &value );
44
49 void registerExpressionContextGenerator( const QgsExpressionContextGenerator *generator );
50
57 void setProcessingModeType( Qgis::ProcessingMode type );
58
59 signals:
60
61 void changed();
62
63 private slots:
64 void loadFieldsFromLayer();
65 void addField();
66 void loadLayerFields();
67
68 private:
69 QgsFieldMappingModel *mModel = nullptr;
70
71
73
74 QgsVectorLayer *mLayer = nullptr;
75 bool mSkipConfirmDialog = false;
76
77 bool mBlockChangedSignal = false;
78 friend class TestProcessingGui;
79};
80
81
82class GUI_EXPORT QgsProcessingFieldMapParameterDefinitionWidget : public QgsProcessingAbstractParameterDefinitionWidget
83{
84 Q_OBJECT
85 public:
86 QgsProcessingFieldMapParameterDefinitionWidget(
87 QgsProcessingContext &context,
88 const QgsProcessingParameterWidgetContext &widgetContext,
89 const QgsProcessingParameterDefinition *definition = nullptr,
90 const QgsProcessingAlgorithm *algorithm = nullptr,
91 QWidget *parent SIP_TRANSFERTHIS = nullptr
92 );
93 QgsProcessingParameterDefinition *createParameter( const QString &name, const QString &description, Qgis::ProcessingParameterFlags flags ) const override;
94
95 private:
96 QComboBox *mParentLayerComboBox = nullptr;
97};
98
99
100class GUI_EXPORT QgsProcessingFieldMapWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper, public QgsProcessingParameterWidgetFactoryInterface
101{
102 Q_OBJECT
103
104 public:
105 QgsProcessingFieldMapWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr, Qgis::ProcessingMode type = Qgis::ProcessingMode::Standard, QWidget *parent = nullptr );
106
107 // QgsProcessingParameterWidgetFactoryInterface
108 QString parameterType() const override;
109 QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, Qgis::ProcessingMode type ) override SIP_FACTORY;
110
111 // QgsProcessingParameterWidgetWrapper interface
112 QWidget *createWidget() override SIP_FACTORY;
113 QgsProcessingAbstractParameterDefinitionWidget *createParameterDefinitionWidget(
114 QgsProcessingContext &context, const QgsProcessingParameterWidgetContext &widgetContext, const QgsProcessingParameterDefinition *definition = nullptr, const QgsProcessingAlgorithm *algorithm = nullptr
115 ) override;
116
117 void postInitialize( const QList<QgsAbstractProcessingParameterWidgetWrapper *> &wrappers ) override;
118 int stretch() const override;
119
120 public slots:
121 void setParentLayerWrapperValue( const QgsAbstractProcessingParameterWidgetWrapper *parentWrapper );
122
123 protected:
124 void setWidgetValue( const QVariant &value, QgsProcessingContext &context ) override;
125 QVariant widgetValue() const override;
126
127 QString modelerExpressionFormatString() const override;
128 const QgsVectorLayer *linkedVectorLayer() const override;
129
130 private:
131 QgsProcessingFieldMapPanelWidget *mPanel = nullptr;
132 std::unique_ptr<QgsVectorLayer> mParentLayer;
133
134 friend class TestProcessingGui;
135};
136
137
139
140#endif // QGSPROCESSINGFIELDMAPWIDGETWRAPPER_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.
Abstract interface for generating an expression context.
Holds mapping information for mapping from one set of QgsFields to another.
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