File: qgsfields.sip.in

package info (click to toggle)
qgis 3.40.11%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,183,800 kB
  • sloc: cpp: 1,595,841; python: 372,637; xml: 23,474; sh: 3,761; perl: 3,664; ansic: 2,257; sql: 2,137; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 154
file content (437 lines) | stat: -rw-r--r-- 11,588 bytes parent folder | download | duplicates (6)
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
433
434
435
436
437
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/qgsfields.h                                                 *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/





class QgsFields
{
%Docstring(signature="appended")
Container of fields for a vector layer.

In addition to storing a list of :py:class:`QgsField` instances, it
also:

- allows quick lookups of field names to index in the list
- keeps track of where the field definition comes from (vector data provider, joined layer or newly added from an editing operation)

.. note::

   :py:class:`QgsFields` objects are implicitly shared.
%End

%TypeHeaderCode
#include "qgsfields.h"
%End
  public:
    static const QMetaObject staticMetaObject;

  public:


    QgsFields() /HoldGIL/;
%Docstring
Constructor for an empty field container
%End

    QgsFields( const QgsFields &other ) /HoldGIL/;

    QgsFields( const QList< QgsField > &fields ) /HoldGIL/;
%Docstring
Construct QgsFields from a list of ``fields``.

.. versionadded:: 3.40
%End

    virtual ~QgsFields();

    void clear() /HoldGIL/;
%Docstring
Removes all fields
%End

    bool append( const QgsField &field, Qgis::FieldOrigin origin = Qgis::FieldOrigin::Provider, int originIndex = -1 ) /HoldGIL/;
%Docstring
Appends a ``field``.

The field must have a unique name, otherwise it is rejected (returns
``False``).

The ``originIndex`` argument must be set to a value corresponding to the
``origin`` type:

- :py:class:`Qgis`.FieldOrigin.Provider: The field's originIndex is the
  index in provider's fields.
- :py:class:`Qgis`.FieldOrigin.Join: The field's originIndex / 1000 =
  index of the join, originIndex % 1000 = index within the join
- :py:class:`Qgis`.FieldOrigin.Edit: The originIndex is the index in the
  list of added attributes
%End

    bool append( const QList< QgsField > &fields, Qgis::FieldOrigin origin = Qgis::FieldOrigin::Provider ) /HoldGIL/;
%Docstring
Appends a list of ``fields``.

The fields must have unique names, otherwise it is rejected (returns
``False``).

.. versionadded:: 3.40
%End

    bool append( const QgsFields &fields ) /HoldGIL/;
%Docstring
Appends another set of ``fields`` to these fields.

The fields must have unique names, otherwise it is rejected (returns
``False``).

.. versionadded:: 3.40
%End

    bool rename( int fieldIdx, const QString &name ) /HoldGIL/;
%Docstring
Renames a name of field. The field must have unique name, otherwise
change is rejected (returns ``False``)

.. versionadded:: 3.6
%End

    bool appendExpressionField( const QgsField &field, int originIndex ) /HoldGIL/;
%Docstring
Appends an expression field. The field must have unique name, otherwise
it is rejected (returns ``False``)
%End


    void remove( int fieldIdx ) /HoldGIL/;
%Docstring
Removes the field with the given index.

:raises KeyError: if no field with the specified index exists
%End
%MethodCode
    if ( a0 < 0 || a0 >= sipCpp->count() )
    {
      PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      sipCpp->remove( a0 );
    }
%End

    void extend( const QgsFields &other ) /HoldGIL/;
%Docstring
Extends with fields from another QgsFields container
%End

    bool isEmpty() const /HoldGIL/;
%Docstring
Checks whether the container is empty
%End

    int count() const /HoldGIL/;
%Docstring
Returns number of items
%End

    Py_ssize_t __len__() const /HoldGIL/;
%MethodCode
    sipRes = sipCpp->count();
%End

    //! Ensures that bool(obj) returns ``True`` (otherwise __len__() would be used)
    int __bool__() const /HoldGIL/;
%MethodCode
    sipRes = true;
%End

    int size() const /HoldGIL/;
%Docstring
Returns number of items
%End

    QStringList names() const /HoldGIL/;
%Docstring
Returns a list with field names
%End

    bool exists( int i ) const /HoldGIL/;
%Docstring
Returns if a field index is valid

:param i: Index of the field which needs to be checked

:return: ``True`` if the field exists
%End


    QgsField &operator[]( int i ) /HoldGIL,Factory/;
%MethodCode
    Py_ssize_t idx = sipConvertFromSequenceIndex( a0, sipCpp->count() );
    if ( idx < 0 )
      sipIsErr = 1;
    else
      sipRes = new QgsField( sipCpp->operator[]( idx ) );
%End

    SIP_PYOBJECT __getitem__( const QString &name ) const /HoldGIL,TypeHint="QgsField"/;
%MethodCode
    const int fieldIdx = sipCpp->lookupField( *a0 );
    if ( fieldIdx == -1 )
    {
      PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
      sipIsErr = 1;
    }
    else
    {
      sipRes = sipConvertFromType( new QgsField( sipCpp->at( fieldIdx ) ), sipType_QgsField, Py_None );
    }
%End


    QgsField at( int i ) const /HoldGIL,Factory/;
%Docstring
Returns the field at particular index (must be in range 0..N-1).

:raises KeyError: if no field exists at the specified index
%End
%MethodCode
    if ( a0 < 0 || a0 >= sipCpp->count() )
    {
      PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      sipRes = new QgsField( sipCpp->at( a0 ) );
    }
%End


