QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
Abstract base class for QgsPropertyCollection like objects. More...
#include <qgspropertycollection.h>
Public Member Functions | |
QgsAbstractPropertyCollection (const QString &name=QString()) | |
Constructor for QgsAbstractPropertyCollection. | |
virtual | ~QgsAbstractPropertyCollection ()=default |
virtual void | clear ()=0 |
Removes all properties from the collection. | |
virtual bool | hasActiveProperties () const =0 |
Returns true if the collection has any active properties, or false if all properties within the collection are deactivated. | |
virtual bool | hasDynamicProperties () const =0 |
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. | |
virtual bool | hasProperty (int key) const =0 |
Returns true if the collection contains a property with the specified key. | |
virtual bool | isActive (int key) const =0 |
Returns true if the collection contains an active property with the specified key. | |
virtual bool | loadVariant (const QVariant &configuration, const QgsPropertiesDefinition &definitions)=0 |
Loads this property collection from a QVariantMap, wrapped in a QVariant. | |
QString | name () const |
Returns the descriptive name of the property collection. | |
virtual bool | prepare (const QgsExpressionContext &context=QgsExpressionContext()) const =0 |
Prepares the collection against a specified expression context. | |
virtual QgsProperty | property (int key) const =0 |
Returns a matching property from the collection, if one exists. | |
virtual QSet< int > | propertyKeys () const =0 |
Returns a list of property keys contained within the collection. | |
virtual bool | readXml (const QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) |
Reads property collection state from an XML element. | |
virtual QSet< QString > | referencedFields (const QgsExpressionContext &context=QgsExpressionContext(), bool ignoreContext=false) const =0 |
Returns the set of any fields referenced by the active properties from the collection. | |
void | setName (const QString &name) |
Sets the descriptive name for the property collection. | |
virtual QVariant | toVariant (const QgsPropertiesDefinition &definitions) const =0 |
Saves this property collection to a QVariantMap, wrapped in a QVariant. | |
virtual QVariant | value (int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const =0 |
Returns the calculated value of the property with the specified key from within the collection. | |
bool | valueAsBool (int key, const QgsExpressionContext &context, bool defaultValue=false, bool *ok=nullptr) const |
Calculates the current value of the property with the specified key and interprets it as an boolean. | |
QColor | valueAsColor (int key, const QgsExpressionContext &context, const QColor &defaultColor=QColor(), bool *ok=nullptr) const |
Calculates the current value of the property with the specified key and interprets it as a color. | |
QDateTime | valueAsDateTime (int key, const QgsExpressionContext &context, const QDateTime &defaultDateTime=QDateTime(), bool *ok=nullptr) const |
Calculates the current value of the property with the specified key and interprets it as a datetime. | |
double | valueAsDouble (int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const |
Calculates the current value of the property with the specified key and interprets it as a double. | |
int | valueAsInt (int key, const QgsExpressionContext &context, int defaultValue=0, bool *ok=nullptr) const |
Calculates the current value of the property with the specified key and interprets it as an integer. | |
QString | valueAsString (int key, const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const |
Calculates the current value of the property with the specified key and interprets it as a string. | |
virtual bool | writeXml (QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) const |
Writes the current state of the property collection into an XML element. | |
Abstract base class for QgsPropertyCollection like objects.
Definition at line 40 of file qgspropertycollection.h.
QgsAbstractPropertyCollection::QgsAbstractPropertyCollection | ( | const QString & | name = QString() | ) |
Constructor for QgsAbstractPropertyCollection.
The name parameter should be set to a descriptive name for the collection.
Definition at line 24 of file qgspropertycollection.cpp.
|
virtualdefault |
|
pure virtual |
Removes all properties from the collection.
Implemented in QgsPropertyCollection, and QgsPropertyCollectionStack.
|
pure virtual |
Returns true
if the collection has any active properties, or false
if all properties within the collection are deactivated.
Implemented in QgsPropertyCollection, and QgsPropertyCollectionStack.
|
pure virtual |
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.
Implemented in QgsPropertyCollection, and QgsPropertyCollectionStack.
|
pure virtual |
Returns true
if the collection contains a property with the specified key.
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. |
Implemented in QgsPropertyCollection, and QgsPropertyCollectionStack.
|
pure virtual |
Returns true
if the collection contains an active property with the specified key.
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. |
Implemented in QgsPropertyCollection, and QgsPropertyCollectionStack.
|
pure virtual |
Loads this property collection from a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils::readVariant to save it to an XML document.
Implemented in QgsPropertyCollectionStack, and QgsPropertyCollection.
|
inline |
Returns the descriptive name of the property collection.
Definition at line 68 of file qgspropertycollection.h.
|
pure virtual |
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.
Implemented in QgsPropertyCollection, and QgsPropertyCollectionStack.
|
pure virtual |
Returns a matching property from the collection, if one exists.
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. |
Implemented in QgsPropertyCollection, and QgsPropertyCollectionStack.
|
pure virtual |
Returns a list of property keys contained within the collection.
Implemented in QgsPropertyCollection, and QgsPropertyCollectionStack.
|
virtual |
Reads property collection state from an XML element.
collectionElem | source DOM element for property collection's state |
definitions | property definitions |
Definition at line 108 of file qgspropertycollection.cpp.
|
pure virtual |
Returns the set of any fields referenced by the active properties from the collection.
context | expression context the properties will be evaluated against. |
ignoreContext | This parameter has been added in QGIS 3.14. When set to true , even fields not set in context's fields() will be reported - this is useful e.g. with vector tiles where the actual available field names may not be known beforehand. |
Implemented in QgsPropertyCollection, and QgsPropertyCollectionStack.
|
inline |
Sets the descriptive name for the property collection.
Definition at line 74 of file qgspropertycollection.h.
|
pure virtual |
Saves this property collection to a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils::writeVariant to save it to an XML document.
Implemented in QgsPropertyCollection, and QgsPropertyCollectionStack.
|
pure virtual |
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 property() and QgsProperty::value()
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. |
context | expression context to evaluate property against |
defaultValue | default value to return if no matching, active property found or if the property value cannot be calculated |
Implemented in QgsPropertyCollection, and QgsPropertyCollectionStack.
bool QgsAbstractPropertyCollection::valueAsBool | ( | int | key, |
const QgsExpressionContext & | context, | ||
bool | defaultValue = false , |
||
bool * | ok = nullptr |
||
) | const |
Calculates the current value of the property with the specified key and interprets it as an boolean.
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. |
context | QgsExpressionContext to evaluate the property for. |
defaultValue | default boolean to return if the property cannot be calculated as a boolean |
ok | if specified, will be set to true if conversion was successful |
Definition at line 88 of file qgspropertycollection.cpp.
QColor QgsAbstractPropertyCollection::valueAsColor | ( | int | key, |
const QgsExpressionContext & | context, | ||
const QColor & | defaultColor = QColor() , |
||
bool * | ok = nullptr |
||
) | const |
Calculates the current value of the property with the specified key and interprets it as a color.
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. |
context | QgsExpressionContext to evaluate the property for. |
defaultColor | default color to return if the property cannot be calculated as a color |
ok | if specified, will be set to true if conversion was successful |
Definition at line 54 of file qgspropertycollection.cpp.
QDateTime QgsAbstractPropertyCollection::valueAsDateTime | ( | int | key, |
const QgsExpressionContext & | context, | ||
const QDateTime & | defaultDateTime = QDateTime() , |
||
bool * | ok = nullptr |
||
) | const |
Calculates the current value of the property with the specified key and interprets it as a datetime.
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. |
context | QgsExpressionContext to evaluate the property for. |
defaultDateTime | default datetime to return if the property cannot be calculated as a datetime |
ok | if specified, will be set to true if conversion was successful |
Definition at line 30 of file qgspropertycollection.cpp.
double QgsAbstractPropertyCollection::valueAsDouble | ( | int | key, |
const QgsExpressionContext & | context, | ||
double | defaultValue = 0.0 , |
||
bool * | ok = nullptr |
||
) | const |
Calculates the current value of the property with the specified key and interprets it as a double.
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. |
context | QgsExpressionContext to evaluate the property for. |
defaultValue | default double to return if the property cannot be calculated as a double |
ok | if specified, will be set to true if conversion was successful |
Definition at line 66 of file qgspropertycollection.cpp.
int QgsAbstractPropertyCollection::valueAsInt | ( | int | key, |
const QgsExpressionContext & | context, | ||
int | defaultValue = 0 , |
||
bool * | ok = nullptr |
||
) | const |
Calculates the current value of the property with the specified key and interprets it as an integer.
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. |
context | QgsExpressionContext to evaluate the property for. |
defaultValue | default integer to return if the property cannot be calculated as a integer |
ok | if specified, will be set to true if conversion was successful |
Definition at line 77 of file qgspropertycollection.cpp.
QString QgsAbstractPropertyCollection::valueAsString | ( | int | key, |
const QgsExpressionContext & | context, | ||
const QString & | defaultString = QString() , |
||
bool * | ok = nullptr |
||
) | const |
Calculates the current value of the property with the specified key and interprets it as a string.
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. |
context | QgsExpressionContext to evaluate the property for. |
defaultString | default string to return if the property cannot be calculated as a string |
ok | if specified, will be set to true if conversion was successful |
Definition at line 42 of file qgspropertycollection.cpp.
|
virtual |
Writes the current state of the property collection into an XML element.
collectionElem | destination element for the property collection's state |
definitions | property definitions |
Definition at line 99 of file qgspropertycollection.cpp.