QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
Public Member Functions | List of all members
QgsPropertyCollectionStack Class Reference

An ordered stack of QgsPropertyCollection containers, where collections added later to the stack will take priority over earlier collections. More...

#include <qgspropertycollection.h>

Inheritance diagram for QgsPropertyCollectionStack:
Inheritance graph
[legend]

Public Member Functions

 QgsPropertyCollectionStack ()=default
 Constructor for QgsPropertyCollectionStack. More...
 
 QgsPropertyCollectionStack (const QgsPropertyCollectionStack &other)
 Copy constructor. More...
 
 ~QgsPropertyCollectionStack () override
 
void appendCollection (QgsPropertyCollection *collection)
 Appends a collection to the end of the stack, and transfers ownership of the collection to the stack. More...
 
QgsPropertyCollectionat (int index)
 Returns the collection at the corresponding index from the stack. More...
 
const QgsPropertyCollectionat (int index) const
 Returns the collection at the corresponding index from the stack. More...
 
void clear () override
 Removes all collections from the stack. More...
 
QgsPropertyCollectioncollection (const QString &name)
 Returns the first collection with a matching name from the stack. More...
 
int count () const
 Returns the number of collections contained within the stack. More...
 
bool hasActiveProperties () const override
 Returns true if the collection has any active properties, or false if all properties within the collection are deactivated. More...
 
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. More...
 
bool hasProperty (int key) const override
 Returns true if the collection contains a property with the specified key. More...
 
bool isActive (int key) const override
 Returns true if the stack contains an active property with the specified key. More...
 
bool loadVariant (const QVariant &collection, const QgsPropertiesDefinition &definitions) override
 Loads this property collection from a QVariantMap, wrapped in a QVariant. More...
 
QgsPropertyCollectionStackoperator= (const QgsPropertyCollectionStack &other)
 
bool prepare (const QgsExpressionContext &context=QgsExpressionContext()) const override
 Prepares the collection against a specified expression context. More...
 
QgsProperty property (int key) const override
 Returns the highest priority property with a matching key from within the stack. More...
 
QSet< int > propertyKeys () const override
 Returns a list of property keys contained within the collection. More...
 
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. More...
 
QVariant toVariant (const QgsPropertiesDefinition &definitions) const override
 Saves this property collection to a QVariantMap, wrapped in a QVariant. More...
 
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. More...
 
- Public Member Functions inherited from QgsAbstractPropertyCollection
 QgsAbstractPropertyCollection (const QString &name=QString())
 Constructor for QgsAbstractPropertyCollection. More...
 
virtual ~QgsAbstractPropertyCollection ()=default
 
QString name () const
 Returns the descriptive name of the property collection. More...
 
virtual bool readXml (const QDomElement &collectionElem, const QgsPropertiesDefinition &definitions)
 Reads property collection state from an XML element. More...
 
void setName (const QString &name)
 Sets the descriptive name for the property 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...
 

Detailed Description

An ordered stack of QgsPropertyCollection containers, where collections added later to the stack will take priority over earlier collections.

Since
QGIS 3.0

Definition at line 408 of file qgspropertycollection.h.

Constructor & Destructor Documentation

◆ QgsPropertyCollectionStack() [1/2]

QgsPropertyCollectionStack::QgsPropertyCollectionStack ( )
default

Constructor for QgsPropertyCollectionStack.

◆ ~QgsPropertyCollectionStack()

QgsPropertyCollectionStack::~QgsPropertyCollectionStack ( )
override

Definition at line 387 of file qgspropertycollection.cpp.

◆ QgsPropertyCollectionStack() [2/2]

QgsPropertyCollectionStack::QgsPropertyCollectionStack ( const QgsPropertyCollectionStack other)

Copy constructor.

Definition at line 392 of file qgspropertycollection.cpp.

Member Function Documentation

◆ appendCollection()

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.

Parameters
collectioncollection to append. Ownership is transferred to the stack.

Definition at line 427 of file qgspropertycollection.cpp.

◆ at() [1/2]

QgsPropertyCollection * QgsPropertyCollectionStack::at ( int  index)

Returns the collection at the corresponding index from the stack.

Parameters
indexposition of collection, 0 based
Returns
collection if one exists at the specified index

Definition at line 432 of file qgspropertycollection.cpp.

◆ at() [2/2]

const QgsPropertyCollection * QgsPropertyCollectionStack::at ( int  index) const

Returns the collection at the corresponding index from the stack.

Parameters
indexposition of collection, 0 based
Returns
collection if one exists at the specified index
Note
not available in Python bindings

Definition at line 437 of file qgspropertycollection.cpp.

◆ clear()