    QgsField field( int fieldIdx ) const /HoldGIL,Factory/;
%Docstring
Returns the field at particular index (must be in range 0..N-1).

:raises KeyError: if no field exists at the specified index
%End
%MethodCode
    if ( a0 < 0 || a0 >= sipCpp->count() )
    {
      PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      sipRes = new QgsField( sipCpp->field( a0 ) );
    }
%End


    QgsField field( const QString &name ) const /HoldGIL,Factory/;
%Docstring
Returns the field with matching name.

:raises KeyError: if no matching field was found.
%End
%MethodCode
    int fieldIdx = sipCpp->indexFromName( *a0 );
    if ( fieldIdx == -1 )
    {
      PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
      sipIsErr = 1;
    }
    else
    {
      sipRes = new QgsField( sipCpp->field( *a0 ) );
    }
%End


    Qgis::FieldOrigin fieldOrigin( int fieldIdx ) const /HoldGIL/;
%Docstring
Returns the field's origin (value from an enumeration).

:raises KeyError: if no field exists at the specified index
%End
%MethodCode
    if ( a0 < 0 || a0 >= sipCpp->count() )
    {
      PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      sipRes = sipCpp->fieldOrigin( a0 );
    }
%End


    int fieldOriginIndex( int fieldIdx ) const /HoldGIL/;
%Docstring
Returns the field's origin index (its meaning is specific to each type
of origin).

- :py:class:`Qgis`.FieldOrigin.Provider: The field's originIndex is the
  index in provider's fields.
- :py:class:`Qgis`.FieldOrigin.Join: The field's originIndex / 1000 =
  index of the join, originIndex % 1000 = index within the join
- :py:class:`Qgis`.FieldOrigin.Edit: The originIndex is the index in the
  list of added attributes

:raises KeyError: if no field exists at the specified index
%End
%MethodCode
    if ( a0 < 0 || a0 >= sipCpp->count() )
    {
      PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      sipRes = sipCpp->fieldOriginIndex( a0 );
    }
%End

    int indexFromName( const QString &fieldName ) const /HoldGIL/;
%Docstring
Gets the field index from the field name.

This method is case sensitive and only matches the data source name of
the field.

Alias for indexOf

:param fieldName: The name of the field.

:return: The field index if found or -1 in case it cannot be found.

.. seealso:: :py:func:`lookupField` For a more tolerant alternative.
%End

    int indexOf( const QString &fieldName ) const /HoldGIL/;
%Docstring
Gets the field index from the field name.

This method is case sensitive and only matches the data source name of
the field.

:param fieldName: The name of the field.

:return: The field index if found or -1 in case it cannot be found.

.. seealso:: :py:func:`lookupField` For a more tolerant alternative.
%End

     int lookupField( const QString &fieldName ) const /HoldGIL/;
%Docstring
Looks up field's index from the field name. This method matches in the
following order:

1. The exact field name taking case sensitivity into account
2. Looks for the field name by case insensitive comparison
3. The field alias (case insensitive)

:param fieldName: The name to look for.

:return: The field index if found or -1 in case it cannot be found.

.. seealso:: :py:func:`indexFromName` For a more performant and precise but less tolerant alternative.
%End

    QgsAttributeList allAttributesList() const /HoldGIL/;
%Docstring
Utility function to get list of attribute indexes
%End

    QList<QgsField> toList() const /HoldGIL/;
%Docstring
Utility function to return a list of :py:class:`QgsField` instances
%End

    bool operator==( const QgsFields &other ) const /HoldGIL/;
    bool operator!=( const QgsFields &other ) const  /HoldGIL/;


    QIcon iconForField( int fieldIdx, bool considerOrigin = false ) const /Factory/;
%Docstring
Returns an icon corresponding to a field index, based on the field's
type and source

:param fieldIdx: the field index
:param considerOrigin: if ``True`` the icon will the origin of the field

:raises KeyError: if no field exists at the specified index
%End
%MethodCode
    if ( a0 < 0 || a0 >= sipCpp->count() )
    {
      PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      sipRes = new QIcon( sipCpp->iconForField( a0 ) );
    }
%End

    static QIcon iconForFieldType( QMetaType::Type type, QMetaType::Type subType = QMetaType::Type::UnknownType, const QString &typeString = QString() );
%Docstring
Returns an icon corresponding to a field ``type``

Since QGIS 3.24, the optional ``subType`` argument can be used to
specify the type of variant list or map values. Since QGIS 3.30, the
optional ``typeString`` argument can be used to specify field type
strings for handling user field types.

.. versionadded:: 3.16
%End

 static QIcon iconForFieldType( QVariant::Type type, QVariant::Type subType, const QString &typeString = QString() ) /Deprecated/;
%Docstring
Returns an icon corresponding to a field ``type``

Since QGIS 3.24, the optional ``subType`` argument can be used to
specify the type of variant list or map values. Since QGIS 3.30, the
optional ``typeString`` argument can be used to specify field type
strings for handling user field types.

.. versionadded:: 3.16

.. deprecated:: 3.38

   Use the method with a QMetaType.Type argument instead.
%End

    operator QVariant() const;


    void __setitem__( int key, const QgsField &field ) /HoldGIL/;
%MethodCode
    int idx = ( int )sipConvertFromSequenceIndex( a0, sipCpp->count() );
    if ( idx < 0 )
      sipIsErr = 1;
    else
      ( *sipCpp )[idx] = *a1;
%End



};



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