QGIS API Documentation  3.0.2-Girona (307d082)
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()) 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...
 
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 367 of file qgspropertycollection.h.

Constructor & Destructor Documentation

◆ QgsPropertyCollectionStack() [1/2]

QgsPropertyCollectionStack::QgsPropertyCollectionStack ( )
default

Constructor for QgsPropertyCollectionStack.

◆ ~QgsPropertyCollectionStack()

QgsPropertyCollectionStack::~QgsPropertyCollectionStack ( )
override

Definition at line 359 of file qgspropertycollection.cpp.

◆ QgsPropertyCollectionStack() [2/2]

QgsPropertyCollectionStack::QgsPropertyCollectionStack ( const QgsPropertyCollectionStack other)

Copy constructor.

Definition at line 364 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 399 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 404 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 409 of file qgspropertycollection.cpp.

◆ clear()

void QgsPropertyCollectionStack::clear ( )
overridevirtual

Removes all collections from the stack.

Implements QgsAbstractPropertyCollection.

Definition at line 393 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 414 of file qgspropertycollection.cpp.

◆ count()

int QgsPropertyCollectionStack::count ( ) const

Returns the number of collections contained within the stack.

Definition at line 388 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 424 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 434 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 506 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 444 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 534 of file qgspropertycollection.cpp.

◆ operator=()

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

Definition at line 375 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 486 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 449 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 496 of file qgspropertycollection.cpp.

◆ referencedFields()

QSet< QString > QgsPropertyCollectionStack::referencedFields ( const QgsExpressionContext context = QgsExpressionContext()) 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.

Implements QgsAbstractPropertyCollection.

Definition at line 476 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 516 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 466 of file qgspropertycollection.cpp.


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