22#ifndef QGSPROJECTPROPERTY_H
23#define QGSPROJECTPROPERTY_H
28#include <QCoreApplication>
60 virtual void dump(
int tabs = 0 )
const = 0;
91 virtual bool readXml(
const QDomNode &keyNode ) = 0;
103 QDomElement &element,
104 QDomDocument &document ) = 0;
140 bool isKey()
const override {
return false; }
141 bool isValue()
const override {
return true; }
142 QVariant
value()
const override {
return mValue; }
145 bool isLeaf()
const override {
return true; }
147 void dump(
int tabs = 0 )
const override;
148 bool readXml(
const QDomNode &keyNode )
override;
149 bool writeXml(
const QString &nodeName,
150 QDomElement &element,
151 QDomDocument &document )
override;
196 QString
name()
const {
return mName; }
203 void setName(
const QString &name );
209 QVariant value()
const override;
216 if ( mProperties.contains( keyName ) )
217 delete mProperties.take( keyName );
220 mProperties.insert( keyName, p );
230 delete mProperties.take( keyName );
241 if ( mProperties.contains( name ) )
242 delete mProperties.take( name );
245 mProperties.insert( name, p );
258 return setValue( name(), value );
261 void dump(
int tabs = 0 )
const override;
262 bool readXml(
const QDomNode &keyNode )
override;
263 bool writeXml(
const QString &nodeName, QDomElement &element, QDomDocument &document )
override;
268 int count()
const {
return mProperties.count(); }
273 bool isEmpty()
const {
return mProperties.isEmpty(); }
275 bool isKey()
const override {
return true; }
276 bool isValue()
const override {
return false; }
277 bool isLeaf()
const override;
283 void entryList( QStringList &entries )
const;
289 void subkeyList( QStringList &entries )
const;
305 qDeleteAll( mProperties );
314 return mProperties.
value( propertyName );
323 QHash < QString, QgsProjectProperty * > mProperties;
Project property key node.
QString name() const
The name of the property is used as identifier.
QgsProjectProperty * find(const QString &propertyName) const
Attempts to find a property with a matching sub-key name.
void removeKey(const QString &keyName)
Removes the specified key.
bool isEmpty() const
Returns true if this property contains no sub-keys.
bool isKey() const override
Returns true if the property is a QgsProjectPropertyKey.
virtual void clearKeys()
Deletes any sub-nodes from the property.
virtual void clear()
Resets the property to a default, empty state.
QgsProjectPropertyKey * addKey(const QString &keyName)
Adds the specified property key as a sub-key.
bool isValue() const override
Returns true if the property is a QgsProjectPropertyValue.
QgsProjectPropertyValue * setValue(const QString &name, const QVariant &value)
Sets the value associated with this key.
int count() const
Returns the number of sub-keys contained by this property.
QgsProjectPropertyValue * setValue(const QVariant &value)
Set the value associated with this key.
Project property value node, contains a QgsProjectPropertyKey's value.
QgsProjectPropertyValue()=default
Constructor for QgsProjectPropertyValue.
QVariant value() const override
Returns the node's value.
bool isValue() const override
Returns true if the property is a QgsProjectPropertyValue.
QgsProjectPropertyValue(const QVariant &value)
Constructor for QgsProjectPropertyValue, initialized to a specified value.
bool isKey() const override
Returns true if the property is a QgsProjectPropertyKey.
bool isLeaf() const override
Returns true if property is a leaf node.
An Abstract Base Class for QGIS project property hierarchys.
virtual bool isLeaf() const =0
Returns true if property is a leaf node.
virtual void dump(int tabs=0) const =0
Dumps out the keys and values.
virtual bool readXml(const QDomNode &keyNode)=0
Restores the property hierarchy from a specified DOM node.
virtual bool isKey() const =0
Returns true if the property is a QgsProjectPropertyKey.
virtual bool writeXml(const QString &nodeName, QDomElement &element, QDomDocument &document)=0
Writes the property hierarchy to a specified DOM element.
virtual QVariant value() const =0
Returns the node's value.
virtual bool isValue() const =0
Returns true if the property is a QgsProjectPropertyValue.
virtual ~QgsProjectProperty()=default