summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2016-08-09 13:16:49 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-01-31 09:33:41 +0000
commit9ef81d240ad8d27ea482f9a15d2647a6eee1f7f2 (patch)
tree63d54d6010fe0e34faeb93ca40f8d17044f254c1 /tests
parentd7936f74bda527a85d69e7d1c412d79ee952d139 (diff)
downloadqtlocation-9ef81d240ad8d27ea482f9a15d2647a6eee1f7f2.tar.gz
Allow to create maps with groups of map items
This patch lets a user create an external qml file, and put multiple map items inside a parent MapItemGroup{}, and add that element to a Map item. QDeclarativeGeoMap gets also two associated methods: addMapItemGroup and removeMapItemGroup to deal with item groups at runtime. Additionally, clearMapItems now clears also added item groups. Task-number: QTBUG-55211 Change-Id: Ie4e602e4bda65fb56422b721be5fd34c54eb7954 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative_ui/ItemGroup.qml62
-rw-r--r--tests/auto/declarative_ui/declarative_ui.pro3
-rw-r--r--tests/auto/declarative_ui/tst_map_item.qml10
3 files changed, 74 insertions, 1 deletions
diff --git a/tests/auto/declarative_ui/ItemGroup.qml b/tests/auto/declarative_ui/ItemGroup.qml
new file mode 100644
index 00000000..57108ec7
--- /dev/null
+++ b/tests/auto/declarative_ui/ItemGroup.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtPositioning 5.6
+import QtLocation 5.9
+import QtLocation.Test 5.6
+
+MapItemGroup {
+ id: itemGroup
+ property double latitude : (mainRectangle.topLeft.latitude + mainRectangle.bottomRight.latitude) / 2.0
+ property double longitude: (mainRectangle.topLeft.longitude + mainRectangle.bottomRight.longitude) / 2.0
+ property double radius: 100 * 1000
+
+ MapRectangle {
+ id: mainRectangle
+ topLeft: QtPositioning.coordinate(43, -3)
+ bottomRight: QtPositioning.coordinate(37, 3)
+ opacity: 0.05
+ visible: true
+ color: 'blue'
+ }
+
+ MapCircle {
+ id: groupCircle
+ center: QtPositioning.coordinate(parent.latitude, parent.longitude)
+ radius: parent.radius
+ color: 'crimson'
+ }
+
+ MapRectangle {
+ id: groupRectangle
+ topLeft: QtPositioning.coordinate(parent.latitude + 5, parent.longitude - 5)
+ bottomRight: QtPositioning.coordinate(parent.latitude, parent.longitude )
+ color: 'yellow'
+ }
+}
diff --git a/tests/auto/declarative_ui/declarative_ui.pro b/tests/auto/declarative_ui/declarative_ui.pro
index d3a2f08e..6734b1f9 100644
--- a/tests/auto/declarative_ui/declarative_ui.pro
+++ b/tests/auto/declarative_ui/declarative_ui.pro
@@ -16,3 +16,6 @@ TESTDATA = $$OTHER_FILES
# Import path used by 'make check' since CI doesn't install test imports
IMPORTPATH = $$OUT_PWD/../../../qml
+
+DISTFILES += \
+ ItemGroup.qml
diff --git a/tests/auto/declarative_ui/tst_map_item.qml b/tests/auto/declarative_ui/tst_map_item.qml
index 8ede357f..b75daf38 100644
--- a/tests/auto/declarative_ui/tst_map_item.qml
+++ b/tests/auto/declarative_ui/tst_map_item.qml
@@ -28,7 +28,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtLocation 5.6
+import QtLocation 5.9
import QtPositioning 5.5
import QtLocation.Test 5.6
@@ -75,6 +75,10 @@ Item {
}
Item { id: someItem }
+ ItemGroup {
+ id: itemGroup1
+ }
+
MapCircle {
id: extMapCircle
center {
@@ -403,6 +407,10 @@ Item {
mouseClick(map, map.width + 5, point.y + 5)
tryCompare(extMapQuickItemClicked, "count", 1)
map.removeMapItem(extMapQuickItem)
+
+ var numItemsOnMap = map.mapItems.length
+ map.addMapItemGroup( itemGroup1 )
+ compare(map.mapItems.length, numItemsOnMap + 3)
}
function test_drag()