QgsProjectPropertyKey class

Project property key node.

Can, itself, contain QgsProjectPropertyKey and QgsProjectPropertyValues.

The internal QHash, mProperties, maps key names to their respective QgsProjectPropertyValue or next QgsProjectPropertyKey in the key name sequence. The key with the current name should contain its QgsProjectPropertyValue.

E.g., given the key sequence "/foo/bar", "foo" will have a corresponding QgsProjectPropertyKey with a name "foo". It will contain an element in its mProperties that maps to "bar", which is another QgsProjectPropertyKey. The "bar" QgsProjectPropertyKey will, in turn, have an element that maps to itself, i.e. "bar", that will contain a QgsProjectPropertyValue.

Base classes

class QgsProjectProperty
An Abstract Base Class for QGIS project property hierarchys.

Constructors, destructors, conversion operators

QgsProjectPropertyKey(const QString& name = QString())
Create a new QgsProjectPropertyKey with the specified identifier.

Public functions

auto addKey(const QString& keyName) -> QgsProjectPropertyKey*
Adds the specified property key as a sub-key.
void clear() virtual
Resets the property to a default, empty state.
void clearKeys() virtual
Deletes any sub-nodes from the property.
auto count() const -> int
Returns the number of sub-keys contained by this property.
void dump(int tabs = 0) const override
Dumps out the keys and values.
void entryList(QStringList& entries) const
Returns any sub-keys contained by this property that do not contain other keys.
auto find(const QString& propertyName) const -> QgsProjectProperty*
Attempts to find a property with a matching sub-key name.
auto isEmpty() const -> bool
Returns true if this property contains no sub-keys.
auto isKey() const -> bool override
Returns true if the property is a QgsProjectPropertyKey.
auto isLeaf() const -> bool override
Returns true if property is a leaf node.
auto isValue() const -> bool override
Returns true if the property is a QgsProjectPropertyValue.
auto name() const -> QString
The name of the property is used as identifier.
auto readXml(const QDomNode& keyNode) -> bool override
Restores the property hierarchy from a specified DOM node.
void removeKey(const QString& keyName)
Removes the specified key.
void setName(const QString& name)
The name of the property is used as identifier.
auto setValue(const QString& name, const QVariant& value) -> QgsProjectPropertyValue*
Sets the value associated with this key.
auto setValue(const QVariant& value) -> QgsProjectPropertyValue*
Set the value associated with this key.
void subkeyList(QStringList& entries) const
Returns any sub-keys contained by this property which themselves contain other keys.
auto value() const -> QVariant override
If this key has a value, it will be stored by its name in its properties.
auto writeXml(const QString& nodeName, QDomElement& element, QDomDocument& document) -> bool override
Writes the property hierarchy to a specified DOM element.

Function documentation

void QgsProjectPropertyKey::dump(int tabs = 0) const override

Dumps out the keys and values.

Parameters
tabs is number of tabs to print; used for pretty-printing hierarchy

void QgsProjectPropertyKey::entryList(QStringList& entries) const

Returns any sub-keys contained by this property that do not contain other keys.

bool QgsProjectPropertyKey::isKey() const override

Returns true if the property is a QgsProjectPropertyKey.

bool QgsProjectPropertyKey::isLeaf() const override

Returns true if property is a leaf node.

A leaf node is a key node that has either no value or only a single value. A non-leaf node would be a key node with key sub-nodes.

This is used for entryList() and subkeyList() implementation.

bool QgsProjectPropertyKey::isValue() const override

Returns true if the property is a QgsProjectPropertyValue.

QString QgsProjectPropertyKey::name() const

The name of the property is used as identifier.

bool QgsProjectPropertyKey::readXml(const QDomNode& keyNode) override

Restores the property hierarchy from a specified DOM node.

Used for restoring properties from project file

void QgsProjectPropertyKey::setName(const QString& name)

The name of the property is used as identifier.

QgsProjectPropertyValue* QgsProjectPropertyKey::setValue(const QString& name, const QVariant& value)

Sets the value associated with this key.

Parameters
name is the key name
value is the value to set
Returns pointer to property value

QgsProjectPropertyValue* QgsProjectPropertyKey::setValue(const QVariant& value)

Set the value associated with this key.

void QgsProjectPropertyKey::subkeyList(QStringList& entries) const

Returns any sub-keys contained by this property which themselves contain other keys.

bool QgsProjectPropertyKey::writeXml(const QString& nodeName, QDomElement& element, QDomDocument& document) override

Writes the property hierarchy to a specified DOM element.

Parameters
nodeName the tag name associated with this element
element the parent (or encompassing) property element
document the overall project file Dom document

Used for saving properties to project file.