summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qmlvaluetype.cpp49
-rw-r--r--src/declarative/qml/qmlvaluetype_p.h25
2 files changed, 74 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
diff --git a/src/declarative/qml/qmlvaluetype_p.h b/src/declarative/qml/qmlvaluetype_p.h
index 5581df7..b19c1ba 100644
--- a/src/declarative/qml/qmlvaluetype_p.h
+++ b/src/declarative/qml/qmlvaluetype_p.h
@@ -56,6 +56,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qrect.h>
#include <QtCore/qvariant.h>
+#include <QtGui/qvector3d.h>
QT_BEGIN_NAMESPACE
@@ -105,6 +106,30 @@ public:
private:
QRect rect;
};
+
+class QmlVector3DValueType : public QmlValueType
+{
+ Q_PROPERTY(qreal x READ x WRITE setX);
+ Q_PROPERTY(qreal y READ y WRITE setY);
+ Q_PROPERTY(qreal z READ z WRITE setZ);
+ Q_OBJECT
+public:
+ QmlVector3DValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int);
+
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+ void setX(qreal);
+ void setY(qreal);
+ void setZ(qreal);
+
+private:
+ QVector3D vector;
+};
+
QT_END_NAMESPACE
#endif // QMLVALUETYPE_P_H