File: qgsvectorlayerutils.sip.in

package info (click to toggle)
qgis 3.40.6%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,181,336 kB
  • sloc: cpp: 1,593,302; python: 370,494; xml: 23,474; perl: 3,664; sh: 3,482; ansic: 2,257; sql: 2,133; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 157
file content (432 lines) | stat: -rw-r--r-- 16,010 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/vector/qgsvectorlayerutils.h                                *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/







class QgsVectorLayerUtils
{
%Docstring(signature="appended")
Contains utility methods for working with :py:class:`QgsVectorLayers`.
%End

%TypeHeaderCode
#include "qgsvectorlayerutils.h"
%End
  public:

    class QgsDuplicateFeatureContext
{
%Docstring(signature="appended")
Contains mainly the QMap with :py:class:`QgsVectorLayer` and
:py:class:`QgsFeatureIds` do list all the duplicated features
%End

%TypeHeaderCode
#include "qgsvectorlayerutils.h"
%End
      public:

        QgsDuplicateFeatureContext();

        QList<QgsVectorLayer *> layers() const;
%Docstring
Returns all the layers on which features have been duplicated
%End

        QgsFeatureIds duplicatedFeatures( QgsVectorLayer *layer ) const;
%Docstring
Returns the duplicated features in the given layer
%End


    };

    class QgsFeatureData
{
%Docstring(signature="appended")
Encapsulate geometry and attributes for new features, to be passed to
createFeatures

.. seealso:: :py:func:`createFeatures`

.. versionadded:: 3.6
%End

%TypeHeaderCode
#include "qgsvectorlayerutils.h"
%End
      public:

        QgsFeatureData( const QgsGeometry &geometry = QgsGeometry(), const QgsAttributeMap &attributes = QgsAttributeMap() );
%Docstring
Constructs a new QgsFeatureData with given ``geometry`` and
``attributes``
%End

        QgsGeometry geometry() const;
%Docstring
Returns geometry
%End

        QgsAttributeMap attributes() const;
%Docstring
Returns attributes
%End

    };

    typedef QList<QgsVectorLayerUtils::QgsFeatureData> QgsFeaturesDataList;

    static QgsFeatureIterator getValuesIterator( const QgsVectorLayer *layer, const QString &fieldOrExpression, bool &ok, bool selectedOnly );
%Docstring
Create a feature iterator for a specified field name or expression.

:param layer: vector layer to retrieve values from
:param fieldOrExpression: field name or an expression string
:param ok: will be set to ``False`` if field or expression is invalid,
           otherwise ``True``
:param selectedOnly: set to ``True`` to get values from selected
                     features only

:return: feature iterator
%End

    static QList< QVariant > getValues( const QgsVectorLayer *layer, const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, QgsFeedback *feedback = 0 );
%Docstring
Fetches all values from a specified field name or expression.

:param layer: vector layer to retrieve values from
:param fieldOrExpression: field name or an expression string
:param ok: will be set to ``False`` if field or expression is invalid,
           otherwise ``True``
:param selectedOnly: set to ``True`` to get values from selected
                     features only
:param feedback: optional feedback object to allow cancellation

:return: list of fetched values

.. seealso:: :py:func:`getDoubleValues`
%End

    static QList< double > getDoubleValues( const QgsVectorLayer *layer, const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int *nullCount = 0, QgsFeedback *feedback = 0 );
%Docstring
Fetches all double values from a specified field name or expression.
Null values or invalid expression results are skipped.

:param layer: vector layer to retrieve values from
:param fieldOrExpression: field name or an expression string evaluating
                          to a double value
:param ok: will be set to ``False`` if field or expression is invalid,
           otherwise ``True``
:param selectedOnly: set to ``True`` to get values from selected
                     features only
:param nullCount: optional pointer to integer to store number of null
                  values encountered in
:param feedback: optional feedback object to allow cancellation

:return: list of fetched values

.. seealso:: :py:func:`getValues`
%End

    static bool valueExists( const QgsVectorLayer *layer, int fieldIndex, const QVariant &value, const QgsFeatureIds &ignoreIds = QgsFeatureIds() );
%Docstring
Returns ``True`` if the specified value already exists within a field.
This method can be used to test for uniqueness of values inside a
layer's attributes. An optional list of ignored feature IDs can be
provided, if so, any features with IDs within this list are ignored when
testing for existence of the value.

.. seealso:: :py:func:`createUniqueValue`
%End

    static QVariant createUniqueValue( const QgsVectorLayer *layer, int fieldIndex, const QVariant &seed = QVariant() );
%Docstring
Returns a new attribute value for the specified field index which is
guaranteed to be unique. The optional seed value can be used as a basis
for generated values.

.. seealso:: :py:func:`valueExists`
%End

