diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-04-09 08:41:51 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2017-04-14 12:54:21 +0000 |
commit | e1c8451ffeeaa82f29aa2519addfa377f678ed9e (patch) | |
tree | 475dcb2f6cdb5cbf18270b8f856e9daf95464033 /src/corelib/kernel | |
parent | 097073fa678c6526620f786fbdd6e913a77d54d5 (diff) |
QVariant: implement QByteArray ↔ QUuid conversionv5.9.0-beta2
Seems like an obvious omission.
[ChangeLog][QtCore][QVariant] Can now convert QUuid to and from
QByteArray, not just QString.
Change-Id: Ib56ae86ca0c27adaf1e095b6b85e64fe64ea8d18
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index bca3ac9582..e636c6fe52 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -649,6 +649,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QVariant::Bool: *ba = QByteArray(d->data.b ? "true" : "false"); break; + case QVariant::Uuid: + *ba = v_cast<QUuid>(d)->toByteArray(); + break; default: #ifndef QT_NO_QOBJECT { @@ -916,6 +919,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QVariant::String: *static_cast<QUuid *>(result) = QUuid(*v_cast<QString>(d)); break; + case QVariant::ByteArray: + *static_cast<QUuid *>(result) = QUuid(*v_cast<QByteArray>(d)); + break; default: return false; } @@ -2527,7 +2533,7 @@ QRegularExpression QVariant::toRegularExpression() const \since 5.0 Returns the variant as a QUuid if the variant has type() - \l QMetaType::QUuid or \l QMetaType::QString; + \l QMetaType::QUuid, \l QMetaType::QByteArray or \l QMetaType::QString; otherwise returns a default-constructed QUuid. \sa canConvert(), convert() @@ -2875,7 +2881,8 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*QStringList*/ 1 << QVariant::List | 1 << QVariant::String, /*QByteArray*/ 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool - | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong, + | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong + | 1 << QVariant::Uuid, /*QBitArray*/ 0, @@ -2911,7 +2918,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*QEasingCurve*/ 0, -/*QUuid*/ 1 << QVariant::String +/*QUuid*/ 1 << QVariant::String | 1 << QVariant::ByteArray, }; static const size_t qCanConvertMatrixMaximumTargetType = 8 * sizeof(*qCanConvertMatrix); @@ -2966,7 +2973,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) \l QMetaType::UInt, \l QMetaType::ULongLong \row \li \l QMetaType::QByteArray \li \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, - \l QMetaType::UInt, \l QMetaType::ULongLong + \l QMetaType::UInt, \l QMetaType::ULongLong, \l QMetaType::QUuid \row \li \l QMetaType::QChar \li \l QMetaType::Bool, \l QMetaType::Int, \l QMetaType::UInt, \l QMetaType::LongLong, \l QMetaType::ULongLong \row \li \l QMetaType::QColor \li \l QMetaType::QString @@ -3006,7 +3013,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) \row \li \l QMetaType::ULongLong \li \l QMetaType::Bool, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt - \row \li \l QMetaType::QUuid \li \l QMetaType::QString + \row \li \l QMetaType::QUuid \li \l QMetaType::QByteArray, \l QMetaType::QString \endtable A QVariant containing a pointer to a type derived from QObject will also return true for this |