mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
678 lines
21 KiB
Plaintext
678 lines
21 KiB
Plaintext
/************************************************************************
|
|
* 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 an 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 *
|
|
************************************************************************/
|