summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroute.cpp12
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroute_p.h2
-rw-r--r--tests/auto/declarative_core/tst_routing.qml12
3 files changed, 24 insertions, 2 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeoroute.cpp b/src/location/declarativemaps/qdeclarativegeoroute.cpp
index 95a26a32..0e411361 100644
--- a/src/location/declarativemaps/qdeclarativegeoroute.cpp
+++ b/src/location/declarativemaps/qdeclarativegeoroute.cpp
@@ -321,4 +321,16 @@ QDeclarativeGeoRouteQuery *QDeclarativeGeoRoute::routeQuery()
return routeQuery_;
}
+/*!
+ \qmlmethod bool QtLocation::Route::equals(Route other)
+
+ This method performs deep comparison.
+
+ \since 5.12
+*/
+bool QDeclarativeGeoRoute::equals(QDeclarativeGeoRoute *other) const
+{
+ return route_ == other->route_;
+}
+
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativegeoroute_p.h b/src/location/declarativemaps/qdeclarativegeoroute_p.h
index c19c2674..fa9025d8 100644
--- a/src/location/declarativemaps/qdeclarativegeoroute_p.h
+++ b/src/location/declarativemaps/qdeclarativegeoroute_p.h
@@ -90,6 +90,8 @@ public:
const QGeoRoute &route() const;
QDeclarativeGeoRouteQuery *routeQuery();
+ Q_INVOKABLE bool equals(QDeclarativeGeoRoute *other) const;
+
Q_SIGNALS:
void pathChanged();
diff --git a/tests/auto/declarative_core/tst_routing.qml b/tests/auto/declarative_core/tst_routing.qml
index 5198d87e..f5204f26 100644
--- a/tests/auto/declarative_core/tst_routing.qml
+++ b/tests/auto/declarative_core/tst_routing.qml
@@ -28,8 +28,8 @@
import QtQuick 2.0
import QtTest 1.0
-import QtLocation 5.11
-import QtPositioning 5.2
+import QtLocation 5.12
+import QtPositioning 5.12
Item {
id: root
@@ -608,6 +608,8 @@ Item {
SignalSpy {id: testErrorSlackSpy; target: routeModelSlack; signalName: "errorChanged"}
SignalSpy {id: testPluginSlackSpy; target: routeModelSlack; signalName: "pluginChanged"}
+ RouteModel {id: routeModelEquals; plugin: testPlugin_immediate; query: routeQuery }
+
TestCase {
name: "Routing"
function clear_immediate_model() {
@@ -722,6 +724,7 @@ Item {
compare (routeQuery.waypoints.length, 5)
routeQuery.numberAlternativeRoutes = 1 // how many routes to get back, > 70 indicates error
routeModel.update()
+ routeModelEquals.update()
tryCompare (testRoutesSpy, "count", 1) // 5 sec
tryCompare (testCountSpy, "count", 1)
compare (routeModel.count, 1)
@@ -729,6 +732,11 @@ Item {
compare (routeQuery.waypoints.length, 5)
compare (routeModel.get(0).path.length, 5)
compare (routeModel.get(0).path[0].latitude, routeQuery.waypoints[0].latitude)
+ // test Route.equals
+ var route1 = routeModel.get(0)
+ var route2 = routeModelEquals.get(0)
+ verify(route1 !== route2)
+ verify(route1.equals(route2))
// check reset() functionality
routeModel.reset()
tryCompare (testRoutesSpy, "count", 2) // 5 sec