summaryrefslogtreecommitdiffstats
path: root/examples/corelib/serialization/convert/xmlconverter.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2019-12-02 17:54:48 +0100
committerOlivier Goffart <ogoffart@woboq.com>2020-01-23 16:46:51 +0100
commit73d1476fb1397948a4d806bd921fce372bd8d63b (patch)
treea476349c26627027d78c1279da00ef633323311f /examples/corelib/serialization/convert/xmlconverter.cpp
parenta78d66743171557d79b16c08be775e3ac15bb4ef (diff)
Replace most use of QVariant::type and occurrences of QVariant::Type
I made a clazy automated check that replaced the use of QVariant::Type by the equivalent in QMetaType. This has been deprecated since Qt 5.0, but many uses were not yet removed. In addition, there was some manual changes to fix the compilation errors. Adapted the Private API of QDateTimeParser and QMimeDataPrivate and adjust QDateTimeEdit and QSpinBox. QVariant(QVariant::Invalid) in qstylesheet made no sense. But note that in QVariant::save, we actually wanted to use the non-user type. In the SQL module, many changes were actually reverted because the API still expects QVarient::Type. Change-Id: I98c368490e4ee465ed3a3b63bda8b8eaa50ea67e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'examples/corelib/serialization/convert/xmlconverter.cpp')
-rw-r--r--examples/corelib/serialization/convert/xmlconverter.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/examples/corelib/serialization/convert/xmlconverter.cpp b/examples/corelib/serialization/convert/xmlconverter.cpp
index d9e724dfe1..42cb10100a 100644
--- a/examples/corelib/serialization/convert/xmlconverter.cpp
+++ b/examples/corelib/serialization/convert/xmlconverter.cpp
@@ -284,18 +284,18 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
ba.resize(n);
result = ba;
} else {
- int id = QVariant::Invalid;
+ int id = QMetaType::UnknownType;
if (type == QLatin1String("datetime"))
- id = QVariant::DateTime;
+ id = QMetaType::QDateTime;
else if (type == QLatin1String("url"))
- id = QVariant::Url;
+ id = QMetaType::QUrl;
else if (type == QLatin1String("uuid"))
- id = QVariant::Uuid;
+ id = QMetaType::QUuid;
else if (type == QLatin1String("regex"))
- id = QVariant::RegularExpression;
+ id = QMetaType::QRegularExpression;
else
id = QMetaType::type(type.toLatin1());
- if (id == QVariant::Invalid) {
+ if (id == QMetaType::UnknownType) {
fprintf(stderr, "%lld:%lld: Invalid XML: unknown type '%s'.\n",
xml.lineNumber(), xml.columnNumber(), qPrintable(type.toString()));
exit(EXIT_FAILURE);
@@ -327,14 +327,14 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
static void variantToXml(QXmlStreamWriter &xml, const QVariant &v)
{
int type = v.userType();
- if (type == QVariant::List) {
+ if (type == QMetaType::QVariantList) {
QVariantList list = v.toList();
xml.writeStartElement("list");
for (const QVariant &v : list)
variantToXml(xml, v);
xml.writeEndElement();
- } else if (type == QVariant::Map || type == qMetaTypeId<VariantOrderedMap>()) {
- const VariantOrderedMap map = (type == QVariant::Map) ?
+ } else if (type == QMetaType::QVariantMap || type == qMetaTypeId<VariantOrderedMap>()) {
+ const VariantOrderedMap map = (type == QMetaType::QVariantMap) ?
VariantOrderedMap(v.toMap()) :
qvariant_cast<VariantOrderedMap>(v);
@@ -433,7 +433,7 @@ static void variantToXml(QXmlStreamWriter &xml, const QVariant &v)
// does this convert to string?
const char *typeName = v.typeName();
QVariant copy = v;
- if (copy.convert(QVariant::String)) {
+ if (copy.convert(QMetaType::QString)) {
xml.writeAttribute(typeString, QString::fromLatin1(typeName));
xml.writeCharacters(copy.toString());
} else {