    static QVariant createUniqueValueFromCache( const QgsVectorLayer *layer, int fieldIndex, const QSet<QVariant> &existingValues, const QVariant &seed = QVariant() );
%Docstring
Returns a new attribute value for the specified field index which is
guaranteed to be unique within regard to ``existingValues``. The
optional seed value can be used as a basis for generated values.

.. versionadded:: 3.6
%End

    static bool attributeHasConstraints( const QgsVectorLayer *layer, int attributeIndex );
%Docstring
Returns ``True`` if a feature attribute has active constraints.

:param layer: the vector layer from which field constraints will be
              checked for
:param attributeIndex: the attribute index

.. versionadded:: 3.30
%End

    static bool validateAttribute( const QgsVectorLayer *layer, const QgsFeature &feature, int attributeIndex, QStringList &errors /Out/,
                                   QgsFieldConstraints::ConstraintStrength strength = QgsFieldConstraints::ConstraintStrengthNotSet,
                                   QgsFieldConstraints::ConstraintOrigin origin = QgsFieldConstraints::ConstraintOriginNotSet );
%Docstring
Tests a feature attribute value to check whether it passes all
constraints which are present on the corresponding field. Returns
``True`` if the attribute value is valid for the field. Any constraint
failures will be reported in the errors argument. If the strength or
origin parameter is set then only constraints with a matching
strength/origin will be checked.
%End

    static QgsFeature createFeature( const QgsVectorLayer *layer,
                                     const QgsGeometry &geometry = QgsGeometry(),
                                     const QgsAttributeMap &attributes = QgsAttributeMap(),
                                     QgsExpressionContext *context = 0 );
%Docstring
Creates a new feature ready for insertion into a layer. Default values
and constraints (e.g., unique constraints) will automatically be
handled. An optional attribute map can be passed for the new feature to
copy as many attribute values as possible from the map, assuming that
they respect the layer's constraints. Note that the created feature is
not automatically inserted into the layer.

.. seealso:: :py:func:`createFeatures`
%End

    static QgsFeatureList createFeatures( const QgsVectorLayer *layer,
                                          const QgsFeaturesDataList &featuresData,
                                          QgsExpressionContext *context = 0 );
%Docstring
Creates a set of new features ready for insertion into a layer. Default
values and constraints (e.g., unique constraints) will automatically be
handled. Note that the created features are not automatically inserted
into the layer.

.. seealso:: :py:func:`createFeature`

.. versionadded:: 3.6
%End

    static QgsFeature duplicateFeature( QgsVectorLayer *layer, const QgsFeature &feature, QgsProject *project, QgsDuplicateFeatureContext &duplicateFeatureContext /Out/, const int maxDepth = 0 );
%Docstring
Duplicates a feature and it's children (one level deep). It calls
CreateFeature, so default values and constraints (e.g., unique
constraints) will automatically be handled. The duplicated feature will
be automatically inserted into the layer. ``duplicateFeatureContext``
stores all the layers and the featureids of the duplicated features
(incl. children) ``maxDepth`` the maximum depth to duplicate children in
relations, 0 is unlimited depth (in any case, limited to 100) ``depth``
the current depth, not exposed in Python ``referencedLayersBranch`` the
current branch of layers across the relations, not exposed in Python,
taken by copy not reference, used to avoid infinite loop
%End



    static void matchAttributesToFields( QgsFeature &feature, const QgsFields &fields );
%Docstring
Matches the attributes in ``feature`` to the specified ``fields``.

This causes the attributes contained within the given ``feature`` to be
rearranged (or in some cases dropped) in order to match the fields and
order indicated by ``fields``.

The exact behavior depends on whether or not ``feature`` has a valid
fields container set (see :py:func:`QgsFeature.fields()`). If a fields
container is set, then the names of the feature's fields are matched to
``fields``. In this case attributes from ``feature`` will be rearranged
or dropped in order to match the field names from ``fields``.

If the ``feature`` does not have a valid fields container set, then the
feature's attributes are simply truncated to match the number of fields
present in ``fields`` (or if less attributes are present in ``feature``
than in ``fields``, the feature's attributes are padded with NULL values
to match the required length). Finally, the feature's fields are set to
``fields``.

.. versionadded:: 3.4
%End

    static QgsFeatureList makeFeatureCompatible( const QgsFeature &feature, const QgsVectorLayer *layer, QgsFeatureSink::SinkFlags sinkFlags = QgsFeatureSink::SinkFlags() );
%Docstring
Converts input ``feature`` to be compatible with the given ``layer``.

This function returns a new list of transformed features compatible with
the input layer, note that the number of features returned might be
greater than one when converting a multi part geometry to single part

The following operations will be performed to convert the input
features:

- convert single geometries to multi part
- drop additional attributes
- drop geometry if layer is geometry-less
- add missing attribute fields
- add back M/Z values (initialized to 0)
- drop Z/M
- convert multi part geometries to single part

Optionally, ``sinkFlags`` can be specified to further refine the
compatibility logic.

.. versionadded:: 3.4
%End

