15#ifndef QGSPROPERTYCOLLECTION_H
16#define QGSPROPERTYCOLLECTION_H
46 sipType = sipType_QgsPropertyCollection;
48 sipType = sipType_QgsPropertyCollectionStack;
50 sipType = sipType_QgsAbstractPropertyCollection;
68 QString
name()
const {
return mName; }
74 void setName(
const QString &name ) { mName = name; }
137 QDateTime valueAsDateTime(
int key,
const QgsExpressionContext &context,
const QDateTime &defaultDateTime = QDateTime(),
bool *ok
SIP_OUT =
nullptr )
const;
154 QString valueAsString(
int key,
const QgsExpressionContext &context,
const QString &defaultString = QString(),
bool *ok
SIP_OUT =
nullptr )
const;
171 QColor valueAsColor(
int key,
const QgsExpressionContext &context,
const QColor &defaultColor = QColor(),
bool *ok
SIP_OUT =
nullptr )
const;
294 template<
class T> QDateTime valueAsDateTime(
const T &key,
const QgsExpressionContext &context,
const QDateTime &defaultDateTime = QDateTime(),
bool *ok =
nullptr ) const
SIP_SKIP
296 return valueAsDateTime(
static_cast< int >( key ), context, defaultDateTime, ok );
298 template<
class T> QString valueAsString(
const T &key,
const QgsExpressionContext &context,
const QString &defaultString = QString(),
bool *ok =
nullptr ) const
SIP_SKIP
300 return valueAsString(
static_cast< int >( key ), context, defaultString, ok );
302 template<
class T> QColor valueAsColor(
const T &key,
const QgsExpressionContext &context,
const QColor &defaultColor = QColor(),
bool *ok =
nullptr ) const
SIP_SKIP
304 return valueAsColor(
static_cast< int >( key ), context, defaultColor, ok );
306 template<
class T>
double valueAsDouble(
const T &key,
const QgsExpressionContext &context,
double defaultValue = 0.0,
bool *ok =
nullptr ) const
SIP_SKIP
308 return valueAsDouble(
static_cast< int >( key ), context, defaultValue, ok );
310 template<
class T>
int valueAsInt(
const T &key,
const QgsExpressionContext &context,
int defaultValue = 0,
bool *ok =
nullptr ) const
SIP_SKIP
312 return valueAsInt(
static_cast< int >( key ), context, defaultValue, ok );
314 template<
class T>
bool valueAsBool(
const T &key,
const QgsExpressionContext &context,
bool defaultValue =
false,
bool *ok =
nullptr ) const
SIP_SKIP
316 return valueAsBool(
static_cast< int >( key ), context, defaultValue, ok );
368 QSet<int> propertyKeys()
const final;
370 bool hasProperty(
int key )
const final;
397 template<
class T>
QgsProperty &property( T key )
SIP_SKIP {
return property(
static_cast< int >( key ) ); }
400 QVariant value(
int key,
const QgsExpressionContext &context,
const QVariant &defaultValue = QVariant() ) const final;
406 template< class T> QVariant value( T key, const
QgsExpressionContext &context, const QVariant &defaultValue = QVariant() ) const
SIP_SKIP {
return value(
static_cast< int >( key ), context, defaultValue ); }
410 bool isActive(
int key ) const final;
417 template< class T>
bool isActive( T key ) const
SIP_SKIP {
return isActive(
static_cast< int >( key ) ); }
419 bool hasActiveProperties() const final;
420 bool hasDynamicProperties() const final;
433 void setProperty(
int key, const
QgsProperty &property );
454 void setProperty(
int key,
const QVariant &value );
469 QHash<int, QgsProperty> mProperties;
471 mutable bool mDirty =
false;
472 mutable bool mHasActiveProperties =
false;
473 mutable bool mHasDynamicProperties =
false;
474 mutable int mCount = 0;
549 bool hasActiveProperties() const override;
556 bool hasDynamicProperties() const override;
564 bool isActive(
int key ) const override;
584 QVariant value(
int key, const
QgsExpressionContext &context, const QVariant &defaultValue = QVariant() ) const override;
596 QSet<
int> propertyKeys() const override;
597 bool hasProperty(
int key ) const override;
Abstract base class for QgsPropertyCollection like objects.
virtual QVariant value(int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const =0
Returns the calculated value of the property with the specified key from within the collection.
void setName(const QString &name)
Sets the descriptive name for the property collection.
virtual bool hasProperty(int key) const =0
Returns true if the collection contains a property with the specified key.
virtual bool isActive(int key) const =0
Returns true if the collection contains an active property with the specified key.
virtual QgsProperty property(int key) const =0
Returns a matching property from the collection, if one exists.
virtual QSet< int > propertyKeys() const =0
Returns a list of property keys contained within the collection.
virtual QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext(), bool ignoreContext=false) const =0
Returns the set of any fields referenced by the active properties from the collection.
virtual void clear()=0
Removes all properties from the collection.
virtual bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const =0
Prepares the collection against a specified expression context.
virtual bool loadVariant(const QVariant &configuration, const QgsPropertiesDefinition &definitions)=0
Loads this property collection from a QVariantMap, wrapped in a QVariant.
virtual bool hasActiveProperties() const =0
Returns true if the collection has any active properties, or false if all properties within the colle...
QString name() const
Returns the descriptive name of the property collection.
virtual bool hasDynamicProperties() const =0
Returns true if the collection has any active, non-static properties, or false if either all non-stat...
virtual ~QgsAbstractPropertyCollection()=default
virtual QVariant toVariant(const QgsPropertiesDefinition &definitions) const =0
Saves this property collection to a QVariantMap, wrapped in a QVariant.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
An ordered stack of QgsPropertyCollection containers, where collections added later to the stack will...
QgsPropertyCollectionStack()=default
Constructor for QgsPropertyCollectionStack.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
bool hasProperty(T key) const
Returns true if the collection contains a property with the specified key.
void setProperty(T key, const QVariant &value)
Convenience method, creates a QgsStaticProperty and stores it within the collection.
QVariant value(T key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const
Returns the value of the property with the specified key.
bool isActive(T key) const
Returns true if the property with the specified key is active.
QgsProperty property(T key) const
Returns the property with the specified key.
void setProperty(T key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
A store for object properties.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.