summaryrefslogtreecommitdiffstats
path: root/src/location/qgeoshape.cpp
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2012-08-16 13:32:43 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-28 10:07:49 +0200
commit059388adce26be48868cd741b4c5d751298fb4d8 (patch)
tree1a8a41c0f280b7ab3c502b49527bd609d1c0884a /src/location/qgeoshape.cpp
parent7dd46f8c96a4bdaca2809ff97b773f358392516f (diff)
Convert GeoShape, GeoRectangle and GeoCircle into QML value types.v5.0.0-beta1
This replaces the GeoShape, GeoRectangle and GeoCircle QML elements with value types. A value type is a better fit for shape types. It is very similar to a rect with some utility functions. Declare QGeoShape, QGeoRectangle and QGeoCircle as movable types. Update documentation. Change-Id: Id6c48e1e841c68f2f0c5c6a9c4a6580a57e2dfb6 Reviewed-by: abcd <amos.choy@nokia.com>
Diffstat (limited to 'src/location/qgeoshape.cpp')
-rw-r--r--src/location/qgeoshape.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/location/qgeoshape.cpp b/src/location/qgeoshape.cpp
index 2c47fdde..c62269e0 100644
--- a/src/location/qgeoshape.cpp
+++ b/src/location/qgeoshape.cpp
@@ -41,6 +41,16 @@
#include "qgeoshape.h"
#include "qgeoshape_p.h"
+#include "qgeorectangle.h"
+#include "qgeocircle.h"
+
+#ifndef QT_NO_DEBUG_STREAM
+#include <QtCore/QDebug>
+#endif
+
+#ifndef QT_NO_DATASTREAM
+#include <QtCore/QDataStream>
+#endif
QT_BEGIN_NAMESPACE
@@ -221,4 +231,77 @@ QGeoShape &QGeoShape::operator=(const QGeoShape &other)
return *this;
}
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QGeoShape &shape)
+{
+ //dbg << *shape.d_func();
+ dbg.nospace() << "QGeoShape(";
+ switch (shape.type()) {
+ case QGeoShape::UnknownType:
+ dbg.nospace() << "Unknown";
+ break;
+ case QGeoShape::RectangleType:
+ dbg.nospace() << "Rectangle";
+ break;
+ case QGeoShape::CircleType:
+ dbg.nospace() << "Circle";
+ }
+
+ dbg.nospace() << ')';
+
+ return dbg;
+}
+#endif
+
+#ifndef QT_NO_DATASTREAM
+QDataStream &operator<<(QDataStream &stream, const QGeoShape &shape)
+{
+ stream << quint32(shape.type());
+ switch (shape.type()) {
+ case QGeoShape::UnknownType:
+ break;
+ case QGeoShape::RectangleType: {
+ QGeoRectangle r = shape;
+ stream << r.topLeft() << r.bottomRight();
+ break;
+ }
+ case QGeoShape::CircleType: {
+ QGeoCircle c = shape;
+ stream << c.center() << c.radius();
+ break;
+ }
+ }
+
+ return stream;
+}
+
+QDataStream &operator>>(QDataStream &stream, QGeoShape &shape)
+{
+ quint32 type;
+ stream >> type;
+
+ switch (type) {
+ case QGeoShape::UnknownType:
+ shape = QGeoShape();
+ break;
+ case QGeoShape::RectangleType: {
+ QGeoCoordinate tl;
+ QGeoCoordinate br;
+ stream >> tl >> br;
+ shape = QGeoRectangle(tl, br);
+ break;
+ }
+ case QGeoShape::CircleType: {
+ QGeoCoordinate c;
+ qreal r;
+ stream >> c >> r;
+ shape = QGeoCircle(c, r);
+ break;
+ }
+ }
+
+ return stream;
+}
+#endif
+
QT_END_NAMESPACE