21 #include <QDomDocument> 22 #include <QStringList> 27 tabString.
fill(
'\t', tabs );
29 if ( QVariant::StringList == value_.
type() )
53 if ( QString::null == typeString )
76 case QVariant::Invalid:
88 case QVariant::String:
89 value_ = subkeyElement.
text();
92 case QVariant::StringList:
100 while ( i < values.
count() )
114 value_ = valueStringList;
122 case QVariant::Pixmap:
126 case QVariant::Brush:
138 case QVariant::Color:
142 case QVariant::Palette:
146 case QVariant::Point:
150 case QVariant::Image:
166 case QVariant::Double:
170 case QVariant::ByteArray:
171 value_ =
QVariant( subkeyElement.
text() ).toByteArray();
174 case QVariant::Polygon:
178 case QVariant::Region:
182 case QVariant::Bitmap:
186 case QVariant::Cursor:
190 case QVariant::BitArray :
191 QgsDebugMsg(
"no support for QVariant::BitArray" );
194 case QVariant::KeySequence :
195 QgsDebugMsg(
"no support for QVariant::KeySequence" );
215 QgsDebugMsg(
QString(
"unsupported value type %1 .. not propertly translated to QVariant" ).arg( typeString ) );
240 if ( QVariant::StringList == value_.
type() )
280 if ( !foundQgsProperty )
286 return foundQgsProperty->
value();
294 tabString.
fill(
'\t', tabs );
299 tabString.
fill(
'\t', tabs );
306 if ( i.
next().value()->isValue() )
310 if ( QVariant::StringList == propertyValue->
value().
type() )
313 propertyValue->
dump( tabs + 1 );
326 i.
value()->dump( tabs + 1 );
330 qDebug(
"<%s>",
name().toUtf8().constData() );
331 if ( i.
value()->isValue() )
333 qDebug(
" <%s>", i.
key().toUtf8().constData() );
336 if ( i.
value()->isValue() )
338 qDebug(
" </%s>", i.
key().toUtf8().constData() );
340 qDebug(
"</%s>",
name().toUtf8().constData() );
354 while ( i < subkeys.
count() )
368 if ( !mProperties[subkeys.
item( i ).
nodeName()]->readXML( subkey ) )
380 if ( !mProperties[subkeys.
item( i ).
nodeName()]->readXML( subkey ) )
410 if ( !i.
value()->writeXML( i.
key(), keyElement, document ) )
433 if ( i.
next().value()->isLeaf() )
449 if ( !i.
next().value()->isLeaf() )
463 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
void entryList(QStringList &entries) const
return keys that do not contain other keys
QString attribute(const QString &name, const QString &defValue) const
QString nodeValue() const
virtual ~QgsPropertyKey()
QDomNodeList childNodes() const
QString name() const
every key has a name
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 ...
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...
QVariant value() const override
Return the node's value.
QDomText createTextNode(const QString &value)
const T value(const Key &key) const
QByteArray toLocal8Bit() const
void subkeyList(QStringList &entries) const
return keys that contain other keys
QDomNode firstChild() const
QStringList toStringList() const
QgsPropertyKey(const QString &name="")
const char * typeName() const
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.
int count() const
how many elements are contained within this one?