diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-06-20 16:45:12 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-06-20 16:45:12 +0200 |
commit | 6213b8145772d3dc584907a544f6c46b8cef74e2 (patch) | |
tree | 4c1902793bb78511e63c09cbe92f9eda6b3d7237 /src/corelib/kernel/qvariant.cpp | |
parent | 75e9c7d6bc662e62e9ce8b641588183992c1e8bf (diff) | |
parent | 25739bebba0343a8b35775a073c49f0fba080762 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp
tools/configure/configureapp.cpp
Change-Id: I3092bd3276af14304b7ab3ae1e1cc05d11cdede0
Diffstat (limited to 'src/corelib/kernel/qvariant.cpp')
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index a9e7549685..24bf25baea 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -162,6 +162,10 @@ static qlonglong qMetaTypeNumber(const QVariant::Private *d) return qRound64(d->data.f); case QVariant::Double: return qRound64(d->data.d); +#ifndef QT_BOOTSTRAPPED + case QMetaType::QJsonValue: + return v_cast<QJsonValue>(d)->toDouble(); +#endif } Q_ASSERT(false); return 0; @@ -206,12 +210,14 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) case QMetaType::Long: case QMetaType::Float: case QMetaType::LongLong: + case QMetaType::QJsonValue: return qMetaTypeNumber(d); case QVariant::ULongLong: case QVariant::UInt: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: + return qlonglong(qMetaTypeUNumber(d)); } @@ -240,6 +246,7 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) case QMetaType::Long: case QMetaType::Float: case QMetaType::LongLong: + case QMetaType::QJsonValue: return qulonglong(qMetaTypeNumber(d)); case QVariant::ULongLong: case QVariant::UInt: @@ -358,6 +365,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QVariant::Url: *str = v_cast<QUrl>(d)->toString(); break; + case QMetaType::QJsonValue: + *str = v_cast<QJsonValue>(d)->toString(); + break; #endif case QVariant::Uuid: *str = v_cast<QUuid>(d)->toString(); @@ -598,6 +608,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::ULong: *b = qMetaTypeUNumber(d) != Q_UINT64_C(0); break; +#ifndef QT_BOOTSTRAPPED + case QMetaType::QJsonValue: + *b = v_cast<QJsonValue>(d)->toBool(); + break; +#endif default: *b = false; return false; @@ -634,6 +649,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::ULong: *f = double(qMetaTypeUNumber(d)); break; +#ifndef QT_BOOTSTRAPPED + case QMetaType::QJsonValue: + *f = v_cast<QJsonValue>(d)->toDouble(); + break; +#endif default: *f = 0.0; return false; @@ -670,6 +690,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::ULong: *f = float(qMetaTypeUNumber(d)); break; +#ifndef QT_BOOTSTRAPPED + case QMetaType::QJsonValue: + *f = v_cast<QJsonValue>(d)->toDouble(); + break; +#endif default: *f = 0.0f; return false; @@ -2810,6 +2835,29 @@ bool QVariant::canConvert(int targetTypeId) const if (targetTypeId >= QMetaType::User) return canConvertMetaObject(currentType, targetTypeId, d.data.o); + if (currentType == QMetaType::QJsonValue) { + switch (targetTypeId) { + case QMetaType::QString: + case QMetaType::Bool: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::Double: + case QMetaType::Float: + case QMetaType::ULong: + case QMetaType::Long: + case QMetaType::LongLong: + case QMetaType::ULongLong: + case QMetaType::UShort: + case QMetaType::UChar: + case QMetaType::Char: + case QMetaType::SChar: + case QMetaType::Short: + return true; + default: + return false; + } + } + // FIXME It should be LastCoreType intead of Uuid if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) { switch (uint(targetTypeId)) { |