22 #ifndef QGSPROJECTPROPERTY_H 23 #define QGSPROJECTPROPERTY_H 27 #include <QStringList> 29 #include "qgis_core.h" 60 virtual void dump(
int tabs = 0 )
const = 0;
67 virtual bool isKey()
const = 0;
74 virtual bool isValue()
const = 0;
84 virtual bool isLeaf()
const = 0;
91 virtual bool readXml(
const QDomNode &keyNode ) = 0;
102 virtual bool writeXml(
const QString &nodeName,
103 QDomElement &element,
104 QDomDocument &document ) = 0;
116 virtual QVariant value()
const = 0;
141 bool isKey()
const override {
return false; }
142 bool isValue()
const override {
return true; }
143 QVariant
value()
const override {
return mValue; }
146 bool isLeaf()
const override {
return true; }
148 void dump(
int tabs = 0 )
const override;
149 bool readXml(
const QDomNode &keyNode )
override;
150 bool writeXml(
const QString &nodeName,
151 QDomElement &element,
152 QDomDocument &document )
override;
196 QString
name()
const {
return mName; }
204 void setName(
const QString &name );
210 QVariant
value()
const override;
217 if ( mProperties.contains( keyName ) )
218 delete mProperties.take( keyName );
221 mProperties.insert( keyName, p );
231 delete mProperties.take( keyName );
242 if ( mProperties.contains( name ) )
243 delete mProperties.take( name );
246 mProperties.insert( name, p );
259 return setValue( name(), value );
262 void dump(
int tabs = 0 )
const override;
263 bool readXml(
const QDomNode &keyNode )
override;
264 bool writeXml(
const QString &nodeName, QDomElement &element, QDomDocument &document )
override;
269 int count()
const {
return mProperties.count(); }
274 bool isEmpty()
const {
return mProperties.isEmpty(); }
276 bool isKey()
const override {
return true; }
277 bool isValue()
const override {
return false; }
278 bool isLeaf()
const override;
284 void entryList( QStringList &entries )
const;
290 void subkeyList( QStringList &entries )
const;
306 qDeleteAll( mProperties );
315 return mProperties.
value( propertyName );
324 QHash < QString, QgsProjectProperty * > mProperties;
bool isKey() const override
Returns true if the property is a QgsProjectPropertyKey.
QVariant value() const override
Returns the node's value.
virtual void clear()
Resets the property to a default, empty state.
virtual QVariant value() const =0
Returns the node's value.
QgsProjectPropertyKey * addKey(const QString &keyName)
Adds the specified property key as a sub-key.
virtual bool isLeaf() const =0
Returns true if property is a leaf node.
void removeKey(const QString &keyName)
Removes the specified key.
Project property value node, contains a QgsProjectPropertyKey's value.
QgsProjectProperty * find(const QString &propertyName) const
Attempts to find a property with a matching sub-key name.
QgsProjectPropertyValue * setValue(const QString &name, const QVariant &value)
Sets the value associated with this key.
bool isKey() const override
Returns true if the property is a QgsProjectPropertyKey.
QString name() const
The name of the property is used as identifier.
QgsProjectPropertyValue * setValue(const QVariant &value)
Set the value associated with this key.
virtual bool writeXml(const QString &nodeName, QDomElement &element, QDomDocument &document)=0
Writes the property hierarchy to a specified DOM element.
int count() const
Returns the number of sub-keys contained by this property.
virtual void clearKeys()
Deletes any sub-nodes from the property.
virtual bool readXml(const QDomNode &keyNode)=0
Restores the property hierarchy from a specified DOM node.
bool isLeaf() const override
Returns true if property is a leaf node.
bool isValue() const override
Returns true if the property is a QgsProjectPropertyValue.
bool isEmpty() const
Returns true if this property contains no sub-keys.
Project property key node.
bool isValue() const override
Returns true if the property is a QgsProjectPropertyValue.
QgsProjectPropertyValue(const QVariant &value)
Constructor for QgsProjectPropertyValue, initialized to a specified value.
An Abstract Base Class for QGIS project property hierarchys.
virtual void dump(int tabs=0) const =0
Dumps out the keys and values.