    static QgsFeatureList makeFeaturesCompatible( const QgsFeatureList &features, const QgsVectorLayer *layer, QgsFeatureSink::SinkFlags sinkFlags = QgsFeatureSink::SinkFlags() );
%Docstring
Converts input ``features`` to be compatible with the given ``layer``.

This function returns a new list of transformed features compatible with
the input layer, note that the number of features returned might be
greater than the number of input features.

The following operations will be performed to convert the input
features:

- convert single geometries to multi part
- drop additional attributes
- drop geometry if layer is geometry-less
- add missing attribute fields
- add back M/Z values (initialized to 0)
- drop Z/M
- convert multi part geometries to single part

Optionally, ``sinkFlags`` can be specified to further refine the
compatibility logic.

.. versionadded:: 3.4
%End

    static bool fieldIsEditable( const QgsVectorLayer *layer, int fieldIndex, const QgsFeature &feature );
%Docstring
Tests whether a field is editable for a particular ``feature``.

:return: ``True`` if the field at index ``fieldIndex`` from ``layer`` is
         editable, ``False`` if the field is read only.

.. versionadded:: 3.10
%End

    static bool fieldIsReadOnly( const QgsVectorLayer *layer, int fieldIndex );
%Docstring
:return: ``True`` if the field at index ``fieldIndex`` from ``layer`` is
         editable, ``False`` if the field is read only.

If this function returns ``True`` then the editability of the field may
still vary feature by feature. See
:py:func:`~QgsVectorLayerUtils.fieldIsEditable` to determine this on a
feature by feature basis.

.. versionadded:: 3.18
%End

    static bool fieldEditabilityDependsOnFeature( const QgsVectorLayer *layer, int fieldIndex );
%Docstring
Returns ``True`` if the editability of the field at index ``fieldIndex``
from ``layer`` may vary feature by feature.

I.e. if the field is taken from a joined layer, the value may or may not
be editable for any individual feature depending on the join's "upsert
on edit" capabilities.

.. versionadded:: 3.18
%End



    static QString getFeatureDisplayString( const QgsVectorLayer *layer, const QgsFeature &feature );
%Docstring
:return: a descriptive string for a ``feature``, suitable for displaying
         to the user. The definition is taken from the
         ``displayExpression`` property of ``layer``.

.. versionadded:: 3.12
%End

    enum CascadedFeatureFlag
    {
      IgnoreAuxiliaryLayers,
    };
    typedef QFlags<QgsVectorLayerUtils::CascadedFeatureFlag> CascadedFeatureFlags;


    static bool impactsCascadeFeatures( const QgsVectorLayer *layer, const QgsFeatureIds &fids, const QgsProject *project, QgsDuplicateFeatureContext &context /Out/, QgsVectorLayerUtils::CascadedFeatureFlags flags = QgsVectorLayerUtils::CascadedFeatureFlags() );
%Docstring
:return: ``True`` if at least one feature of the ``fids`` on ``layer``
         is connected as parent in at least one composition relation of
         the ``project`` or contains joins, where cascade delete is set.
         Details about cascading effects will be written to ``context``.

.. versionadded:: 3.14
%End


    static QString guessFriendlyIdentifierField( const QgsFields &fields, bool *foundFriendly /Out/ = 0 ) /PyName=guessFriendlyIdentifierFieldV2/;
%Docstring
Given a set of fields, attempts to pick the "most useful" field for
user-friendly identification of features.

For instance, if a field called "name" is present, this will be
returned.

Assumes that the user has organized the data with the more "interesting"
field names first. As such, "name" would be selected before "oldname",
"othername", etc.

If no friendly identifier is found, the function will fallback to the
first available.

:param fields: list of fields to pick a friendly identifier from

:return: - field name
         - foundFriendly: set to ``True`` if the returned field name is
           a friendly identifier

.. versionadded:: 3.22
%End


    static QString guessFriendlyIdentifierField( const QgsFields &fields );
%Docstring
Given a set of fields, attempts to pick the "most useful" field for
user-friendly identification of features.

For instance, if a field called "name" is present, this will be
returned.

Assumes that the user has organized the data with the more "interesting"
field names first. As such, "name" would be selected before "oldname",
"othername", etc.

If no friendly identifier is found, the function will fallback to the
first available.

:param fields: list of fields to pick a friendly identifier from

:return: field name

.. versionadded:: 3.18
%End

};


/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/vector/qgsvectorlayerutils.h                                *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/