void QgsPropertyCollectionStack::clear ( )
overridevirtual

Removes all collections from the stack.

Implements QgsAbstractPropertyCollection.

Definition at line 421 of file qgspropertycollection.cpp.

◆ collection()

QgsPropertyCollection * QgsPropertyCollectionStack::collection ( const QString &  name)

Returns the first collection with a matching name from the stack.

Parameters
namename of collection to find
Returns
collection if one exists with the specified name

Definition at line 442 of file qgspropertycollection.cpp.

◆ count()

int QgsPropertyCollectionStack::count ( ) const

Returns the number of collections contained within the stack.

Definition at line 416 of file qgspropertycollection.cpp.

◆ hasActiveProperties()

bool QgsPropertyCollectionStack::hasActiveProperties ( ) const
overridevirtual

Returns true if the collection has any active properties, or false if all properties within the collection are deactivated.

See also
isActive()
hasDynamicProperties()

Implements QgsAbstractPropertyCollection.

Definition at line 453 of file qgspropertycollection.cpp.

◆ hasDynamicProperties()

bool QgsPropertyCollectionStack::hasDynamicProperties ( ) const
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.

See also
hasActiveProperties()

Implements QgsAbstractPropertyCollection.

Definition at line 464 of file qgspropertycollection.cpp.

◆ hasProperty()

bool QgsPropertyCollectionStack::hasProperty ( int  key) const
overridevirtual

Returns true if the collection contains a property with the specified key.

Parameters
keyinteger key for property. The intended use case is that a context specific enum is cast to int and used for the key value.
See also
property()

Implements QgsAbstractPropertyCollection.

Definition at line 540 of file qgspropertycollection.cpp.

◆ isActive()

bool QgsPropertyCollectionStack::isActive ( int  key) const
overridevirtual

Returns true if the stack contains an active property with the specified key.

Parameters
keyinteger 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.
See also
hasActiveProperties()

Implements QgsAbstractPropertyCollection.

Definition at line 475 of file qgspropertycollection.cpp.

◆ loadVariant()

bool QgsPropertyCollectionStack::loadVariant ( const QVariant &  configuration,
const QgsPropertiesDefinition definitions 
)
overridevirtual

Loads this property collection from a QVariantMap, wrapped in a QVariant.

You can use QgsXmlUtils::readVariant to save it to an XML document.

See also
toVariant()

Implements QgsAbstractPropertyCollection.

Definition at line 570 of file qgspropertycollection.cpp.

◆ operator=()

QgsPropertyCollectionStack & QgsPropertyCollectionStack::operator= ( const QgsPropertyCollectionStack other)

Definition at line 403 of file qgspropertycollection.cpp.

◆ prepare()

bool QgsPropertyCollectionStack::prepare ( const QgsExpressionContext context = QgsExpressionContext()) const
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.

◆ property()

QgsProperty QgsPropertyCollectionStack::property ( int  key) const
overridevirtual

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

Parameters
keyinteger 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.
Returns
matching property, or null if no matching, active property found.
See also
hasActiveProperty()

Implements QgsAbstractPropertyCollection.

Definition at line 480 of file qgspropertycollection.cpp.

◆ propertyKeys()

QSet< int > QgsPropertyCollectionStack::propertyKeys ( ) const
overridevirtual

Returns a list of property keys contained within the collection.

Implements QgsAbstractPropertyCollection.

Definition at line 529 of file qgspropertycollection.cpp.

◆ referencedFields()

QSet< QString > QgsPropertyCollectionStack::referencedFields ( const QgsExpressionContext context = QgsExpressionContext(),
bool  ignoreContext = false 
) const
overridevirtual

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

Parameters
contextexpression context the properties will be evaluated against.
ignoreContextThis 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.

◆ toVariant()

QVariant QgsPropertyCollectionStack::toVariant ( const QgsPropertiesDefinition definitions) const
overridevirtual

Saves this property collection to a QVariantMap, wrapped in a QVariant.

You can use QgsXmlUtils::writeVariant to save it to an XML document.

See also
loadVariant()

Implements QgsAbstractPropertyCollection.

Definition at line 551 of file qgspropertycollection.cpp.

◆ value()

QVariant QgsPropertyCollectionStack::value ( int  key,
const QgsExpressionContext context,
const QVariant &  defaultValue = QVariant() 
) const
overridevirtual

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

Parameters
keyinteger 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.
contextexpression context to evaluate property against
defaultValuedefault value to return if no matching, active property found or if the property value cannot be calculated
Returns
calculated property value, or default value if property could not be evaluated

Implements QgsAbstractPropertyCollection.

Definition at line 497 of file qgspropertycollection.cpp.


The documentation for this class was generated from the following files: