summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlvaluetype.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-08-05 01:30:54 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-08-05 01:30:54 (GMT)
commitdcb3dc40abc18cedfa0c984a9a6fe693c6b5789c (patch)
treef2af2409a34f7d6c7ef0bece987fce81a527eb1f /src/declarative/qml/qmlvaluetype.cpp
parentbf29e65b9814c1c0ead40876e719462f481468fa (diff)
downloadQt-dcb3dc40abc18cedfa0c984a9a6fe693c6b5789c.zip
Qt-dcb3dc40abc18cedfa0c984a9a6fe693c6b5789c.tar.gz
Qt-dcb3dc40abc18cedfa0c984a9a6fe693c6b5789c.tar.bz2
Fixup QPoint and QRect value types
The floating point and integer point/rect classes are not binary compatible, as change e494fef4cd3fd2dbec273fc48c49f8d15469bc96 assumed.
Diffstat (limited to 'src/declarative/qml/qmlvaluetype.cpp')
-rw-r--r--src/declarative/qml/qmlvaluetype.cpp124
1 files changed, 110 insertions, 14 deletions
diff --git a/src/declarative/qml/qmlvaluetype.cpp b/src/declarative/qml/qmlvaluetype.cpp
index ca968fc..b827572 100644
--- a/src/declarative/qml/qmlvaluetype.cpp
+++ b/src/declarative/qml/qmlvaluetype.cpp
@@ -60,11 +60,13 @@ QmlValueType *QmlValueTypeFactory::valueType(int t)
{
switch (t) {
case QVariant::Point:
- case QVariant::PointF:
return new QmlPointValueType;
+ case QVariant::PointF:
+ return new QmlPointFValueType;
case QVariant::Rect:
- case QVariant::RectF:
return new QmlRectValueType;
+ case QVariant::RectF:
+ return new QmlRectFValueType;
case QVariant::Vector3D:
return new QmlVector3DValueType;
default:
@@ -77,6 +79,43 @@ QmlValueType::QmlValueType(QObject *parent)
{
}
+QmlPointFValueType::QmlPointFValueType(QObject *parent)
+: QmlValueType(parent)
+{
+}
+
+void QmlPointFValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &point, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QmlPointFValueType::write(QObject *obj, int idx)
+{
+ void *a[] = { &point, 0 };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+qreal QmlPointFValueType::x() const
+{
+ return point.x();
+}
+
+qreal QmlPointFValueType::y() const
+{
+ return point.y();
+}
+
+void QmlPointFValueType::setX(qreal x)
+{
+ point.setX(x);
+}
+
+void QmlPointFValueType::setY(qreal y)
+{
+ point.setY(y);
+}
+
QmlPointValueType::QmlPointValueType(QObject *parent)
: QmlValueType(parent)
{
@@ -94,26 +133,83 @@ void QmlPointValueType::write(QObject *obj, int idx)
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
-qreal QmlPointValueType::x() const
+int QmlPointValueType::x() const
{
return point.x();
}
-qreal QmlPointValueType::y() const
+int QmlPointValueType::y() const
{
return point.y();
}
-void QmlPointValueType::setX(qreal x)
+void QmlPointValueType::setX(int x)
{
point.setX(x);
}
-void QmlPointValueType::setY(qreal y)
+void QmlPointValueType::setY(int y)
{
point.setY(y);
}
+QmlRectFValueType::QmlRectFValueType(QObject *parent)
+: QmlValueType(parent)
+{
+}
+
+void QmlRectFValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &rect, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QmlRectFValueType::write(QObject *obj, int idx)
+{
+ void *a[] = { &rect, 0 };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+qreal QmlRectFValueType::x() const
+{
+ return rect.x();
+}
+
+qreal QmlRectFValueType::y() const
+{
+ return rect.y();
+}
+
+void QmlRectFValueType::setX(qreal x)
+{
+ rect.moveLeft(x);
+}
+
+void QmlRectFValueType::setY(qreal y)
+{
+ rect.moveTop(y);
+}
+
+qreal QmlRectFValueType::width() const
+{
+ return rect.width();
+}
+
+qreal QmlRectFValueType::height() const
+{
+ return rect.height();
+}
+
+void QmlRectFValueType::setWidth(qreal w)
+{
+ rect.setWidth(w);
+}
+
+void QmlRectFValueType::setHeight(qreal h)
+{
+ rect.setHeight(h);
+}
+
QmlRectValueType::QmlRectValueType(QObject *parent)
: QmlValueType(parent)
{
@@ -131,42 +227,42 @@ void QmlRectValueType::write(QObject *obj, int idx)
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
-qreal QmlRectValueType::x() const
+int QmlRectValueType::x() const
{
return rect.x();
}
-qreal QmlRectValueType::y() const
+int QmlRectValueType::y() const
{
return rect.y();
}
-void QmlRectValueType::setX(qreal x)
+void QmlRectValueType::setX(int x)
{
rect.moveLeft(x);
}
-void QmlRectValueType::setY(qreal y)
+void QmlRectValueType::setY(int y)
{
rect.moveTop(y);
}
-qreal QmlRectValueType::width() const
+int QmlRectValueType::width() const
{
return rect.width();
}
-qreal QmlRectValueType::height() const
+int QmlRectValueType::height() const
{
return rect.height();
}
-void QmlRectValueType::setWidth(qreal w)
+void QmlRectValueType::setWidth(int w)
{
rect.setWidth(w);
}
-void QmlRectValueType::setHeight(qreal h)
+void QmlRectValueType::setHeight(int h)
{
rect.setHeight(h);
}