File: qgspropertycollection.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 (677 lines) | stat: -rw-r--r-- 21,876 bytes parent folder | download | duplicates (12)
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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/qgspropertycollection.h                                     *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/




typedef QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition;


class QgsAbstractPropertyCollection
{
%Docstring(signature="appended")
Abstract base class for :py:class:`QgsPropertyCollection` like objects.
%End

%TypeHeaderCode
#include "qgspropertycollection.h"
%End
%ConvertToSubClassCode
    if ( dynamic_cast<QgsPropertyCollection *>( sipCpp ) )
      sipType = sipType_QgsPropertyCollection;
    else if ( dynamic_cast<QgsPropertyCollectionStack *>( sipCpp ) )
      sipType = sipType_QgsPropertyCollectionStack;
    else
      sipType = sipType_QgsAbstractPropertyCollection;
%End
  public:

    QgsAbstractPropertyCollection( const QString &name = QString() );
%Docstring
Constructor for QgsAbstractPropertyCollection. The name parameter should
be set to a descriptive name for the collection.
%End

    virtual ~QgsAbstractPropertyCollection();

    QString name() const;
%Docstring
Returns the descriptive name of the property collection.

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

    void setName( const QString &name );
%Docstring
Sets the descriptive name for the property collection.

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

    virtual QSet<int> propertyKeys() const = 0;
%Docstring
Returns a list of property keys contained within the collection.
%End

    virtual void clear() = 0;
%Docstring
Removes all properties from the collection.
%End

    virtual bool hasProperty( int key ) const = 0;
%Docstring
Returns ``True`` if the collection contains a property with the
specified key.

:param key: integer key for property. The intended use case is that a
            context specific enum is cast to int and used for the key
            value.

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

    virtual QgsProperty property( int key ) const = 0;
%Docstring
Returns a matching property from the collection, if one exists.

:param key: integer key for property to return. The intended use case is
            that a context specific enum is cast to int and used for the
            key value.

:return: matching property, or null if no matching, active property
         found.

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

    virtual QVariant value( int key, const QgsExpressionContext &context, const QVariant &defaultValue = QVariant() ) const = 0;
%Docstring
Returns the calculated value of the property with the specified key from
within the collection. If you need the validity of the value (like ok
provided from the valueAs* variants) refer to the
:py:func:`~QgsAbstractPropertyCollection.property` and
:py:func:`QgsProperty.value()`

:param key: integer key for property to return. The intended use case is
            that a context specific enum is cast to int and used for the
            key value.
:param context: expression context to evaluate property against
:param defaultValue: default value to return if no matching, active
                     property found or if the property value cannot be
                     calculated

:return: calculated property value, or default value if property could
         not be evaluated

.. seealso:: :py:func:`valueAsString`

.. seealso:: :py:func:`valueAsColor`

.. seealso:: :py:func:`valueAsDouble`

.. seealso:: :py:func:`valueAsInt`

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

