QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsProjectPropertyKey Class Reference

Project property key node. More...

#include <qgsprojectproperty.h>

Inheritance diagram for QgsProjectPropertyKey:
Inheritance graph
[legend]

Public Member Functions

 QgsProjectPropertyKey (const QString &name=QString())
 Create a new QgsProjectPropertyKey with the specified identifier.
 
 ~QgsProjectPropertyKey () override
 
QgsProjectPropertyKeyaddKey (const QString &keyName)
 Adds the specified property key as a sub-key.
 
virtual void clear ()
 Resets the property to a default, empty state.
 
virtual void clearKeys ()
 Deletes any sub-nodes from the property.
 
int count () const
 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.
 
QgsProjectPropertyfind (const QString &propertyName) const
 Attempts to find a property with a matching sub-key name.
 
bool isEmpty () const
 Returns true if this property contains no sub-keys.
 
bool isKey () const override
 Returns true if the property is a QgsProjectPropertyKey.
 
bool isLeaf () const override
 Returns true if property is a leaf node.
 
bool isValue () const override
 Returns true if the property is a QgsProjectPropertyValue.
 
QString name () const
 The name of the property is used as identifier.
 
bool readXml (const QDomNode &keyNode) 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.
 
QgsProjectPropertyValuesetValue (const QString &name, const QVariant &value)
 Sets the value associated with this key.
 
QgsProjectPropertyValuesetValue (const QVariant &value)
 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.
 
QVariant value () const override
 If this key has a value, it will be stored by its name in its properties.
 
bool writeXml (const QString &nodeName, QDomElement &element, QDomDocument &document) override
 Writes the property hierarchy to a specified DOM element.
 
- Public Member Functions inherited from QgsProjectProperty
 QgsProjectProperty ()
 
virtual ~QgsProjectProperty ()=default
 

Detailed Description

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.

Definition at line 179 of file qgsprojectproperty.h.

Constructor & Destructor Documentation

◆ QgsProjectPropertyKey()

QgsProjectPropertyKey::QgsProjectPropertyKey ( const QString &  name = QString())

Create a new QgsProjectPropertyKey with the specified identifier.

Definition at line 276 of file qgsprojectproperty.cpp.

◆ ~QgsProjectPropertyKey()

QgsProjectPropertyKey::~QgsProjectPropertyKey ( )
override

Definition at line 280 of file qgsprojectproperty.cpp.

Member Function Documentation

◆ addKey()

QgsProjectPropertyKey * QgsProjectPropertyKey::addKey ( const QString &  keyName)
inline

Adds the specified property key as a sub-key.

Definition at line 213 of file qgsprojectproperty.h.

◆ clear()

virtual void QgsProjectPropertyKey::clear ( )
inlinevirtual

Resets the property to a default, empty state.

Definition at line 293 of file qgsprojectproperty.h.

◆ clearKeys()

virtual void QgsProjectPropertyKey::clearKeys ( )
inlinevirtual

Deletes any sub-nodes from the property.

Definition at line 302 of file qgsprojectproperty.h.

◆ count()

int QgsProjectPropertyKey::count ( ) const
inline

Returns the number of sub-keys contained by this property.

Definition at line 267 of file qgsprojectproperty.h.

◆ dump()

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

Dumps out the keys and values.

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

Implements QgsProjectProperty.

Definition at line 299 of file qgsprojectproperty.cpp.

◆ entryList()

void QgsProjectPropertyKey::entryList ( QStringList &  entries) const

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

See also
subkeyList()

Definition at line 430 of file qgsprojectproperty.cpp.

◆ find()

QgsProjectProperty * QgsProjectPropertyKey::find ( const QString &  propertyName) const
inline

Attempts to find a property with a matching sub-key name.

Definition at line 311 of file qgsprojectproperty.h.

◆ isEmpty()

bool QgsProjectPropertyKey::isEmpty ( ) const
inline

Returns true if this property contains no sub-keys.

Definition at line 272 of file qgsprojectproperty.h.

◆ isKey()

bool QgsProjectPropertyKey::isKey ( ) const
inlineoverridevirtual

Returns true if the property is a QgsProjectPropertyKey.

See also
isValue()
isLeaf()

Implements QgsProjectProperty.

Definition at line 274 of file qgsprojectproperty.h.

◆ isLeaf()

bool QgsProjectPropertyKey::isLeaf ( ) const
overridevirtual

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.

Implements QgsProjectProperty.

Definition at line 459 of file qgsprojectproperty.cpp.

◆ isValue()

bool QgsProjectPropertyKey::isValue ( ) const
inlineoverridevirtual

Returns true if the property is a QgsProjectPropertyValue.

See also
isKey()
isLeaf()

Implements QgsProjectProperty.

Definition at line 275 of file qgsprojectproperty.h.

◆ name()

QString QgsProjectPropertyKey::name ( ) const
inline

The name of the property is used as identifier.

See also
setName()

Definition at line 195 of file qgsprojectproperty.h.

◆ readXml()

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

Restores the property hierarchy from a specified DOM node.

Used for restoring properties from project file

Implements QgsProjectProperty.

Definition at line 358 of file qgsprojectproperty.cpp.

◆ removeKey()

void QgsProjectPropertyKey::removeKey ( const QString &  keyName)
inline

Removes the specified key.

Definition at line 227 of file qgsprojectproperty.h.

◆ setName()

void QgsProjectPropertyKey::setName ( const QString &  name)

The name of the property is used as identifier.

See also
name()

Definition at line 478 of file qgsprojectproperty.cpp.

◆ setValue() [1/2]

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

Sets the value associated with this key.

Parameters
nameis the key name
valueis the value to set
Returns
pointer to property value

Definition at line 238 of file qgsprojectproperty.h.

◆ setValue() [2/2]

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

Set the value associated with this key.

Note
that the single value node associated with each key is always stored keyed by the current key name

Definition at line 255 of file qgsprojectproperty.h.

◆ subkeyList()

void QgsProjectPropertyKey::subkeyList ( QStringList &  entries) const

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

See also
entryList()

Definition at line 444 of file qgsprojectproperty.cpp.

◆ value()

QVariant QgsProjectPropertyKey::value ( ) const
overridevirtual

If this key has a value, it will be stored by its name in its properties.

Implements QgsProjectProperty.

Definition at line 285 of file qgsprojectproperty.cpp.

◆ writeXml()

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

Writes the property hierarchy to a specified DOM element.

Used for saving properties to project file.

Parameters
nodeNamethe tag name associated with this element
elementthe parent (or encompassing) property element
documentthe overall project file Dom document

Implements QgsProjectProperty.

Definition at line 406 of file qgsprojectproperty.cpp.


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