SVN commit 625897 by jaham: support saving/loading of complex variant types like QStringList, QMap, etc. M +9 -5 KoProperties.cpp --- trunk/koffice/libs/kofficecore/KoProperties.cpp #625896:625897 @@ -16,7 +16,6 @@ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#include #include #include @@ -44,8 +43,10 @@ const QString name = e.attribute("name"); const QString type = e.attribute("type"); const QString value = e.text(); - // XXX Convert the variant pro-actively to the right type? - m_properties[name] = QVariant(value); + QDataStream in( value.toAscii() ); + QVariant v; + in >> v; + m_properties[name] = v; } } n = n.nextSibling(); @@ -65,8 +66,11 @@ e.setAttribute( "name", QString(it.key().toLatin1()) ); QVariant v = it.value(); e.setAttribute( "type", v.typeName() ); - QString s = v.toString(); - QDomText text = doc.createCDATASection(v.toString() ); // XXX: Unittest this! + + QByteArray bytes; + QDataStream out( &bytes, QIODevice::WriteOnly ); + out << v; + QDomText text = doc.createCDATASection( QString::fromAscii( bytes, bytes.size() ) ); // XXX: Unittest this! e.appendChild(text); root.appendChild(e); }