@@ -57,6 +57,40 @@ Returns the duplicated features in the given layer
5757
5858 };
5959
60+ class QgsFeatureData
61+ {
62+ %Docstring
63+ Encapsulate geometry and attributes for new features, to be passed to createFeatures
64+
65+ .. seealso:: :py:func:`createFeatures`
66+
67+ .. versionadded:: 3.6
68+ %End
69+
70+ %TypeHeaderCode
71+ #include "qgsvectorlayerutils.h"
72+ %End
73+ public:
74+
75+ QgsFeatureData( const QgsGeometry &geometry = QgsGeometry(), const QgsAttributeMap &attributes = QgsAttributeMap() );
76+ %Docstring
77+ Constructs a new QgsFeatureData with given ``geometry`` and ``attributes``
78+ %End
79+
80+ QgsGeometry geometry() const;
81+ %Docstring
82+ Returns geometry
83+ %End
84+
85+ QgsAttributeMap attributes() const;
86+ %Docstring
87+ Returns attributes
88+ %End
89+
90+ };
91+
92+ typedef QList<QgsVectorLayerUtils::QgsFeatureData> QgsFeaturesDataList;
93+
6094 static QgsFeatureIterator getValuesIterator( const QgsVectorLayer *layer, const QString &fieldOrExpression, bool &ok, bool selectedOnly );
6195%Docstring
6296Create a feature iterator for a specified field name or expression.
@@ -122,6 +156,15 @@ Returns a new attribute value for the specified field index which is guaranteed
122156value can be used as a basis for generated values.
123157
124158.. seealso:: :py:func:`valueExists`
159+ %End
160+
161+ static QVariant createUniqueValueFromCache( const QgsVectorLayer *layer, int fieldIndex, const QSet<QVariant> &existingValues, const QVariant &seed = QVariant() );
162+ %Docstring
163+ Returns a new attribute value for the specified field index which is guaranteed to
164+ be unique within regard to ``existingValues``.
165+ The optional seed value can be used as a basis for generated values.
166+
167+ .. versionadded:: 3.6
125168%End
126169
127170 static bool validateAttribute( const QgsVectorLayer *layer, const QgsFeature &feature, int attributeIndex, QStringList &errors /Out/,
@@ -143,6 +186,21 @@ Creates a new feature ready for insertion into a layer. Default values and const
143186passed for the new feature to copy as many attribute values as possible from the map,
144187assuming that they respect the layer's constraints. Note that the created feature is not
145188automatically inserted into the layer.
189+
190+ .. seealso:: :py:func:`createFeatures`
191+ %End
192+
193+ static QgsFeatureList createFeatures( const QgsVectorLayer *layer,
194+ const QgsFeaturesDataList &featuresData,
195+ QgsExpressionContext *context = 0 );
196+ %Docstring
197+ Creates a set of new features ready for insertion into a layer. Default values and constraints
198+ (e.g., unique constraints) will automatically be handled. Note that the created features are not
199+ automatically inserted into the layer.
200+
201+ .. seealso:: :py:func:`createFeature`
202+
203+ .. versionadded:: 3.6
146204%End
147205
148206 static QgsFeature duplicateFeature( QgsVectorLayer *layer, const QgsFeature &feature, QgsProject *project, int depth, QgsDuplicateFeatureContext &duplicateFeatureContext /Out/ );
0 commit comments