2017-01-02 10:28:31 +10:00
|
|
|
class QgsProjectProperty
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsprojectproperty.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
2017-01-02 10:28:31 +10:00
|
|
|
QgsProjectProperty();
|
|
|
|
virtual ~QgsProjectProperty();
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Dumps out the keys and values
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* @param tabs is number of tabs to print; used for pretty-printing hierarchy
|
|
|
|
*/
|
2013-09-06 22:07:42 +02:00
|
|
|
virtual void dump( int tabs = 0 ) const = 0;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns true if is a QgsPropertyKey */
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual bool isKey() const = 0;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns true if is a QgsPropertyValue */
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual bool isValue() const = 0;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns true if a leaf node
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* A leaf node is a key node that has either no value or a single value.
|
|
|
|
* A non-leaf node would be a key node with key sub-nodes.
|
|
|
|
*
|
|
|
|
* This is used for entryList() and subkeyList() implementation.
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual bool isLeaf() const = 0;
|
|
|
|
|
|
|
|
/**
|
2016-02-14 03:50:23 +01:00
|
|
|
* restores property hierarchy to given Dom node
|
|
|
|
*
|
|
|
|
* Used for restoring properties from project file
|
|
|
|
*/
|
2017-05-01 16:42:33 +02:00
|
|
|
virtual bool readXml( const QDomNode &keyNode ) = 0;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/**
|
2016-02-14 03:50:23 +01:00
|
|
|
* adds property hierarchy to given Dom element
|
|
|
|
*
|
|
|
|
* Used for saving properties to project file.
|
|
|
|
*
|
|
|
|
* @param nodeName the tag name associated with this element
|
|
|
|
* @param element the parent (or encompassing) property element
|
|
|
|
* @param document the overall project file Dom document
|
|
|
|
*/
|
2016-07-19 11:45:47 +10:00
|
|
|
virtual bool writeXml( const QString & nodeName,
|
2012-09-24 02:28:15 +02:00
|
|
|
QDomElement & element,
|
2017-05-01 16:42:33 +02:00
|
|
|
QDomDocument &document ) = 0;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return the node's value
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* For QgsPropertyValue nodes, this is straightforward -- just return the
|
|
|
|
* embedded QVariant, _value. For QgsPropertyKey, this means returning
|
2017-05-01 16:42:33 +02:00
|
|
|
*the QgsPropertyValue _value that is keyed by its name, if it exists;
|
2016-02-14 03:50:23 +01:00
|
|
|
* i.e., QgsPropertyKey "foo" will return the property value mapped to its
|
|
|
|
* name, "foo", in its QHash of QProperties.
|
|
|
|
*
|
2012-09-24 02:28:15 +02:00
|
|
|
*/
|
|
|
|
virtual QVariant value() const = 0;
|
|
|
|
|
|
|
|
}; // class QgsProperty
|
|
|
|
|
|
|
|
|
2017-01-02 10:28:31 +10:00
|
|
|
class QgsProjectPropertyValue : QgsProjectProperty
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsprojectproperty.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
2017-01-02 10:28:31 +10:00
|
|
|
QgsProjectPropertyValue();
|
|
|
|
QgsProjectPropertyValue( const QVariant &value );
|
|
|
|
virtual ~QgsProjectPropertyValue();
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns true if is a QgsPropertyKey */
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual bool isKey() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns true if is a QgsPropertyValue */
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual bool isValue() const;
|
|
|
|
|
|
|
|
QVariant value() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns true if is a leaf node
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* @note I suppose, in a way, value nodes can also be qualified as leaf
|
|
|
|
* nodes even though we're only counting key nodes.
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
bool isLeaf() const;
|
|
|
|
|
2013-09-06 22:07:42 +02:00
|
|
|
void dump( int tabs = 0 ) const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
bool readXml( const QDomNode &keyNode );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-07-19 11:45:47 +10:00
|
|
|
bool writeXml( const QString & nodeName,
|
2012-09-24 02:28:15 +02:00
|
|
|
QDomElement & element,
|
2017-05-01 16:42:33 +02:00
|
|
|
QDomDocument &document );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-01-02 10:28:31 +10:00
|
|
|
class QgsProjectPropertyKey : QgsProjectProperty
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsprojectproperty.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
2017-05-01 16:42:33 +02:00
|
|
|
QgsProjectPropertyKey( const QString &name = QString() );
|
2017-01-02 10:28:31 +10:00
|
|
|
virtual ~QgsProjectPropertyKey();
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-10-21 13:31:42 +02:00
|
|
|
/**
|
|
|
|
* The name of the property is used as identifier.
|
|
|
|
*/
|
|
|
|
QString name() const;
|
2014-01-26 18:35:21 +01:00
|
|
|
|
2016-10-21 13:31:42 +02:00
|
|
|
/**
|
|
|
|
* The name of the property is used as identifier.
|
|
|
|
*/
|
2017-05-01 16:42:33 +02:00
|
|
|
void setName( const QString &name );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** If this key has a value, it will be stored by its name in its
|
2012-09-24 02:28:15 +02:00
|
|
|
* properties
|
|
|
|
*/
|
|
|
|
QVariant value() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// add the given property key
|
2017-05-01 16:42:33 +02:00
|
|
|
QgsProjectPropertyKey *addKey( const QString &keyName );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/// remove the given key
|
2017-05-01 16:42:33 +02:00
|
|
|
void removeKey( const QString &keyName );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Set the value associated with this key
|
2016-02-14 03:50:23 +01:00
|
|
|
* @param name is the key name
|
|
|
|
* @param value is the value to set
|
|
|
|
* @return pointer to property value
|
|
|
|
*/
|
2017-05-01 16:42:33 +02:00
|
|
|
QgsProjectPropertyValue *setValue( const QString &name, const QVariant &value );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Set the value associated with this key
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* @note that the single value node associated with each key is always
|
|
|
|
* stored keyed by the current key name
|
|
|
|
*/
|
2017-05-01 16:42:33 +02:00
|
|
|
QgsProjectPropertyValue *setValue( const QVariant &value );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
|
2013-09-06 22:07:42 +02:00
|
|
|
void dump( int tabs = 0 ) const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
bool readXml( const QDomNode &keyNode );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
bool writeXml( const QString &nodeName, QDomElement &element, QDomDocument &document );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/// how many elements are contained within this one?
|
2013-09-06 22:07:42 +02:00
|
|
|
int count() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/// Does this property not have any subkeys or values?
|
|
|
|
/* virtual */ bool isEmpty() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns true if is a QgsPropertyKey */
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual bool isKey() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns true if is a QgsPropertyValue */
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual bool isValue() const;
|
|
|
|
|
|
|
|
/// return keys that do not contain other keys
|
2017-05-01 16:42:33 +02:00
|
|
|
void entryList( QStringList &entries ) const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/// return keys that contain other keys
|
2017-05-01 16:42:33 +02:00
|
|
|
void subkeyList( QStringList &entries ) const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns true if a leaf node
|
2016-02-14 03:50:23 +01:00
|
|
|
* A leaf node is a key node that has either no value or a single value.
|
|
|
|
* A non-leaf node would be a key node with key sub-nodes.
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
bool isLeaf() const;
|
|
|
|
|
|
|
|
/// reset the QgsProperty key to prestine state
|
|
|
|
virtual void clear();
|
|
|
|
|
|
|
|
/// delete any sub-nodes
|
|
|
|
virtual void clearKeys();
|
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
QgsProjectProperty *find( QString &propertyName );
|
2012-09-24 02:28:15 +02:00
|
|
|
}; // class QgsPropertyKey
|