QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 375 of file qgspropertycollection.h.

Constructor & Destructor Documentation

QgsPropertyCollectionStack::QgsPropertyCollectionStack ( )
default

Constructor for QgsPropertyCollectionStack.

QgsPropertyCollectionStack::~QgsPropertyCollectionStack ( )
override

Definition at line 365 of file qgspropertycollection.cpp.

QgsPropertyCollectionStack::QgsPropertyCollectionStack ( const QgsPropertyCollectionStack other)

Copy constructor.

Definition at line 370 of file qgspropertycollection.cpp.

Member Function Documentation

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 405 of file qgspropertycollection.cpp.

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 410 of file qgspropertycollection.cpp.

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 415 of file qgspropertycollection.cpp.

void QgsPropertyCollectionStack::clear ( )
overridevirtual

Removes all collections from the stack.

Implements QgsAbstractPropertyCollection.

Definition at line 399 of file qgspropertycollection.cpp.

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 420 of file qgspropertycollection.cpp.

int QgsPropertyCollectionStack::count ( ) const

Returns the number of collections contained within the stack.

Definition at line 394 of file qgspropertycollection.cpp.

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 430 of file qgspropertycollection.cpp.

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 440 of file qgspropertycollection.cpp.

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 512 of file qgspropertycollection.cpp.

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 450 of file qgspropertycollection.cpp.

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 540 of file qgspropertycollection.cpp.

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

Definition at line 381 of file qgspropertycollection.cpp.

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 492 of file qgspropertycollection.cpp.

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 455 of file qgspropertycollection.cpp.

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

Returns a list of property keys contained within the collection.

Implements QgsAbstractPropertyCollection.

Definition at line 502 of file qgspropertycollection.cpp.

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 482 of file qgspropertycollection.cpp.

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 522 of file qgspropertycollection.cpp.

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 472 of file qgspropertycollection.cpp.


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