QGIS API Documentation 3.41.0-Master (af5edcb665c)
|
An ordered stack of QgsPropertyCollection containers, where collections added later to the stack will take priority over earlier collections. More...
#include <qgspropertycollection.h>
Public Member Functions | |
QgsPropertyCollectionStack ()=default | |
QgsPropertyCollectionStack (const QgsPropertyCollectionStack &other) | |
~QgsPropertyCollectionStack () override | |
void | appendCollection (QgsPropertyCollection *collection) |
Appends a collection to the end of the stack, and transfers ownership of the collection to the stack. | |
QgsPropertyCollection * | at (int index) |
Returns the collection at the corresponding index from the stack. | |
const QgsPropertyCollection * | at (int index) const |
Returns the collection at the corresponding index from the stack. | |
void | clear () FINAL |
Removes all collections from the stack. | |
QgsPropertyCollection * | collection (const QString &name) |
Returns the first collection with a matching name from the stack. | |
int | count () const |
Returns the number of collections contained within the stack. | |
bool | hasActiveProperties () const override |
Returns true if the collection has any active properties, or false if all properties within the collection are deactivated. | |
bool | hasDynamicProperties () const override |
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. | |
bool | hasProperty (int key) const override |
Returns true if the collection contains a property with the specified key. | |
bool | isActive (int key) const override |
Returns true if the stack contains an active property with the specified key. | |
bool | loadVariant (const QVariant &collection, const QgsPropertiesDefinition &definitions) override |
Loads this property collection from a QVariantMap, wrapped in a QVariant. | |
QgsPropertyCollectionStack & | operator= (const QgsPropertyCollectionStack &other) |
bool | prepare (const QgsExpressionContext &context=QgsExpressionContext()) const override |
Prepares the collection against a specified expression context. | |
QgsProperty | property (int key) const override |
Returns the highest priority property with a matching key from within the stack. | |
QSet< int > | propertyKeys () const override |
Returns a list of property keys contained within the collection. | |
QSet< QString > | referencedFields (const QgsExpressionContext &context=QgsExpressionContext(), bool ignoreContext=false) const override |
Returns the set of any fields referenced by the active properties from the stack. | |
QVariant | toVariant (const QgsPropertiesDefinition &definitions) const override |
Saves this property collection to a QVariantMap, wrapped in a QVariant. | |
QVariant | value (int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const override |
Returns the calculated value of the highest priority property with the specified key from within the stack. | |
Public Member Functions inherited from QgsAbstractPropertyCollection | |
QgsAbstractPropertyCollection (const QString &name=QString()) | |
Constructor for QgsAbstractPropertyCollection. | |
virtual | ~QgsAbstractPropertyCollection ()=default |
QString | name () const |
Returns the descriptive name of the property collection. | |
virtual bool | readXml (const QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) |
Reads property collection state from an XML element. | |
void | setName (const QString &name) |
Sets the descriptive name for the property 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. | |
An ordered stack of QgsPropertyCollection containers, where collections added later to the stack will take priority over earlier collections.
Definition at line 485 of file qgspropertycollection.h.
|
default |
|
override |
Definition at line 387 of file qgspropertycollection.cpp.
QgsPropertyCollectionStack::QgsPropertyCollectionStack | ( | const QgsPropertyCollectionStack & | other | ) |
Definition at line 392 of file qgspropertycollection.cpp.
void QgsPropertyCollectionStack::appendCollection | ( | QgsPropertyCollection * | collection | ) |
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.
collection | collection to append. Ownership is transferred to the stack. |
Definition at line 427 of file qgspropertycollection.cpp.
QgsPropertyCollection * QgsPropertyCollectionStack::at | ( | int | index | ) |
Returns the collection at the corresponding index from the stack.
index | position of collection, 0 based |
Definition at line 432 of file qgspropertycollection.cpp.
const QgsPropertyCollection * QgsPropertyCollectionStack::at | ( | int | index | ) | const |
Returns the collection at the corresponding index from the stack.
index | position of collection, 0 based |
Definition at line 437 of file qgspropertycollection.cpp.
|
virtual |
Removes all collections from the stack.
Implements QgsAbstractPropertyCollection.
Definition at line 421 of file qgspropertycollection.cpp.
QgsPropertyCollection * QgsPropertyCollectionStack::collection | ( | const QString & | name | ) |
Returns the first collection with a matching name from the stack.
name | name of collection to find |
Definition at line 442 of file qgspropertycollection.cpp.
int QgsPropertyCollectionStack::count | ( | ) | const |
Returns the number of collections contained within the stack.
Definition at line 416 of file qgspropertycollection.cpp.
|
overridevirtual |
Returns true
if the collection has any active properties, or false
if all properties within the collection are deactivated.
Implements QgsAbstractPropertyCollection.
Definition at line 453 of file qgspropertycollection.cpp.
|
overridevirtual |
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.
Implements QgsAbstractPropertyCollection.
Definition at line 464 of file qgspropertycollection.cpp.
|
overridevirtual |
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. |
Implements QgsAbstractPropertyCollection.
Definition at line 540 of file qgspropertycollection.cpp.
|
overridevirtual |
Returns true
if the stack 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. |
Implements QgsAbstractPropertyCollection.
Definition at line 475 of file qgspropertycollection.cpp.
|
overridevirtual |
Loads this property collection from a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils::readVariant to save it to an XML document.
Implements QgsAbstractPropertyCollection.
Definition at line 570 of file qgspropertycollection.cpp.
QgsPropertyCollectionStack & QgsPropertyCollectionStack::operator= | ( | const QgsPropertyCollectionStack & | other | ) |
Definition at line 403 of file qgspropertycollection.cpp.
|
overridevirtual |
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.
Implements QgsAbstractPropertyCollection.
Definition at line 518 of file qgspropertycollection.cpp.
|
overridevirtual |
Returns the highest priority property with a matching key from within the stack.
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. |
Implements QgsAbstractPropertyCollection.
Definition at line 480 of file qgspropertycollection.cpp.
|
overridevirtual |
Returns a list of property keys contained within the collection.
Implements QgsAbstractPropertyCollection.
Definition at line 529 of file qgspropertycollection.cpp.
|
overridevirtual |
Returns the set of any fields referenced by the active properties from the stack.
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. |
Implements QgsAbstractPropertyCollection.
Definition at line 507 of file qgspropertycollection.cpp.
|
overridevirtual |
Saves this property collection to a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils::writeVariant to save it to an XML document.
Implements QgsAbstractPropertyCollection.
Definition at line 551 of file qgspropertycollection.cpp.
|
overridevirtual |
Returns the calculated value of the highest priority property with the specified key from within the stack.
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. |
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 |
Implements QgsAbstractPropertyCollection.
Definition at line 497 of file qgspropertycollection.cpp.