1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the test suite of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#include "qgeotiledmap_test.h"
30#include <QtLocation/private/qgeotiledmap_p_p.h>
31#include <QtLocation/private/qgeomapparameter_p.h>
32
33QT_USE_NAMESPACE
34
35class QGeoTiledMapTestPrivate: public QGeoTiledMapPrivate
36{
37 Q_DECLARE_PUBLIC(QGeoTiledMapTest)
38public:
39 QGeoTiledMapTestPrivate(QGeoTiledMappingManagerEngine *engine,
40 const QGeoTiledMapTestOptions &options)
41 : QGeoTiledMapPrivate(engine), m_options(options)
42 {
43
44 }
45
46 ~QGeoTiledMapTestPrivate()
47 {
48
49 }
50
51 void addParameter(QGeoMapParameter *param) override
52 {
53 Q_Q(QGeoTiledMapTest);
54 if (param->type() == QStringLiteral("cameraCenter_test")) {
55 // We assume that cameraCenter_test parameters have a QGeoCoordinate property named "center"
56 // Handle the parameter
57 QGeoCameraData cameraData = m_cameraData;
58 QGeoCoordinate newCenter = param->property(name: "center").value<QGeoCoordinate>();
59 cameraData.setCenter(newCenter);
60 q->setCameraData(cameraData);
61 // Connect for further changes handling
62 q->connect(sender: param, SIGNAL(propertyUpdated(QGeoMapParameter *, const char *)),
63 receiver: q, SLOT(onCameraCenter_testChanged(QGeoMapParameter*, const char*)));
64
65 }
66 }
67 void removeParameter(QGeoMapParameter *param) override
68 {
69 Q_Q(QGeoTiledMapTest);
70 param->disconnect(receiver: q);
71 }
72
73 virtual void setVisibleArea(const QRectF &visibleArea) override
74 {
75 if (m_options.supportVisibleArea)
76 return QGeoTiledMapPrivate::setVisibleArea(visibleArea);
77 else
78 return QGeoMapPrivate::setVisibleArea(visibleArea);
79 }
80
81 virtual QRectF visibleArea() const override
82 {
83 if (m_options.supportVisibleArea)
84 return QGeoTiledMapPrivate::visibleArea();
85 else
86 return QGeoMapPrivate::visibleArea();
87 }
88
89 QGeoTiledMapTestOptions m_options;
90};
91
92QGeoTiledMapTest::QGeoTiledMapTest(QGeoTiledMappingManagerEngine *engine,
93 const QGeoTiledMapTestOptions &options,
94 QObject *parent)
95: QGeoTiledMap(*new QGeoTiledMapTestPrivate(engine, options), engine, parent), m_engine(engine)
96{
97}
98
99void QGeoTiledMapTest::onCameraCenter_testChanged(QGeoMapParameter *param, const char *propertyName)
100{
101 if (strcmp(s1: propertyName, s2: "center") == 0) {
102 QGeoCameraData cameraData = this->cameraData();
103 // Not testing for propertyName as this param has only one allowed property
104 QGeoCoordinate newCenter = param->property(name: propertyName).value<QGeoCoordinate>();
105 cameraData.setCenter(newCenter);
106 setCameraData(cameraData);
107 }
108}
109

source code of qtlocation/tests/auto/geotestplugin/qgeotiledmap_test.cpp