diff options
author | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2010-02-22 08:51:40 (GMT) |
---|---|---|
committer | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2010-02-23 08:10:10 (GMT) |
commit | ab2497c20116399e963748adf0ed2bf691d42cbf (patch) | |
tree | 44f8818918be4bd3fe0e9e85eede553195c54a70 /src/corelib/kernel/qvariant.cpp | |
parent | 23fb8f6e4f3f6fe4ae7611de84f09cc0095e240c (diff) | |
download | Qt-ab2497c20116399e963748adf0ed2bf691d42cbf.zip Qt-ab2497c20116399e963748adf0ed2bf691d42cbf.tar.gz Qt-ab2497c20116399e963748adf0ed2bf691d42cbf.tar.bz2 |
Add QEasingCurve as builtin metatype
This is needed for qml, in order to be able to use easing as a valuetype.
Task-number: QTBUG-8235
Reviewed-by: thierry
Reviewed-by: janarve
Diffstat (limited to 'src/corelib/kernel/qvariant.cpp')
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index e1b5825..384a3cd 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -46,6 +46,7 @@ #include "qdebug.h" #include "qmap.h" #include "qdatetime.h" +#include "qeasingcurve.h" #include "qlist.h" #include "qstring.h" #include "qstringlist.h" @@ -146,6 +147,11 @@ static void construct(QVariant::Private *x, const void *copy) v_construct<QRegExp>(x, copy); break; #endif +#ifndef QT_BOOTSTRAPPED + case QVariant::EasingCurve: + v_construct<QEasingCurve>(x, copy); + break; +#endif case QVariant::Int: x->data.i = copy ? *static_cast<const int *>(copy) : 0; break; @@ -259,6 +265,11 @@ static void clear(QVariant::Private *d) v_clear<QRegExp>(d); break; #endif +#ifndef QT_BOOTSTRAPPED + case QVariant::EasingCurve: + v_clear<QEasingCurve>(d); + break; +#endif case QVariant::LongLong: case QVariant::ULongLong: case QVariant::Double: @@ -317,6 +328,9 @@ static bool isNull(const QVariant::Private *d) case QVariant::PointF: return v_cast<QPointF>(d)->isNull(); #endif +#ifndef QT_BOOTSTRAPPED + case QVariant::EasingCurve: +#endif case QVariant::Url: case QVariant::Locale: case QVariant::RegExp: @@ -435,6 +449,10 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b) return *v_cast<QTime>(a) == *v_cast<QTime>(b); case QVariant::DateTime: return *v_cast<QDateTime>(a) == *v_cast<QDateTime>(b); +#ifndef QT_BOOTSTRAPPED + case QVariant::EasingCurve: + return *v_cast<QEasingCurve>(a) == *v_cast<QEasingCurve>(b); +#endif case QVariant::ByteArray: return *v_cast<QByteArray>(a) == *v_cast<QByteArray>(b); case QVariant::BitArray: @@ -1097,6 +1115,11 @@ static void streamDebug(QDebug dbg, const QVariant &v) case QVariant::DateTime: dbg.nospace() << v.toDateTime(); break; +#ifndef QT_BOOTSTRAPPED + case QVariant::EasingCurve: + dbg.nospace() << v.toEasingCurve(); + break; +#endif case QVariant::ByteArray: dbg.nospace() << v.toByteArray(); break; @@ -1265,6 +1288,7 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler; \value Date a QDate \value DateTime a QDateTime \value Double a double + \value EasingCurve a QEasingCurve \value Font a QFont \value Hash a QVariantHash \value Icon a QIcon @@ -1483,6 +1507,12 @@ QVariant::QVariant(const char *val) */ /*! + \fn QVariant::QVariant(const QEasingCurve &val) + + Constructs a new variant with an easing curve value, \a val. +*/ + +/*! \fn QVariant::QVariant(const QByteArray &val) Constructs a new variant with a bytearray value, \a val. @@ -1681,6 +1711,10 @@ QVariant::QVariant(const QTime &val) { d.is_null = false; d.type = Time; v_construct<QTime>(&d, val); } QVariant::QVariant(const QDateTime &val) { d.is_null = false; d.type = DateTime; v_construct<QDateTime>(&d, val); } +#ifndef QT_BOOTSTRAPPED +QVariant::QVariant(const QEasingCurve &val) +{ d.is_null = false; d.type = EasingCurve; v_construct<QEasingCurve>(&d, val); } +#endif QVariant::QVariant(const QList<QVariant> &list) { d.is_null = false; d.type = List; v_construct<QVariantList>(&d, list); } QVariant::QVariant(const QMap<QString, QVariant> &map) @@ -1870,7 +1904,7 @@ QVariant::Type QVariant::nameToType(const char *name) } #ifndef QT_NO_DATASTREAM -enum { MapFromThreeCount = 35 }; +enum { MapFromThreeCount = 36 }; static const ushort map_from_three[MapFromThreeCount] = { QVariant::Invalid, @@ -1902,6 +1936,7 @@ static const ushort map_from_three[MapFromThreeCount] = QVariant::Date, QVariant::Time, QVariant::DateTime, + QVariant::EasingCurve, QVariant::ByteArray, QVariant::BitArray, QVariant::KeySequence, @@ -2165,6 +2200,21 @@ QDateTime QVariant::toDateTime() const } /*! + \fn QEasingCurve QVariant::toEasingCurve() const + + Returns the variant as a QEasingCurve if the variant has type() \l + EasingCurve; otherwise returns a default easing curve. + + \sa canConvert(), convert() +*/ +#ifndef QT_BOOTSTRAPPED +QEasingCurve QVariant::toEasingCurve() const +{ + return qVariantToHelper<QEasingCurve>(d, EasingCurve, handler); +} +#endif + +/*! \fn QByteArray QVariant::toByteArray() const Returns the variant as a QByteArray if the variant has type() \l @@ -2605,8 +2655,9 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*QRegExp*/ 0, -/*QHash*/ 0 +/*QHash*/ 0, +/*QEasingCurve*/ 0 }; /*! |