diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-07-24 05:37:14 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-07-24 05:37:14 (GMT) |
commit | aff524d218e9d2f2ed4a02258a5a159be3e61de6 (patch) | |
tree | c282acd117f772d82efe30ae29c6c003f1af570e /src/declarative/qml/qmlvaluetype.cpp | |
parent | 3ff864cf3ec30af8f5a7522eef7bc170d7e99911 (diff) | |
download | Qt-aff524d218e9d2f2ed4a02258a5a159be3e61de6.zip Qt-aff524d218e9d2f2ed4a02258a5a159be3e61de6.tar.gz Qt-aff524d218e9d2f2ed4a02258a5a159be3e61de6.tar.bz2 |
Add QVector3D as a value type to QML
Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src/declarative/qml/qmlvaluetype.cpp')
-rw-r--r-- | src/declarative/qml/qmlvaluetype.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlvaluetype.cpp b/src/declarative/qml/qmlvaluetype.cpp index a01b4a7..571263e 100644 --- a/src/declarative/qml/qmlvaluetype.cpp +++ b/src/declarative/qml/qmlvaluetype.cpp @@ -61,6 +61,8 @@ QmlValueType *QmlValueTypeFactory::valueType(int t) switch (t) { case QVariant::Rect: return new QmlRectValueType; + case QVariant::Vector3D: + return new QmlVector3DValueType; default: return 0; } @@ -128,4 +130,51 @@ void QmlRectValueType::setHeight(int h) rect.setHeight(h); } +QmlVector3DValueType::QmlVector3DValueType(QObject *parent) +: QmlValueType(parent) +{ +} + +void QmlVector3DValueType::read(QObject *obj, int idx) +{ + void *a[] = { &vector, 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a); +} + +void QmlVector3DValueType::write(QObject *obj, int idx) +{ + void *a[] = { &vector, 0 }; + QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); +} + +qreal QmlVector3DValueType::x() const +{ + return vector.x(); +} + +qreal QmlVector3DValueType::y() const +{ + return vector.y(); +} + +qreal QmlVector3DValueType::z() const +{ + return vector.z(); +} + +void QmlVector3DValueType::setX(qreal x) +{ + vector.setX(x); +} + +void QmlVector3DValueType::setY(qreal y) +{ + vector.setY(y); +} + +void QmlVector3DValueType::setZ(qreal z) +{ + vector.setZ(z); +} + QT_END_NAMESPACE |