summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--src/declarative/qml/qmlvaluetype.cpp124
-rw-r--r--src/declarative/qml/qmlvaluetype_p.h55
2 files changed, 161 insertions, 18 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);
}
diff --git a/src/declarative/qml/qmlvaluetype_p.h b/src/declarative/qml/qmlvaluetype_p.h
index 9195c61..0c9e279 100644
--- a/src/declarative/qml/qmlvaluetype_p.h
+++ b/src/declarative/qml/qmlvaluetype_p.h
@@ -80,13 +80,13 @@ public:
QmlValueType *operator[](int idx) const { return valueTypes[idx]; }
};
-class QmlPointValueType : public QmlValueType
+class QmlPointFValueType : public QmlValueType
{
Q_PROPERTY(qreal x READ x WRITE setX);
Q_PROPERTY(qreal y READ y WRITE setY);
Q_OBJECT
public:
- QmlPointValueType(QObject *parent = 0);
+ QmlPointFValueType(QObject *parent = 0);
virtual void read(QObject *, int);
virtual void write(QObject *, int);
@@ -100,7 +100,27 @@ private:
QPointF point;
};
-class QmlRectValueType : public QmlValueType
+class QmlPointValueType : public QmlValueType
+{
+ Q_PROPERTY(int x READ x WRITE setX);
+ Q_PROPERTY(int y READ y WRITE setY);
+ Q_OBJECT
+public:
+ QmlPointValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int);
+
+ int x() const;
+ int y() const;
+ void setX(int);
+ void setY(int);
+
+private:
+ QPoint point;
+};
+
+class QmlRectFValueType : public QmlValueType
{
Q_PROPERTY(qreal x READ x WRITE setX);
Q_PROPERTY(qreal y READ y WRITE setY);
@@ -108,7 +128,7 @@ class QmlRectValueType : public QmlValueType
Q_PROPERTY(qreal height READ height WRITE setHeight);
Q_OBJECT
public:
- QmlRectValueType(QObject *parent = 0);
+ QmlRectFValueType(QObject *parent = 0);
virtual void read(QObject *, int);
virtual void write(QObject *, int);
@@ -127,6 +147,33 @@ private:
QRectF rect;
};
+class QmlRectValueType : public QmlValueType
+{
+ Q_PROPERTY(int x READ x WRITE setX);
+ Q_PROPERTY(int y READ y WRITE setY);
+ Q_PROPERTY(int width READ width WRITE setWidth);
+ Q_PROPERTY(int height READ height WRITE setHeight);
+ Q_OBJECT
+public:
+ QmlRectValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int);
+
+ int x() const;
+ int y() const;
+ void setX(int);
+ void setY(int);
+
+ int width() const;
+ int height() const;
+ void setWidth(int);
+ void setHeight(int);
+
+private:
+ QRect rect;
+};
+
class QmlVector3DValueType : public QmlValueType
{
Q_PROPERTY(qreal x READ x WRITE setX);