20 #include <QMetaClassInfo>
32 m_pXmlWriter->writeDTD(R
"(<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">)");
47 return "text/x-apple-plist+xml";
51 const QVariant &vValue,
54 if ( vValue.canConvert<QObject*>())
56 const QObject *pObject = vValue.value<QObject*>();
61 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
62 auto type =
static_cast<QMetaType::Type
>(vValue.type());
64 auto type = vValue.typeId();
68 case QMetaType::QVariantList:
74 case QMetaType::QStringList:
80 case QMetaType::QVariantMap:
86 case QMetaType::QDateTime:
88 if (vValue.toDateTime().isValid())
92 m_pXmlWriter->writeTextElement(
"date", vValue.toDateTime()
93 .toUTC().toString(
"yyyy-MM-ddThh:mm:ssZ"));
98 case QMetaType::QByteArray:
100 if (!vValue.toByteArray().isNull())
105 vValue.toByteArray().toBase64().data());
110 case QMetaType::Bool:
119 case QMetaType::UInt:
120 case QMetaType::ULongLong:
125 QString::number(vValue.toULongLong()));
130 case QMetaType::LongLong:
131 case QMetaType::Double:
136 QString(
"%1").arg(vValue.toDouble(), 0,
'f', 6));
141 case QMetaType::QString:
146 m_pXmlWriter->writeTextElement(
"string", vValue.toString());
153 const QVariantList &list)
158 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
159 auto t =
static_cast<QMetaType::Type
>(list[0].type());
160 array = std::all_of(list.cbegin(), list.cend(),
161 [
t](
const QVariant& v)
162 { return t == static_cast<QMetaType::Type>(v.type()); } );
164 auto t = list[0].typeId();
165 array = std::all_of(list.cbegin(), list.cend(),
166 [
t](
const QVariant& v) { return t == v.typeId(); } );
172 m_pXmlWriter->writeStartElement(array ?
"array" :
"dict");
174 QListIterator<QVariant> it(list);
182 const QStringList &list)
187 QListIterator<QString> it(list);
195 const QVariantMap &map)
201 QMapIterator<QString,QVariant> it(map);
212 const QObject *pObject)
214 const QMetaObject *pMeta = pObject->metaObject();
219 nIdx = pMeta->indexOfClassInfo(
"version");
224 m_pXmlWriter->writeTextElement(
"string", pMeta->classInfo(nIdx).value());
227 m_pXmlWriter->writeTextElement(
"key",
"serializerversion");
241 const QVariant &vValue,
243 const QMetaProperty *)
249 const QObject *pObject,
262 const QMetaObject *pMetaObject = pObject->metaObject();
264 int nCount = pMetaObject->propertyCount();
266 for (
int nIdx=0; nIdx < nCount; ++nIdx)
268 QMetaProperty metaProperty = pMetaObject->property(nIdx);
270 if (metaProperty.isDesignable())
272 const char *pszPropName = metaProperty.name();
273 QString sPropName(pszPropName);
275 if (sPropName.compare(
"objectName") == 0)
278 QVariant value(pObject->property(pszPropName));
280 AddProperty(sPropName, value, pMetaObject, &metaProperty);