    QDateTime valueAsDateTime( int key, const QgsExpressionContext &context, const QDateTime &defaultDateTime = QDateTime(), bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property with the specified key and
interprets it as a datetime.

:param key: integer key for property to return. The intended use case is
            that a context specific enum is cast to int and used for the
            key value.
:param context: :py:class:`QgsExpressionContext` to evaluate the
                property for.
:param defaultDateTime: default datetime to return if the property
                        cannot be calculated as a datetime

:return: - value parsed to datetime
         - ok: ``True`` if conversion was successful

.. seealso:: :py:func:`value`

.. seealso:: :py:func:`valueAsString`

.. seealso:: :py:func:`valueAsColor`

.. seealso:: :py:func:`valueAsDouble`

.. seealso:: :py:func:`valueAsInt`

.. seealso:: :py:func:`valueAsBool`

.. versionadded:: 3.14
%End

    QString valueAsString( int key, const QgsExpressionContext &context, const QString &defaultString = QString(), bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property with the specified key and
interprets it as a string.

:param key: integer key for property to return. The intended use case is
            that a context specific enum is cast to int and used for the
            key value.
:param context: :py:class:`QgsExpressionContext` to evaluate the
                property for.
:param defaultString: default string to return if the property cannot be
                      calculated as a string

:return: - value parsed to string
         - ok: ``True`` if conversion was successful

.. seealso:: :py:func:`value`

.. seealso:: :py:func:`valueAsDateTime`

.. seealso:: :py:func:`valueAsColor`

.. seealso:: :py:func:`valueAsDouble`

.. seealso:: :py:func:`valueAsInt`

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

    QColor valueAsColor( int key, const QgsExpressionContext &context, const QColor &defaultColor = QColor(), bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property with the specified key and
interprets it as a color.

:param key: integer key for property to return. The intended use case is
            that a context specific enum is cast to int and used for the
            key value.
:param context: :py:class:`QgsExpressionContext` to evaluate the
                property for.
:param defaultColor: default color to return if the property cannot be
                     calculated as a color

:return: - value parsed to color
         - ok: ``True`` if conversion was successful

.. seealso:: :py:func:`value`

.. seealso:: :py:func:`valueAsDateTime`

.. seealso:: :py:func:`valueAsString`

.. seealso:: :py:func:`valueAsDouble`

.. seealso:: :py:func:`valueAsInt`

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

    double valueAsDouble( int key, const QgsExpressionContext &context, double defaultValue = 0.0, bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property with the specified key and
interprets it as a double.

:param key: integer key for property to return. The intended use case is
            that a context specific enum is cast to int and used for the
            key value.
:param context: :py:class:`QgsExpressionContext` to evaluate the
                property for.
:param defaultValue: default double to return if the property cannot be
                     calculated as a double

:return: - value parsed to double
         - ok: ``True`` if conversion was successful

.. seealso:: :py:func:`value`

.. seealso:: :py:func:`valueAsDateTime`

.. seealso:: :py:func:`valueAsString`

.. seealso:: :py:func:`valueAsColor`

.. seealso:: :py:func:`valueAsInt`

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

    int valueAsInt( int key, const QgsExpressionContext &context, int defaultValue = 0, bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property with the specified key and
interprets it as an integer.

:param key: integer key for property to return. The intended use case is
            that a context specific enum is cast to int and used for the
            key value.
:param context: :py:class:`QgsExpressionContext` to evaluate the
                property for.
:param defaultValue: default integer to return if the property cannot be
                     calculated as a integer

:return: - value parsed to integer
         - ok: ``True`` if conversion was successful

.. seealso:: :py:func:`value`

.. seealso:: :py:func:`valueAsDateTime`

.. seealso:: :py:func:`valueAsString`

.. seealso:: :py:func:`valueAsColor`

.. seealso:: :py:func:`valueAsDouble`

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

    bool valueAsBool( int key, const QgsExpressionContext &context, bool defaultValue = false, bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property with the specified key and
interprets it as an boolean.

:param key: integer key for property to return. The intended use case is
            that a context specific enum is cast to int and used for the
            key value.
:param context: :py:class:`QgsExpressionContext` to evaluate the
                property for.
:param defaultValue: default boolean to return if the property cannot be
                     calculated as a boolean

:return: - value parsed to bool
         - ok: ``True`` if conversion was successful

.. seealso:: :py:func:`value`

.. seealso:: :py:func:`valueAsDateTime`

.. seealso:: :py:func:`valueAsString`

.. seealso:: :py:func:`valueAsColor`

.. seealso:: :py:func:`valueAsDouble`

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

    virtual bool prepare( const QgsExpressionContext &context = QgsExpressionContext() ) const = 0;
%Docstring
Prepares the collection against a specified expression context. Calling
prepare before evaluating the collection's properties multiple times
allows precalculation of expensive setup tasks such as parsing
expressions. Returns ``True`` if preparation was successful.
%End

    virtual QSet< QString > referencedFields( const QgsExpressionContext &context = QgsExpressionContext(), bool ignoreContext = false ) const = 0;
%Docstring
Returns the set of any fields referenced by the active properties from
the collection.

:param context: expression context the properties will be evaluated
                against.
:param ignoreContext: This parameter has been added in QGIS 3.14. When
                      set to ``True``, even fields not set in context's
                      :py:func:`~QgsAbstractPropertyCollection.fields`
                      will be reported - this is useful e.g. with vector
                      tiles where the actual available field names may
                      not be known beforehand.
%End

    virtual bool isActive( int key ) const = 0;
%Docstring
Returns ``True`` if the collection contains an active property with the
specified key.

:param key: integer key for property to test. The intended use case is
            that a context specific enum is cast to int and used for the
            key value.
%End

    virtual bool hasActiveProperties() const = 0;
%Docstring
Returns ``True`` if the collection has any active properties, or
``False`` if all properties within the collection are deactivated.

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

    virtual bool hasDynamicProperties() const = 0;
%Docstring
Returns ``True`` if the collection has any active, non-static
properties, or ``False`` if either all non-static properties within the
collection are deactivated or if the collection only contains static
properties.

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

    virtual bool writeXml( QDomElement &collectionElem, const QgsPropertiesDefinition &definitions ) const;
%Docstring
Writes the current state of the property collection into an XML element

:param collectionElem: destination element for the property collection's
                       state
:param definitions: property definitions

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

    virtual bool readXml( const QDomElement &collectionElem, const QgsPropertiesDefinition &definitions );
%Docstring
Reads property collection state from an XML element.

:param collectionElem: source DOM element for property collection's
                       state
:param definitions: property definitions

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

    virtual QVariant toVariant( const QgsPropertiesDefinition &definitions ) const = 0;
%Docstring
Saves this property collection to a QVariantMap, wrapped in a QVariant.
You can use :py:class:`QgsXmlUtils`.writeVariant to save it to an XML
document.

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

    virtual bool loadVariant( const QVariant &configuration, const QgsPropertiesDefinition &definitions ) = 0;
%Docstring
Loads this property collection from a QVariantMap, wrapped in a
QVariant. You can use :py:class:`QgsXmlUtils`.readVariant to save it to
an XML document.

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


};


class QgsPropertyCollection : QgsAbstractPropertyCollection
{
%Docstring(signature="appended")
A grouped map of multiple :py:class:`QgsProperty` objects, each
referenced by a integer key value.

Properties within a collection are referenced by an integer key. This is
done to avoid the cost of string creation and comparisons which would be
required by a string key. The intended use case is that a context
specific enum is cast to int and used for the key value. Examples of
such enums are :

.. seealso:: :py:func:`QgsLayoutObject.DataDefinedProperty`

.. seealso:: :py:func:`QgsSymbolLayer.Property`

.. seealso:: :py:func:`QgsPalLabeling.Property`

.. seealso:: :py:func:`QgsAbstract3DSymbol.Property`

.. seealso:: :py:func:`QgsDiagramLayerSettings.Property`

.. seealso:: :py:func:`QgsPalLayerSettings.Property`

.. seealso:: :py:func:`QgsWidgetWrapper.Property`
%End

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

    QgsPropertyCollection( const QString &name = QString() );
%Docstring
Constructor for QgsPropertyCollection

:param name: collection name
%End

    QgsPropertyCollection( const QgsPropertyCollection &other );


    bool operator==( const QgsPropertyCollection &other ) const;
    bool operator!=( const QgsPropertyCollection &other ) const;

    int count() const;
%Docstring
Returns the number of properties contained within the collection.
%End

    QSet<int> propertyKeys() const final;
    void clear() final;
    bool hasProperty( int key ) const final;




    virtual QgsProperty &property( int key );
%Docstring
Returns a reference to a matching property from the collection, if one
exists.

:param key: integer key for property to return. The intended use case is
            that a context specific enum is cast to int and used for the
            key value.

:return: matching property, or null if no matching, active property
         found.

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


    QVariant value( int key, const QgsExpressionContext &context, const QVariant &defaultValue = QVariant() ) const final;


    bool prepare( const QgsExpressionContext &context = QgsExpressionContext() ) const final;
    QSet< QString > referencedFields( const QgsExpressionContext &context = QgsExpressionContext(), bool ignoreContext = false ) const final;
    bool isActive( int key ) const final;


    bool hasActiveProperties() const final;
    bool hasDynamicProperties() const final;

    QVariant toVariant( const QgsPropertiesDefinition &definitions ) const final;
    bool loadVariant( const QVariant &configuration, const QgsPropertiesDefinition &definitions ) final;

    void setProperty( int key, const QgsProperty &property );
%Docstring
Adds a property to the collection and takes ownership of it.

:param key: integer key for property. Any existing property with the
            same key will be removed and replaced by this property. The
            intended use case is that a context specific enum is cast to
            int and used for the key value.
:param property: property to add. Ownership is transferred to the
                 collection. Setting an invalid property will remove the
                 property from the collection.
%End


    void setProperty( int key, const QVariant &value );
%Docstring
Convenience method, creates a :py:class:`QgsStaticProperty` and stores
it within the collection.

:param key: integer key for property. Any existing property with the
            same key will be deleted and replaced by this property. The
            intended use case is that a context specific enum is cast to
            int and used for the key value.
:param value: static value for property
%End


};



class QgsPropertyCollectionStack : QgsAbstractPropertyCollection
{
%Docstring(signature="appended")
An ordered stack of :py:class:`QgsPropertyCollection` containers, where
collections added later to the stack will take priority over earlier
collections.
%End

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

    QgsPropertyCollectionStack();

    ~QgsPropertyCollectionStack();

    QgsPropertyCollectionStack( const QgsPropertyCollectionStack &other );


    int count() const;
%Docstring
Returns the number of collections contained within the stack.
%End

    virtual void clear() ${SIP_FINAL};

%Docstring
Removes all collections from the stack.
%End

    void appendCollection( QgsPropertyCollection *collection /Transfer/ );
%Docstring
Appends a collection to the end of the stack, and transfers ownership of
the collection to the stack. Properties from the newly added collection
will take priority over any existing properties with the same name.

:param collection: collection to append. Ownership is transferred to the
                   stack.
%End

    QgsPropertyCollection *at( int index );
%Docstring
Returns the collection at the corresponding index from the stack.

:param index: position of collection, 0 based

:return: collection if one exists at the specified index
%End


    QgsPropertyCollection *collection( const QString &name );
%Docstring
Returns the first collection with a matching name from the stack.

:param name: name of collection to find

:return: collection if one exists with the specified name
%End

    virtual bool hasActiveProperties() const;

%Docstring
Returns ``True`` if the collection has any active properties, or
``False`` if all properties within the collection are deactivated.

.. seealso:: :py:func:`isActive`

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

    virtual bool hasDynamicProperties() const;

%Docstring
Returns ``True`` if the collection has any active, non-static
properties, or ``False`` if either all non-static properties within the
collection are deactivated or if the collection only contains static
properties.

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

    virtual bool isActive( int key ) const;

%Docstring
Returns ``True`` if the stack contains an active property with the
specified key.

:param key: integer key for property to test. The intended use case is
            that a context specific enum is cast to int and used for the
            key value.

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

    virtual QgsProperty property( int key ) const;

%Docstring
Returns the highest priority property with a matching key from within
the stack.

:param key: integer key for property to return. The intended use case is
            that a context specific enum is cast to int and used for the
            key value.

:return: matching property, or null if no matching, active property
         found.

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

    virtual QVariant value( int key, const QgsExpressionContext &context, const QVariant &defaultValue = QVariant() ) const;

%Docstring
Returns the calculated value of the highest priority property with the
specified key from within the stack.

:param key: integer key for property to calculate. The intended use case
            is that a context specific enum is cast to int and used for
            the key value.
:param context: expression context to evaluate property against
:param defaultValue: default value to return if no matching, active
                     property found or if the property value cannot be
                     calculated

:return: calculated property value, or default value if property could
         not be evaluated
%End

    virtual QSet< QString > referencedFields( const QgsExpressionContext &context = QgsExpressionContext(), bool ignoreContext = false ) const;

%Docstring
Returns the set of any fields referenced by the active properties from
the stack.

:param context: expression context the properties will be evaluated
                against.
:param ignoreContext: This parameter has been added in QGIS 3.14. When
                      set to ``True``, even fields not set in context's
                      :py:func:`~QgsPropertyCollectionStack.fields` will
                      be reported - this is useful e.g. with vector
                      tiles where the actual available field names may
                      not be known beforehand.
%End
    virtual bool prepare( const QgsExpressionContext &context = QgsExpressionContext() ) const;


    virtual QSet<int> propertyKeys() const;

    virtual bool hasProperty( int key ) const;


    virtual QVariant toVariant( const QgsPropertiesDefinition &definitions ) const;


    virtual bool loadVariant( const QVariant &collection, const QgsPropertiesDefinition &definitions );


};

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