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 --- src/corelib/kernel/qvariant.cpp | 492 ++++++++++++++++++++-------------------- 1 file changed, 246 insertions(+), 246 deletions(-) (limited to 'src/corelib/kernel/qvariant.cpp') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index f3ac3fcdbac..b417683d2a2 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -168,7 +168,7 @@ static qlonglong qMetaTypeNumber(const QVariant::Private *d) return qlonglong(d->data.l); case QMetaType::Float: return qRound64(d->data.f); - case QVariant::Double: + case QMetaType::Double: return qRound64(d->data.d); #ifndef QT_BOOTSTRAPPED case QMetaType::QJsonValue: @@ -184,9 +184,9 @@ static qlonglong qMetaTypeNumber(const QVariant::Private *d) static qulonglong qMetaTypeUNumber(const QVariant::Private *d) { switch (d->type) { - case QVariant::UInt: + case QMetaType::UInt: return d->data.u; - case QVariant::ULongLong: + case QMetaType::ULongLong: return d->data.ull; case QMetaType::UChar: return d->data.uc; @@ -204,13 +204,13 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) *ok = true; switch (uint(d->type)) { - case QVariant::String: + case QMetaType::QString: return v_cast(d)->toLongLong(ok); - case QVariant::Char: + case QMetaType::QChar: return v_cast(d)->unicode(); - case QVariant::ByteArray: + case QMetaType::QByteArray: return v_cast(d)->toLongLong(ok); - case QVariant::Bool: + case QMetaType::Bool: return qlonglong(d->data.b); #ifndef QT_BOOTSTRAPPED case QMetaType::QCborValue: @@ -222,8 +222,8 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) break; Q_FALLTHROUGH(); #endif - case QVariant::Double: - case QVariant::Int: + case QMetaType::Double: + case QMetaType::Int: case QMetaType::Char: case QMetaType::SChar: case QMetaType::Short: @@ -231,8 +231,8 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) case QMetaType::Float: case QMetaType::LongLong: return qMetaTypeNumber(d); - case QVariant::ULongLong: - case QVariant::UInt: + case QMetaType::ULongLong: + case QMetaType::UInt: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -262,12 +262,12 @@ static qreal qConvertToRealNumber(const QVariant::Private *d, bool *ok) { *ok = true; switch (uint(d->type)) { - case QVariant::Double: + case QMetaType::Double: return qreal(d->data.d); case QMetaType::Float: return qreal(d->data.f); - case QVariant::ULongLong: - case QVariant::UInt: + case QMetaType::ULongLong: + case QMetaType::UInt: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -289,13 +289,13 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) *ok = true; switch (uint(d->type)) { - case QVariant::String: + case QMetaType::QString: return v_cast(d)->toULongLong(ok); - case QVariant::Char: + case QMetaType::QChar: return v_cast(d)->unicode(); - case QVariant::ByteArray: + case QMetaType::QByteArray: return v_cast(d)->toULongLong(ok); - case QVariant::Bool: + case QMetaType::Bool: return qulonglong(d->data.b); #ifndef QT_BOOTSTRAPPED case QMetaType::QCborValue: @@ -309,8 +309,8 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) break; Q_FALLTHROUGH(); #endif - case QVariant::Double: - case QVariant::Int: + case QMetaType::Double: + case QMetaType::Int: case QMetaType::Char: case QMetaType::SChar: case QMetaType::Short: @@ -318,8 +318,8 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) case QMetaType::Float: case QMetaType::LongLong: return qulonglong(qMetaTypeNumber(d)); - case QVariant::ULongLong: - case QVariant::UInt: + case QMetaType::ULongLong: + case QMetaType::UInt: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -406,9 +406,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) switch (uint(t)) { #ifndef QT_BOOTSTRAPPED - case QVariant::Url: + case QMetaType::QUrl: switch (d->type) { - case QVariant::String: + case QMetaType::QString: *static_cast(result) = QUrl(*v_cast(d)); break; case QMetaType::QCborValue: @@ -423,18 +423,18 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; #endif // QT_BOOTSTRAPPED #if QT_CONFIG(itemmodel) - case QVariant::ModelIndex: + case QMetaType::QModelIndex: switch (d->type) { - case QVariant::PersistentModelIndex: + case QMetaType::QPersistentModelIndex: *static_cast(result) = QModelIndex(*v_cast(d)); break; default: return false; } break; - case QVariant::PersistentModelIndex: + case QMetaType::QPersistentModelIndex: switch (d->type) { - case QVariant::ModelIndex: + case QMetaType::QModelIndex: *static_cast(result) = QPersistentModelIndex(*v_cast(d)); break; default: @@ -442,10 +442,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } break; #endif // QT_CONFIG(itemmodel) - case QVariant::String: { + case QMetaType::QString: { QString *str = static_cast(result); switch (d->type) { - case QVariant::Char: + case QMetaType::QChar: *str = *v_cast(d); break; case QMetaType::Char: @@ -455,12 +455,12 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; case QMetaType::Short: case QMetaType::Long: - case QVariant::Int: - case QVariant::LongLong: + case QMetaType::Int: + case QMetaType::LongLong: *str = QString::number(qMetaTypeNumber(d)); break; - case QVariant::UInt: - case QVariant::ULongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: case QMetaType::UShort: case QMetaType::ULong: *str = QString::number(qMetaTypeUNumber(d)); @@ -468,32 +468,32 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::Float: *str = QString::number(d->data.f, 'g', QLocale::FloatingPointShortest); break; - case QVariant::Double: + case QMetaType::Double: *str = QString::number(d->data.d, 'g', QLocale::FloatingPointShortest); break; #if QT_CONFIG(datestring) - case QVariant::Date: + case QMetaType::QDate: *str = v_cast(d)->toString(Qt::ISODate); break; - case QVariant::Time: + case QMetaType::QTime: *str = v_cast(d)->toString(Qt::ISODateWithMs); break; - case QVariant::DateTime: + case QMetaType::QDateTime: *str = v_cast(d)->toString(Qt::ISODateWithMs); break; #endif - case QVariant::Bool: + case QMetaType::Bool: *str = d->data.b ? QStringLiteral("true") : QStringLiteral("false"); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: *str = QString::fromUtf8(v_cast(d)->constData()); break; - case QVariant::StringList: + case QMetaType::QStringList: if (v_cast(d)->count() == 1) *str = v_cast(d)->at(0); break; #ifndef QT_BOOTSTRAPPED - case QVariant::Url: + case QMetaType::QUrl: *str = v_cast(d)->toString(); break; case QMetaType::QJsonValue: @@ -508,7 +508,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) *str = v_cast(d)->toVariant().toString(); break; #endif - case QVariant::Uuid: + case QMetaType::QUuid: *str = v_cast(d)->toString(); break; case QMetaType::Nullptr: @@ -528,11 +528,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } break; } - case QVariant::Char: { + case QMetaType::QChar: { QChar *c = static_cast(result); switch (d->type) { - case QVariant::Int: - case QVariant::LongLong: + case QMetaType::Int: + case QMetaType::LongLong: case QMetaType::Char: case QMetaType::SChar: case QMetaType::Short: @@ -540,8 +540,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::Float: *c = QChar(ushort(qMetaTypeNumber(d))); break; - case QVariant::UInt: - case QVariant::ULongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -553,10 +553,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; } #ifndef QT_NO_GEOM_VARIANT - case QVariant::Size: { + case QMetaType::QSize: { QSize *s = static_cast(result); switch (d->type) { - case QVariant::SizeF: + case QMetaType::QSizeF: *s = v_cast(d)->toSize(); break; default: @@ -565,10 +565,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; } - case QVariant::SizeF: { + case QMetaType::QSizeF: { QSizeF *s = static_cast(result); switch (d->type) { - case QVariant::Size: + case QMetaType::QSize: *s = QSizeF(*(v_cast(d))); break; default: @@ -577,10 +577,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; } - case QVariant::Line: { + case QMetaType::QLine: { QLine *s = static_cast(result); switch (d->type) { - case QVariant::LineF: + case QMetaType::QLineF: *s = v_cast(d)->toLine(); break; default: @@ -589,10 +589,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; } - case QVariant::LineF: { + case QMetaType::QLineF: { QLineF *s = static_cast(result); switch (d->type) { - case QVariant::Line: + case QMetaType::QLine: *s = QLineF(*(v_cast(d))); break; default: @@ -601,27 +601,27 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; } #endif - case QVariant::StringList: - if (d->type == QVariant::List) { + case QMetaType::QStringList: + if (d->type == QMetaType::QVariantList) { QStringList *slst = static_cast(result); const QVariantList *list = v_cast(d); const int size = list->size(); slst->reserve(size); for (int i = 0; i < size; ++i) slst->append(list->at(i).toString()); - } else if (d->type == QVariant::String) { + } else if (d->type == QMetaType::QString) { QStringList *slst = static_cast(result); *slst = QStringList(*v_cast(d)); } else { return false; } break; - case QVariant::Date: { + case QMetaType::QDate: { QDate *dt = static_cast(result); - if (d->type == QVariant::DateTime) + if (d->type == QMetaType::QDateTime) *dt = v_cast(d)->date(); #if QT_CONFIG(datestring) - else if (d->type == QVariant::String) + else if (d->type == QMetaType::QString) *dt = QDate::fromString(*v_cast(d), Qt::ISODate); #endif else @@ -629,14 +629,14 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) return dt->isValid(); } - case QVariant::Time: { + case QMetaType::QTime: { QTime *t = static_cast(result); switch (d->type) { - case QVariant::DateTime: + case QMetaType::QDateTime: *t = v_cast(d)->time(); break; #if QT_CONFIG(datestring) - case QVariant::String: + case QMetaType::QString: *t = QTime::fromString(*v_cast(d), Qt::ISODate); break; #endif @@ -645,11 +645,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } return t->isValid(); } - case QVariant::DateTime: { + case QMetaType::QDateTime: { QDateTime *dt = static_cast(result); switch (d->type) { #if QT_CONFIG(datestring) - case QVariant::String: + case QMetaType::QString: *dt = QDateTime::fromString(*v_cast(d), Qt::ISODate); break; # ifndef QT_BOOTSTRAPPED @@ -661,7 +661,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; # endif #endif - case QVariant::Date: + case QMetaType::QDate: *dt = QDateTime(*v_cast(d)); break; default: @@ -669,13 +669,13 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } return dt->isValid(); } - case QVariant::ByteArray: { + case QMetaType::QByteArray: { QByteArray *ba = static_cast(result); switch (d->type) { - case QVariant::String: + case QMetaType::QString: *ba = v_cast(d)->toUtf8(); break; - case QVariant::Double: + case QMetaType::Double: *ba = QByteArray::number(d->data.d, 'g', QLocale::FloatingPointShortest); break; case QMetaType::Float: @@ -686,22 +686,22 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::UChar: *ba = QByteArray(1, d->data.c); break; - case QVariant::Int: - case QVariant::LongLong: + case QMetaType::Int: + case QMetaType::LongLong: case QMetaType::Short: case QMetaType::Long: *ba = QByteArray::number(qMetaTypeNumber(d)); break; - case QVariant::UInt: - case QVariant::ULongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: case QMetaType::UShort: case QMetaType::ULong: *ba = QByteArray::number(qMetaTypeUNumber(d)); break; - case QVariant::Bool: + case QMetaType::Bool: *ba = QByteArray(d->data.b ? "true" : "false"); break; - case QVariant::Uuid: + case QMetaType::QUuid: *ba = v_cast(d)->toByteArray(); break; case QMetaType::Nullptr: @@ -741,16 +741,16 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::ULong: *static_cast(result) = ulong(qConvertToUnsignedNumber(d, ok)); return *ok; - case QVariant::Int: + case QMetaType::Int: *static_cast(result) = int(qConvertToNumber(d, ok)); return *ok; - case QVariant::UInt: + case QMetaType::UInt: *static_cast(result) = uint(qConvertToUnsignedNumber(d, ok)); return *ok; - case QVariant::LongLong: + case QMetaType::LongLong: *static_cast(result) = qConvertToNumber(d, ok); return *ok; - case QVariant::ULongLong: { + case QMetaType::ULongLong: { *static_cast(result) = qConvertToUnsignedNumber(d, ok); return *ok; } @@ -763,21 +763,21 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) *static_cast(result) = qConvertToUnsignedNumber(d, ok); return *ok; } - case QVariant::Bool: { + case QMetaType::Bool: { bool *b = static_cast(result); switch(d->type) { - case QVariant::ByteArray: + case QMetaType::QByteArray: *b = qt_convertToBool(d); break; - case QVariant::String: + case QMetaType::QString: *b = qt_convertToBool(d); break; - case QVariant::Char: + case QMetaType::QChar: *b = !v_cast(d)->isNull(); break; - case QVariant::Double: - case QVariant::Int: - case QVariant::LongLong: + case QMetaType::Double: + case QMetaType::Int: + case QMetaType::LongLong: case QMetaType::Char: case QMetaType::SChar: case QMetaType::Short: @@ -785,8 +785,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::Float: *b = qMetaTypeNumber(d) != Q_INT64_C(0); break; - case QVariant::UInt: - case QVariant::ULongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -810,31 +810,31 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } break; } - case QVariant::Double: { + case QMetaType::Double: { double *f = static_cast(result); switch (d->type) { - case QVariant::String: + case QMetaType::QString: *f = v_cast(d)->toDouble(ok); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: *f = v_cast(d)->toDouble(ok); break; - case QVariant::Bool: + case QMetaType::Bool: *f = double(d->data.b); break; case QMetaType::Float: *f = double(d->data.f); break; - case QVariant::LongLong: - case QVariant::Int: + case QMetaType::LongLong: + case QMetaType::Int: case QMetaType::Char: case QMetaType::SChar: case QMetaType::Short: case QMetaType::Long: *f = double(qMetaTypeNumber(d)); break; - case QVariant::UInt: - case QVariant::ULongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -861,28 +861,28 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::Float: { float *f = static_cast(result); switch (d->type) { - case QVariant::String: + case QMetaType::QString: *f = v_cast(d)->toFloat(ok); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: *f = v_cast(d)->toFloat(ok); break; - case QVariant::Bool: + case QMetaType::Bool: *f = float(d->data.b); break; - case QVariant::Double: + case QMetaType::Double: *f = float(d->data.d); break; - case QVariant::LongLong: - case QVariant::Int: + case QMetaType::LongLong: + case QMetaType::Int: case QMetaType::Char: case QMetaType::SChar: case QMetaType::Short: case QMetaType::Long: *f = float(qMetaTypeNumber(d)); break; - case QVariant::UInt: - case QVariant::ULongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -906,8 +906,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } break; } - case QVariant::List: - if (d->type == QVariant::StringList) { + case QMetaType::QVariantList: + if (d->type == QMetaType::QStringList) { QVariantList *lst = static_cast(result); const QStringList *slist = v_cast(d); const int size = slist->size(); @@ -935,11 +935,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) return false; } break; - case QVariant::Map: + case QMetaType::QVariantMap: if (qstrcmp(QMetaType::typeName(d->type), "QMap") == 0) { *static_cast(result) = *static_cast *>(d->data.shared->ptr); - } else if (d->type == QVariant::Hash) { + } else if (d->type == QMetaType::QVariantHash) { QVariantMap *map = static_cast(result); const QVariantHash *hash = v_cast(d); const auto end = hash->end(); @@ -963,11 +963,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) return false; } break; - case QVariant::Hash: + case QMetaType::QVariantHash: if (qstrcmp(QMetaType::typeName(d->type), "QHash") == 0) { *static_cast(result) = *static_cast *>(d->data.shared->ptr); - } else if (d->type == QVariant::Map) { + } else if (d->type == QMetaType::QVariantMap) { QVariantHash *hash = static_cast(result); const QVariantMap *map = v_cast(d); const auto end = map->end(); @@ -992,26 +992,26 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } break; #ifndef QT_NO_GEOM_VARIANT - case QVariant::Rect: - if (d->type == QVariant::RectF) + case QMetaType::QRect: + if (d->type == QMetaType::QRectF) *static_cast(result) = (v_cast(d))->toRect(); else return false; break; - case QVariant::RectF: - if (d->type == QVariant::Rect) + case QMetaType::QRectF: + if (d->type == QMetaType::QRect) *static_cast(result) = *v_cast(d); else return false; break; - case QVariant::PointF: - if (d->type == QVariant::Point) + case QMetaType::QPointF: + if (d->type == QMetaType::QPoint) *static_cast(result) = *v_cast(d); else return false; break; - case QVariant::Point: - if (d->type == QVariant::PointF) + case QMetaType::QPoint: + if (d->type == QMetaType::QPointF) *static_cast(result) = (v_cast(d))->toPoint(); else return false; @@ -1022,12 +1022,12 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) return *ok; } #endif - case QVariant::Uuid: + case QMetaType::QUuid: switch (d->type) { - case QVariant::String: + case QMetaType::QString: *static_cast(result) = QUuid(*v_cast(d)); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: *static_cast(result) = QUuid(*v_cast(d)); break; #ifndef QT_BOOTSTRAPPED @@ -1067,7 +1067,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::Nullptr: *static_cast(result) = QJsonValue(QJsonValue::Null); break; - case QVariant::Bool: + case QMetaType::Bool: *static_cast(result) = QJsonValue(d->data.b); break; case QMetaType::Int: @@ -1086,19 +1086,19 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) *static_cast(result) = QJsonValue(qConvertToRealNumber(d, ok)); Q_ASSERT(ok); break; - case QVariant::String: + case QMetaType::QString: *static_cast(result) = QJsonValue(*v_cast(d)); break; - case QVariant::StringList: + case QMetaType::QStringList: *static_cast(result) = QJsonValue(QJsonArray::fromStringList(*v_cast(d))); break; - case QVariant::List: + case QMetaType::QVariantList: *static_cast(result) = QJsonValue(QJsonArray::fromVariantList(*v_cast(d))); break; - case QVariant::Map: + case QMetaType::QVariantMap: *static_cast(result) = QJsonValue(QJsonObject::fromVariantMap(*v_cast(d))); break; - case QVariant::Hash: + case QMetaType::QVariantHash: *static_cast(result) = QJsonValue(QJsonObject::fromVariantHash(*v_cast(d))); break; case QMetaType::QJsonObject: @@ -1128,10 +1128,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; case QMetaType::QJsonArray: switch (d->type) { - case QVariant::StringList: + case QMetaType::QStringList: *static_cast(result) = QJsonArray::fromStringList(*v_cast(d)); break; - case QVariant::List: + case QMetaType::QVariantList: *static_cast(result) = QJsonArray::fromVariantList(*v_cast(d)); break; case QMetaType::QJsonValue: @@ -1158,10 +1158,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; case QMetaType::QJsonObject: switch (d->type) { - case QVariant::Map: + case QMetaType::QVariantMap: *static_cast(result) = QJsonObject::fromVariantMap(*v_cast(d)); break; - case QVariant::Hash: + case QMetaType::QVariantHash: *static_cast(result) = QJsonObject::fromVariantHash(*v_cast(d)); break; case QMetaType::QJsonValue: @@ -1197,7 +1197,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::Nullptr: *static_cast(result) = QCborValue(QCborValue::Null); break; - case QVariant::Bool: + case QMetaType::Bool: *static_cast(result) = QCborValue(d->data.b); break; case QMetaType::Int: @@ -1219,39 +1219,39 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) *static_cast(result) = QCborValue(qConvertToRealNumber(d, ok)); Q_ASSERT(ok); break; - case QVariant::String: + case QMetaType::QString: *static_cast(result) = *v_cast(d); break; - case QVariant::StringList: + case QMetaType::QStringList: *static_cast(result) = QCborArray::fromStringList(*v_cast(d)); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: *static_cast(result) = *v_cast(d); break; - case QVariant::Date: + case QMetaType::QDate: *static_cast(result) = QCborValue(QDateTime(*v_cast(d))); break; - case QVariant::DateTime: + case QMetaType::QDateTime: *static_cast(result) = QCborValue(*v_cast(d)); break; - case QVariant::Url: + case QMetaType::QUrl: *static_cast(result) = QCborValue(*v_cast(d)); break; #if QT_CONFIG(regularexpression) - case QVariant::RegularExpression: + case QMetaType::QRegularExpression: *static_cast(result) = QCborValue(*v_cast(d)); break; #endif - case QVariant::Uuid: + case QMetaType::QUuid: *static_cast(result) = QCborValue(*v_cast(d)); break; - case QVariant::List: + case QMetaType::QVariantList: *static_cast(result) = QCborArray::fromVariantList(*v_cast(d)); break; - case QVariant::Map: + case QMetaType::QVariantMap: *static_cast(result) = QCborMap::fromVariantMap(*v_cast(d)); break; - case QVariant::Hash: + case QMetaType::QVariantHash: *static_cast(result) = QCborMap::fromVariantHash(*v_cast(d)); break; case QMetaType::QJsonValue: @@ -1287,10 +1287,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; case QMetaType::QCborArray: switch (d->type) { - case QVariant::StringList: + case QMetaType::QStringList: *static_cast(result) = QCborArray::fromStringList(*v_cast(d)); break; - case QVariant::List: + case QMetaType::QVariantList: *static_cast(result) = QCborArray::fromVariantList(*v_cast(d)); break; case QMetaType::QCborValue: @@ -1317,10 +1317,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; case QMetaType::QCborMap: switch (d->type) { - case QVariant::Map: + case QMetaType::QVariantMap: *static_cast(result) = QCborMap::fromVariantMap(*v_cast(d)); break; - case QVariant::Hash: + case QMetaType::QVariantHash: *static_cast(result) = QCborMap::fromVariantHash(*v_cast(d)); break; case QMetaType::QCborValue: @@ -1349,10 +1349,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) default: #ifndef QT_NO_QOBJECT - if (d->type == QVariant::String || d->type == QVariant::ByteArray) { + if (d->type == QMetaType::QString || d->type == QMetaType::QByteArray) { QMetaEnum en = metaEnumFromType(t); if (en.isValid()) { - QByteArray keys = (d->type == QVariant::String) ? v_cast(d)->toUtf8() : *v_cast(d); + QByteArray keys = (d->type == QMetaType::QString) ? v_cast(d)->toUtf8() : *v_cast(d); int value = en.keysToValue(keys.constData(), ok); if (*ok) { switch (QMetaType::sizeOf(t)) { @@ -1457,7 +1457,7 @@ static void customConstruct(QVariant::Private *d, const void *copy) const uint size = type.sizeOf(); if (!size) { qWarning("Trying to construct an instance of an invalid type, type id: %i", d->type); - d->type = QVariant::Invalid; + d->type = QMetaType::UnknownType; return; } @@ -2438,43 +2438,43 @@ QVariant::Type QVariant::nameToType(const char *name) enum { MapFromThreeCount = 36 }; static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] = { - QVariant::Invalid, - QVariant::Map, - QVariant::List, - QVariant::String, - QVariant::StringList, - QVariant::Font, - QVariant::Pixmap, - QVariant::Brush, - QVariant::Rect, - QVariant::Size, - QVariant::Color, - QVariant::Palette, + QMetaType::UnknownType, + QMetaType::QVariantMap, + QMetaType::QVariantList, + QMetaType::QString, + QMetaType::QStringList, + QMetaType::QFont, + QMetaType::QPixmap, + QMetaType::QBrush, + QMetaType::QRect, + QMetaType::QSize, + QMetaType::QColor, + QMetaType::QPalette, 0, // ColorGroup - QVariant::Icon, - QVariant::Point, - QVariant::Image, - QVariant::Int, - QVariant::UInt, - QVariant::Bool, - QVariant::Double, + QMetaType::QIcon, + QMetaType::QPoint, + QMetaType::QImage, + QMetaType::Int, + QMetaType::UInt, + QMetaType::Bool, + QMetaType::Double, 0, // Buggy ByteArray, QByteArray never had id == 20 - QVariant::Polygon, - QVariant::Region, - QVariant::Bitmap, - QVariant::Cursor, - QVariant::SizePolicy, - QVariant::Date, - QVariant::Time, - QVariant::DateTime, - QVariant::ByteArray, - QVariant::BitArray, - QVariant::KeySequence, - QVariant::Pen, - QVariant::LongLong, - QVariant::ULongLong, + QMetaType::QPolygon, + QMetaType::QRegion, + QMetaType::QBitmap, + QMetaType::QCursor, + QMetaType::QSizePolicy, + QMetaType::QDate, + QMetaType::QTime, + QMetaType::QDateTime, + QMetaType::QByteArray, + QMetaType::QBitArray, + QMetaType::QKeySequence, + QMetaType::QPen, + QMetaType::LongLong, + QMetaType::ULongLong, #if QT_CONFIG(easingcurve) - QVariant::EasingCurve + QMetaType::QEasingCurve #endif }; @@ -2551,7 +2551,7 @@ void QVariant::load(QDataStream &s) */ void QVariant::save(QDataStream &s) const { - quint32 typeId = type(); + quint32 typeId = d.type >= QMetaType::User ? QMetaType::User : userType(); bool fakeUserType = false; if (s.version() < QDataStream::Qt_4_0) { int i; @@ -3294,80 +3294,80 @@ QVariantList QVariant::toList() const } -static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = +static const quint32 qCanConvertMatrix[QMetaType::LastCoreType + 1] = { /*Invalid*/ 0, -/*Bool*/ 1 << QVariant::Double | 1 << QVariant::Int | 1 << QVariant::UInt - | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::ByteArray - | 1 << QVariant::String | 1 << QVariant::Char, +/*Bool*/ 1 << QMetaType::Double | 1 << QMetaType::Int | 1 << QMetaType::UInt + | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong | 1 << QMetaType::QByteArray + | 1 << QMetaType::QString | 1 << QMetaType::QChar, -/*Int*/ 1 << QVariant::UInt | 1 << QVariant::String | 1 << QVariant::Double - | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong - | 1 << QVariant::Char | 1 << QVariant::ByteArray | 1 << QVariant::Int, +/*Int*/ 1 << QMetaType::UInt | 1 << QMetaType::QString | 1 << QMetaType::Double + | 1 << QMetaType::Bool | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong + | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray | 1 << QMetaType::Int, -/*UInt*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double - | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong - | 1 << QVariant::Char | 1 << QVariant::ByteArray, +/*UInt*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::Double + | 1 << QMetaType::Bool | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong + | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray, -/*LLong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double - | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::ULongLong - | 1 << QVariant::Char | 1 << QVariant::ByteArray, +/*LLong*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::Double + | 1 << QMetaType::Bool | 1 << QMetaType::UInt | 1 << QMetaType::ULongLong + | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray, -/*ULlong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double - | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong - | 1 << QVariant::Char | 1 << QVariant::ByteArray, +/*ULlong*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::Double + | 1 << QMetaType::Bool | 1 << QMetaType::UInt | 1 << QMetaType::LongLong + | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray, -/*double*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::ULongLong - | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong - | 1 << QVariant::ByteArray, +/*double*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::ULongLong + | 1 << QMetaType::Bool | 1 << QMetaType::UInt | 1 << QMetaType::LongLong + | 1 << QMetaType::QByteArray, -/*QChar*/ 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::LongLong - | 1 << QVariant::ULongLong, +/*QChar*/ 1 << QMetaType::Int | 1 << QMetaType::UInt | 1 << QMetaType::LongLong + | 1 << QMetaType::ULongLong, /*QMap*/ 0, -/*QList*/ 1 << QVariant::StringList, +/*QList*/ 1 << QMetaType::QStringList, -/*QString*/ 1 << QVariant::StringList | 1 << QVariant::ByteArray | 1 << QVariant::Int - | 1 << QVariant::UInt | 1 << QVariant::Bool | 1 << QVariant::Double - | 1 << QVariant::Date | 1 << QVariant::Time | 1 << QVariant::DateTime - | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char - | 1 << QVariant::Url | 1 << QVariant::Uuid, +/*QString*/ 1 << QMetaType::QStringList | 1 << QMetaType::QByteArray | 1 << QMetaType::Int + | 1 << QMetaType::UInt | 1 << QMetaType::Bool | 1 << QMetaType::Double + | 1 << QMetaType::QDate | 1 << QMetaType::QTime | 1 << QMetaType::QDateTime + | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong | 1 << QMetaType::QChar + | 1 << QMetaType::QUrl | 1 << QMetaType::QUuid, -/*QStringList*/ 1 << QVariant::List | 1 << QVariant::String, +/*QStringList*/ 1 << QMetaType::QVariantList | 1 << QMetaType::QString, -/*QByteArray*/ 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool - | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong - | 1 << QVariant::Uuid, +/*QByteArray*/ 1 << QMetaType::QString | 1 << QMetaType::Int | 1 << QMetaType::UInt | 1 << QMetaType::Bool + | 1 << QMetaType::Double | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong + | 1 << QMetaType::QUuid, /*QBitArray*/ 0, -/*QDate*/ 1 << QVariant::String | 1 << QVariant::DateTime, +/*QDate*/ 1 << QMetaType::QString | 1 << QMetaType::QDateTime, -/*QTime*/ 1 << QVariant::String | 1 << QVariant::DateTime, +/*QTime*/ 1 << QMetaType::QString | 1 << QMetaType::QDateTime, -/*QDateTime*/ 1 << QVariant::String | 1 << QVariant::Date, +/*QDateTime*/ 1 << QMetaType::QString | 1 << QMetaType::QDate, -/*QUrl*/ 1 << QVariant::String, +/*QUrl*/ 1 << QMetaType::QString, /*QLocale*/ 0, -/*QRect*/ 1 << QVariant::RectF, +/*QRect*/ 1 << QMetaType::QRectF, -/*QRectF*/ 1 << QVariant::Rect, +/*QRectF*/ 1 << QMetaType::QRect, -/*QSize*/ 1 << QVariant::SizeF, +/*QSize*/ 1 << QMetaType::QSizeF, -/*QSizeF*/ 1 << QVariant::Size, +/*QSizeF*/ 1 << QMetaType::QSize, -/*QLine*/ 1 << QVariant::LineF, +/*QLine*/ 1 << QMetaType::QLineF, -/*QLineF*/ 1 << QVariant::Line, +/*QLineF*/ 1 << QMetaType::QLine, -/*QPoint*/ 1 << QVariant::PointF, +/*QPoint*/ 1 << QMetaType::QPointF, -/*QPointF*/ 1 << QVariant::Point, +/*QPointF*/ 1 << QMetaType::QPoint, /*QRegExp*/ 0, @@ -3375,7 +3375,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*QEasingCurve*/ 0, -/*QUuid*/ 1 << QVariant::String | 1 << QVariant::ByteArray, +/*QUuid*/ 1 << QMetaType::QString | 1 << QMetaType::QByteArray, }; static const size_t qCanConvertMatrixMaximumTargetType = 8 * sizeof(*qCanConvertMatrix); @@ -3915,7 +3915,7 @@ static bool qIsNumericType(uint tp) static bool qIsFloatingPoint(uint tp) { - return tp == QVariant::Double || tp == QMetaType::Float; + return tp == QMetaType::Double || tp == QMetaType::Float; } static int normalizeLowerRanks(uint tp) @@ -3927,13 +3927,13 @@ static int normalizeLowerRanks(uint tp) Q_UINT64_C(1) << QMetaType::UChar | Q_UINT64_C(1) << QMetaType::Short | Q_UINT64_C(1) << QMetaType::UShort; - return numericTypeBits & (Q_UINT64_C(1) << tp) ? QVariant::Int : tp; + return numericTypeBits & (Q_UINT64_C(1) << tp) ? uint(QMetaType::Int) : tp; } static int normalizeLong(uint tp) { - const uint IntType = sizeof(long) == sizeof(int) ? QVariant::Int : QVariant::LongLong; - const uint UIntType = sizeof(ulong) == sizeof(uint) ? QVariant::UInt : QVariant::ULongLong; + const uint IntType = sizeof(long) == sizeof(int) ? QMetaType::Int : QMetaType::LongLong; + const uint UIntType = sizeof(ulong) == sizeof(uint) ? QMetaType::UInt : QMetaType::ULongLong; return tp == QMetaType::Long ? IntType : tp == QMetaType::ULong ? UIntType : tp; } @@ -3975,13 +3975,13 @@ static int numericTypePromotion(uint t1, uint t2) // if any of the two is ULongLong, then it wins (highest rank, unsigned) // otherwise, if one of the two is LongLong, then the other is either LongLong too or lower-ranked // otherwise, if one of the two is UInt, then the other is either UInt too or Int - if (t1 == QVariant::ULongLong || t2 == QVariant::ULongLong) - return QVariant::ULongLong; - if (t1 == QVariant::LongLong || t2 == QVariant::LongLong) - return QVariant::LongLong; - if (t1 == QVariant::UInt || t2 == QVariant::UInt) - return QVariant::UInt; - return QVariant::Int; + if (t1 == QMetaType::ULongLong || t2 == QMetaType::ULongLong) + return QMetaType::ULongLong; + if (t1 == QMetaType::LongLong || t2 == QMetaType::LongLong) + return QMetaType::LongLong; + if (t1 == QMetaType::UInt || t2 == QMetaType::UInt) + return QMetaType::UInt; + return QMetaType::Int; } static int integralCompare(uint promotedType, const QVariant::Private *d1, const QVariant::Private *d2) @@ -3994,13 +3994,13 @@ static int integralCompare(uint promotedType, const QVariant::Private *d1, const qlonglong l2 = qConvertToNumber(d2, &ok); Q_ASSERT(ok); - if (promotedType == QVariant::Int) + if (promotedType == QMetaType::Int) return int(l1) < int(l2) ? -1 : int(l1) == int(l2) ? 0 : 1; - if (promotedType == QVariant::UInt) + if (promotedType == QMetaType::UInt) return uint(l1) < uint(l2) ? -1 : uint(l1) == uint(l2) ? 0 : 1; - if (promotedType == QVariant::LongLong) + if (promotedType == QMetaType::LongLong) return l1 < l2 ? -1 : l1 == l2 ? 0 : 1; - if (promotedType == QVariant::ULongLong) + if (promotedType == QMetaType::ULongLong) return qulonglong(l1) < qulonglong(l2) ? -1 : qulonglong(l1) == qulonglong(l2) ? 0 : 1; Q_UNREACHABLE(); -- cgit v1.2.3