From 73d1476fb1397948a4d806bd921fce372bd8d63b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 2 Dec 2019 17:54:48 +0100 Subject: 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 --- .../corelib/serialization/convert/xmlconverter.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'examples/corelib/serialization/convert/xmlconverter.cpp') 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()) { - const VariantOrderedMap map = (type == QVariant::Map) ? + } else if (type == QMetaType::QVariantMap || type == qMetaTypeId()) { + const VariantOrderedMap map = (type == QMetaType::QVariantMap) ? VariantOrderedMap(v.toMap()) : qvariant_cast(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 { -- cgit v1.2.3