21 #include <QDomDocument> 22 #include <QStringList> 39 tabString.
fill(
'\t', tabs );
41 if ( QVariant::StringList == value_.type() )
65 if ( QString::null == typeString )
88 case QVariant::Invalid:
100 case QVariant::String:
101 value_ = subkeyElement.
text();
104 case QVariant::StringList:
112 while ( i < values.
count() )
126 value_ = valueStringList;
134 case QVariant::Pixmap:
138 case QVariant::Brush:
150 case QVariant::Color:
154 case QVariant::Palette:
158 case QVariant::Point:
162 case QVariant::Image:
178 case QVariant::Double:
182 case QVariant::ByteArray:
183 value_ =
QVariant( subkeyElement.
text() ).toByteArray();
186 case QVariant::Polygon:
190 case QVariant::Region:
194 case QVariant::Bitmap:
198 case QVariant::Cursor:
202 case QVariant::BitArray :
203 QgsDebugMsg(
"no support for QVariant::BitArray" );
206 case QVariant::KeySequence :
207 QgsDebugMsg(
"no support for QVariant::KeySequence" );
227 QgsDebugMsg(
QString(
"unsupported value type %1 .. not propertly translated to QVariant" ).arg( typeString ) );
252 if ( QVariant::StringList == value_.type() )
292 if ( !foundQgsProperty )
298 return foundQgsProperty->
value();
306 tabString.
fill(
'\t', tabs );
311 tabString.
fill(
'\t', tabs );
318 if ( i.
next().value()->isValue() )
322 if ( QVariant::StringList == propertyValue->
value().
type() )
325 propertyValue->
dump( tabs + 1 );
338 i.
value()->dump( tabs + 1 );
342 qDebug(
"<%s>",
name().toUtf8().constData() );
343 if ( i.
value()->isValue() )
345 qDebug(
" <%s>", i.
key().toUtf8().constData() );
348 if ( i.
value()->isValue() )
350 qDebug(
" </%s>", i.
key().toUtf8().constData() );
352 qDebug(
"</%s>",
name().toUtf8().constData() );
366 while ( i < subkeys.
count() )
380 if ( !mProperties[subkeys.
item( i ).
nodeName()]->readXML( subkey ) )
391 if ( !mProperties[subkeys.
item( i ).
nodeName()]->readXML( subkey ) )
421 if ( !i.
value()->writeXML( i.
key(), keyElement, document ) )
444 if ( i.
next().value()->isLeaf() )
460 if ( !i.
next().value()->isLeaf() )
474 else if ( 1 ==
count() )
iterator insert(const Key &key, const T &value)
QDomNode item(int index) const
QString & fill(QChar ch, int size)
QgsPropertyKey * addKey(const QString &keyName)
add the given property key
QDomNode appendChild(const QDomNode &newChild)
bool writeXML(const QString &nodeName, QDomElement &element, QDomDocument &document) override
keyElement created by parent QgsPropertyKey
QString attribute(const QString &name, const QString &defValue) const
QString nodeValue() const
virtual ~QgsPropertyKey()
QDomNodeList childNodes() const
void dump(int tabs=0) const override
Dumps out the keys and values.
QDomElement toElement() const
bool writeXML(const QString &nodeName, QDomElement &element, QDomDocument &document) override
Property keys will always create a Dom element for itself and then recursively call writeXML for any ...
int count() const
how many elements are contained within this one?
void append(const T &value)
bool hasAttribute(const QString &name) const
virtual void clearKeys()
delete any sub-nodes
void setAttribute(const QString &name, const QString &value)
Type nameToType(const char *name)
const char * constData() const
virtual QVariant value() const =0
Return the node's value.
bool readXML(QDomNode &keyNode) override
restores property hierarchy to given Dom node
An Abstract Base Class for QGIS project property hierarchies.
bool isLeaf() const override
Returns true if a leaf node A leaf node is a key node that has either no value or a single value...
void subkeyList(QStringList &entries) const
return keys that contain other keys
virtual ~QgsPropertyValue()
QVariant value() const override
Return the node's value.
QDomText createTextNode(const QString &value)
const T value(const Key &key) const
QByteArray toLocal8Bit() const
QDomNode firstChild() const
QgsPropertyKey(const QString &name="")
QString name() const
every key has a name
void entryList(QStringList &entries) const
return keys that do not contain other keys
bool readXML(QDomNode &keyNode) override
restores property hierarchy to given Dom node
bool hasAttributes() const
QDomElement createElement(const QString &tagName)
QVariant value() const override
If this key has a value, it will be stored by its name in its properties.
void dump(int tabs=0) const override
Dumps out the keys and values.