Class: QgsPropertyCollectionStack¶
- class qgis.core.QgsPropertyCollectionStack¶
Bases:
QgsAbstractPropertyCollection
An ordered stack of
QgsPropertyCollection
containers, where collections added later to the stack will take priority over earlier collections.QgsPropertyCollectionStack() Constructor for QgsPropertyCollectionStack.
QgsPropertyCollectionStack(other:
QgsPropertyCollectionStack
) Copy constructorMethods
Appends a collection to the end of the stack, and transfers ownership of the collection to the stack.
Returns the collection at the corresponding index from the stack.
Removes all collections from the stack.
Returns the first collection with a matching name from the stack.
Returns the number of collections contained within the stack.
Returns
True
if the collection has any active properties, orFalse
if all properties within the collection are deactivated.Returns
True
if the collection has any active, non-static properties, orFalse
if either all non-static properties within the collection are deactivated or if the collection only contains static properties.- param key:
Returns
True
if the stack contains an active property with the specified key.- param collection:
- param context:
Returns the highest priority property with a matching key from within the stack.
- rtype:
object
Returns the set of any fields referenced by the active properties from the stack.
- param definitions:
Returns the calculated value of the highest priority property with the specified key from within the stack.
- appendCollection(self, collection: QgsPropertyCollection)¶
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:
collection (QgsPropertyCollection) – collection to append. Ownership is transferred to the stack.
- at(self, index: int) QgsPropertyCollection ¶
Returns the collection at the corresponding index from the stack.
- Parameters:
index (int) – position of collection, 0 based
- Return type:
- Returns:
collection if one exists at the specified index
- clear(self)¶
Removes all collections from the stack.
- collection(self, name: str) QgsPropertyCollection ¶
Returns the first collection with a matching name from the stack.
- Parameters:
name (str) – name of collection to find
- Return type:
- Returns:
collection if one exists with the specified name
- count(self) int ¶
Returns the number of collections contained within the stack.
- Return type:
int
- hasActiveProperties(self) bool ¶
Returns
True
if the collection has any active properties, orFalse
if all properties within the collection are deactivated.See also
See also
- Return type:
bool
- hasDynamicProperties(self) bool ¶
Returns
True
if the collection has any active, non-static properties, orFalse
if either all non-static properties within the collection are deactivated or if the collection only contains static properties.See also
- Return type:
bool
- hasProperty(self, key: int) bool ¶
- Parameters:
key (int) –
- Return type:
bool
- isActive(self, key: int) bool ¶
Returns
True
if the stack contains an active property with the specified key.- Parameters:
key (int) – 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.
See also
- Return type:
bool
- loadVariant(self, collection: Any, definitions: Dict[int, QgsPropertyDefinition]) bool ¶
- Parameters:
collection (Any) –
definitions (Dict[int) –
- Return type:
bool
- prepare(self, context: QgsExpressionContext = QgsExpressionContext()) bool ¶
- Parameters:
context (
QgsExpressionContext
= QgsExpressionContext()) –- Return type:
bool
- property(self, key: int) QgsProperty ¶
Returns the highest priority property with a matching key from within the stack.
- Parameters:
key (int) – 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.
- Return type:
- Returns:
matching property, or null if no matching, active property found.
See also
hasActiveProperty()
- propertyKeys(self) object ¶
- Return type:
object
- referencedFields(self, context: QgsExpressionContext = QgsExpressionContext(), ignoreContext: bool = False) Set[str] ¶
Returns the set of any fields referenced by the active properties from the stack.
- Parameters:
context (
QgsExpressionContext
= QgsExpressionContext()) – expression context the properties will be evaluated against.ignoreContext (bool = False) – This parameter has been added in QGIS 3.14. When set to
True
, even fields not set in context’sfields()
will be reported - this is useful e.g. with vector tiles where the actual available field names may not be known beforehand.
- Return type:
Set[str]
- toVariant(self, definitions: Dict[int, QgsPropertyDefinition]) Any ¶
- Parameters:
definitions (Dict[int) –
- Return type:
Any
- value(self, key: int, context: QgsExpressionContext, defaultValue: Any = None) Any ¶
Returns the calculated value of the highest priority property with the specified key from within the stack.
- Parameters:
key (int) – 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 (QgsExpressionContext) – expression context to evaluate property against
defaultValue (Any = None) – default value to return if no matching, active property found or if the property value cannot be calculated
- Return type:
Any
- Returns:
calculated property value, or default value if property could not be evaluated