diff options
author | Thomas Hartmann <Thomas.Hartmann@nokia.com> | 2009-08-25 10:06:18 (GMT) |
---|---|---|
committer | Thomas Hartmann <Thomas.Hartmann@nokia.com> | 2009-08-25 10:07:35 (GMT) |
commit | 430e8577845e7722bf8397ce5b37dd83f5de1b2e (patch) | |
tree | ab0cd334ce85b7c7dd780908d69d0cd35c22ce6b /src/declarative/qml/qmlvaluetype.cpp | |
parent | ecd37a35adc4008b105b8bc9fcf55450da1dd949 (diff) | |
download | Qt-430e8577845e7722bf8397ce5b37dd83f5de1b2e.zip Qt-430e8577845e7722bf8397ce5b37dd83f5de1b2e.tar.gz Qt-430e8577845e7722bf8397ce5b37dd83f5de1b2e.tar.bz2 |
Reading and writing of QVariant for QmlValueType
This is very useful for Bauhaus and avoids code duplication
Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src/declarative/qml/qmlvaluetype.cpp')
-rw-r--r-- | src/declarative/qml/qmlvaluetype.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlvaluetype.cpp b/src/declarative/qml/qmlvaluetype.cpp index 7af3c56..4ae2070 100644 --- a/src/declarative/qml/qmlvaluetype.cpp +++ b/src/declarative/qml/qmlvaluetype.cpp @@ -103,6 +103,16 @@ void QmlPointFValueType::write(QObject *obj, int idx) QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } +QVariant QmlPointFValueType::value() +{ + return QVariant(point); +} + +void QmlPointFValueType::setValue(QVariant value) +{ + point = qvariant_cast<QPointF>(value); +} + qreal QmlPointFValueType::x() const { return point.x(); @@ -140,6 +150,16 @@ void QmlPointValueType::write(QObject *obj, int idx) QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } +QVariant QmlPointValueType::value() +{ + return QVariant(point); +} + +void QmlPointValueType::setValue(QVariant value) +{ + point = qvariant_cast<QPoint>(value); +} + int QmlPointValueType::x() const { return point.x(); @@ -177,6 +197,16 @@ void QmlSizeFValueType::write(QObject *obj, int idx) QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } +QVariant QmlSizeFValueType::value() +{ + return QVariant(size); +} + +void QmlSizeFValueType::setValue(QVariant value) +{ + size = qvariant_cast<QSizeF>(value); +} + qreal QmlSizeFValueType::width() const { return size.width(); @@ -214,6 +244,16 @@ void QmlSizeValueType::write(QObject *obj, int idx) QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } +QVariant QmlSizeValueType::value() +{ + return QVariant(size); +} + +void QmlSizeValueType::setValue(QVariant value) +{ + size = qvariant_cast<QSize>(value); +} + int QmlSizeValueType::width() const { return size.width(); @@ -251,6 +291,16 @@ void QmlRectFValueType::write(QObject *obj, int idx) QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } +QVariant QmlRectFValueType::value() +{ + return QVariant(rect); +} + +void QmlRectFValueType::setValue(QVariant value) +{ + rect = qvariant_cast<QRectF>(value); +} + qreal QmlRectFValueType::x() const { return rect.x(); @@ -308,6 +358,16 @@ void QmlRectValueType::write(QObject *obj, int idx) QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } +QVariant QmlRectValueType::value() +{ + return QVariant(rect); +} + +void QmlRectValueType::setValue(QVariant value) +{ + rect = qvariant_cast<QRect>(value); +} + int QmlRectValueType::x() const { return rect.x(); @@ -365,6 +425,16 @@ void QmlVector3DValueType::write(QObject *obj, int idx) QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } +QVariant QmlVector3DValueType::value() +{ + return QVariant(vector); +} + +void QmlVector3DValueType::setValue(QVariant value) +{ + vector = qvariant_cast<QVector3D>(value); +} + qreal QmlVector3DValueType::x() const { return vector.x(); @@ -412,6 +482,17 @@ void QmlFontValueType::write(QObject *obj, int idx) QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } +QVariant QmlFontValueType::value() +{ + return QVariant(font); +} + +void QmlFontValueType::setValue(QVariant value) +{ + font = qvariant_cast<QFont>(value); +} + + QString QmlFontValueType::family() const { return font.family(); |