diff options
author | Chris Adams <christopher.adams@nokia.com> | 2012-06-26 18:02:35 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-11 01:46:52 +0200 |
commit | f5cb65b35e076facbce45e896902a34da7036135 (patch) | |
tree | 7575065fde2d0c14c379a992bf8b3593e21f4881 /src/qml/qml/qqmlglobal_p.h | |
parent | 5376906de58e1c25c77b7a61800365b6e542542f (diff) |
Fix broken value-type support by allowing property definition
In QtQuick 1.x the "variant" property type was supported, which could
be used to allow value type properties to be defined in QML. In
QtQuick 2.0, we have deprecated the "variant" property, but its
replacement ("var") is not suited for defining lightweight C++ type
values (such as QColor, QFont, QRectF, QVector3D etc).
This commit allows those QML basic types to be used in QML once more,
by supporting them in the property definition syntax.
Note that since some value types are provided by QtQuick and others
are provided by QtQml, if a client imports only QtQml they can define
but not use properties of certain types (eg, font).
Task-number: QTBUG-21034
Task-number: QTBUG-18217
Change-Id: Ia951a8522f223408d27293bb96c276281a710277
Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlglobal_p.h')
-rw-r--r-- | src/qml/qml/qqmlglobal_p.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index b3e8eb6421..b10457bd29 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -46,6 +46,7 @@ #include <QtCore/QObject> #include <private/qqmlpropertycache_p.h> #include <private/qmetaobject_p.h> +#include <private/qv8engine_p.h> QT_BEGIN_HEADER @@ -208,7 +209,7 @@ inline void QQml_setParent_noEvent(QObject *object, QObject *parent) class QQmlValueType; - +class QV8Engine; class Q_QML_PRIVATE_EXPORT QQmlValueTypeProvider { public: @@ -226,10 +227,11 @@ public: QVariant createVariantFromString(const QString &); QVariant createVariantFromString(int, const QString &, bool *); + QVariant createVariantFromJsObject(int, QQmlV8Handle, QV8Engine *, bool*); - bool equalValueType(int, const void *, const void *); + bool equalValueType(int, const void *, const void *, size_t); bool storeValueType(int, const void *, void *, size_t); - bool readValueType(int, const void *, int, void *); + bool readValueType(int, const void *, size_t, int, void *); bool writeValueType(int, const void *, void *, size_t); private: @@ -245,10 +247,11 @@ private: virtual bool variantFromString(const QString &, QVariant *); virtual bool variantFromString(int, const QString &, QVariant *); + virtual bool variantFromJsObject(int, QQmlV8Handle, QV8Engine *, QVariant *); - virtual bool equal(int, const void *, const void *); + virtual bool equal(int, const void *, const void *, size_t); virtual bool store(int, const void *, void *, size_t); - virtual bool read(int, const void *, int, void *); + virtual bool read(int, const void *, size_t, int, void *); virtual bool write(int, const void *, void *, size_t); friend Q_QML_PRIVATE_EXPORT void QQml_addValueTypeProvider(QQmlValueTypeProvider *); |