QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Protected Attributes | List of all members
QgsObjectCustomProperties Class Reference

Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML in. More...

#include <qgsobjectcustomproperties.h>

Public Member Functions

 QgsObjectCustomProperties ()
 
QStringList keys () const
 Return list of stored keys. More...
 
void setValue (const QString &key, const QVariant &value)
 Add an entry to the store. If the entry with the keys exists already, it will be overwritten. More...
 
QVariant value (const QString &key, const QVariant &defaultValue=QVariant()) const
 Return value for the given key. If the key is not stored, default value will be used. More...
 
void remove (const QString &key)
 Remove a key (entry) from the store. More...
 
void readXml (const QDomNode &parentNode, const QString &keyStartsWith=QString())
 Read store contents from XML. More...
 
void writeXml (QDomNode &parentNode, QDomDocument &doc) const
 Write store contents to XML. More...
 

Protected Attributes

QMap< QString, QVariant > mMap
 

Detailed Description

Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML in.

<customproperties> 

element.

Note
added in 2.4

Definition at line 33 of file qgsobjectcustomproperties.h.

Constructor & Destructor Documentation

QgsObjectCustomProperties::QgsObjectCustomProperties ( )

Definition at line 24 of file qgsobjectcustomproperties.cpp.

Member Function Documentation

QStringList QgsObjectCustomProperties::keys ( ) const

Return list of stored keys.

Definition at line 28 of file qgsobjectcustomproperties.cpp.

References mMap.

Referenced by QgsLayerTreeNode::customProperties().

void QgsObjectCustomProperties::readXml ( const QDomNode &  parentNode,
const QString &  keyStartsWith = QString() 
)

Read store contents from XML.

Parameters
parentNodenode to read from
keyStartsWithreads only properties starting with the specified string (or all if the string is empty)

Definition at line 49 of file qgsobjectcustomproperties.cpp.

References mMap, and value().

Referenced by QgsLayerTreeNode::readCommonXML(), and QgsMapLayer::readCustomProperties().

void QgsObjectCustomProperties::remove ( const QString &  key)

Remove a key (entry) from the store.

Definition at line 43 of file qgsobjectcustomproperties.cpp.

References mMap.

Referenced by QgsLayerTreeNode::removeCustomProperty(), and QgsMapLayer::removeCustomProperty().

void QgsObjectCustomProperties::setValue ( const QString &  key,
const QVariant &  value 
)

Add an entry to the store. If the entry with the keys exists already, it will be overwritten.

Definition at line 33 of file qgsobjectcustomproperties.cpp.

References mMap, and value().

Referenced by QgsLayerTreeNode::setCustomProperty(), and QgsMapLayer::setCustomProperty().

QVariant QgsObjectCustomProperties::value ( const QString &  key,
const QVariant &  defaultValue = QVariant() 
) const

Return value for the given key. If the key is not stored, default value will be used.

Definition at line 38 of file qgsobjectcustomproperties.cpp.

References mMap.

Referenced by QgsLayerTreeNode::customProperty(), QgsMapLayer::customProperty(), readXml(), and setValue().

void QgsObjectCustomProperties::writeXml ( QDomNode &  parentNode,
QDomDocument &  doc 
) const

Write store contents to XML.

Definition at line 98 of file qgsobjectcustomproperties.cpp.

References mMap.

Referenced by QgsLayerTreeNode::writeCommonXML(), and QgsMapLayer::writeCustomProperties().

Member Data Documentation

QMap<QString, QVariant> QgsObjectCustomProperties::mMap
protected

Definition at line 62 of file qgsobjectcustomproperties.h.

Referenced by keys(), readXml(), remove(), setValue(), value(), and writeXml().


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