QGIS API Documentation
3.18.1-Zürich (202f1bf7e5)
|
Abstract base class for QgsPropertyCollection like objects. More...
#include <qgspropertycollection.h>
Public Member Functions | |
QgsAbstractPropertyCollection (const QString &name=QString()) | |
Constructor for QgsAbstractPropertyCollection. More... | |
virtual | ~QgsAbstractPropertyCollection ()=default |
virtual void | clear ()=0 |
Removes all properties from the collection. More... | |
virtual bool | hasActiveProperties () const =0 |
Returns true if the collection has any active properties, or false if all properties within the collection are deactivated. More... | |
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. More... | |
virtual bool | hasProperty (int key) const =0 |
Returns true if the collection contains a property with the specified key. More... | |
virtual bool | isActive (int key) const =0 |
Returns true if the collection contains an active property with the specified key. More... | |
virtual bool | loadVariant (const QVariant &configuration, const QgsPropertiesDefinition &definitions)=0 |
Loads this property collection from a QVariantMap, wrapped in a QVariant. More... | |
QString | name () const |
Returns the descriptive name of the property collection. More... | |
virtual bool | prepare (const QgsExpressionContext &context=QgsExpressionContext()) const =0 |
Prepares the collection against a specified expression context. More... | |
virtual QgsProperty | property (int key) const =0 |
Returns a matching property from the collection, if one exists. More... | |
virtual QSet< int > | propertyKeys () const =0 |
Returns a list of property keys contained within the collection. More... | |
virtual bool | readXml (const QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) |
Reads property collection state from an XML element. More... | |
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. More... | |
void | setName (const QString &name) |
Sets the descriptive name for the property collection. More... | |
virtual QVariant | toVariant (const QgsPropertiesDefinition &definitions) const =0 |
Saves this property collection to a QVariantMap, wrapped in a QVariant. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
virtual bool | writeXml (QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) const |
Writes the current state of the property collection into an XML element. More... | |
Abstract base class for QgsPropertyCollection like objects.
Definition at line 41 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 QgsPropertyCollectionStack, and QgsPropertyCollection.
|
pure virtual |
Returns true
if the collection has any active properties, or false
if all properties within the collection are deactivated.
Implemented in QgsPropertyCollectionStack, and QgsPropertyCollection.
|
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 QgsPropertyCollectionStack, and QgsPropertyCollection.
|
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 QgsPropertyCollectionStack, and QgsPropertyCollection.
|
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 QgsPropertyCollectionStack, and QgsPropertyCollection.
|
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 QgsPropertyCollection, and QgsPropertyCollectionStack.
|
inline |
Returns the descriptive name of the property collection.
Definition at line 69 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 QgsPropertyCollectionStack, and QgsPropertyCollection.
|
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 QgsPropertyCollectionStack, and QgsPropertyCollection.
|
pure virtual |
Returns a list of property keys contained within the collection.
Implemented in QgsPropertyCollectionStack, and QgsPropertyCollection.
|
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 QgsPropertyCollectionStack, and QgsPropertyCollection.
|
inline |
Sets the descriptive name for the property collection.
Definition at line 75 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 QgsPropertyCollectionStack, and QgsPropertyCollection.
|
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 QgsPropertyCollectionStack, and QgsPropertyCollection.
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.