1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtLocation module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL3$
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 http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or later as published by the Free
28 ** Software Foundation and appearing in the file LICENSE.GPL included in
29 ** the packaging of this file. Please review the following information to
30 ** ensure the GNU General Public License version 2.0 requirements will be
31 ** met: http://www.gnu.org/licenses/gpl-2.0.html.
32 **
33 ** $QT_END_LICENSE$
34 **
35 ****************************************************************************/
36 
37 #include "qgeomappingmanager_p.h"
38 #include "qgeomappingmanager_p_p.h"
39 #include "qgeomappingmanagerengine_p.h"
40 #include "qgeotiledmapreply_p.h"
41 #include "qgeocameracapabilities_p.h"
42 
43 
44 #include "qgeomap_p.h"
45 
46 #include <QTimer>
47 #include <QLocale>
48 
49 QT_BEGIN_NAMESPACE
50 
51 /*!
52     \class QGeoMappingManager
53     \inmodule QtLocation
54     \ingroup QtLocation-maps
55     \since 5.6
56     \internal
57 
58     \brief The QGeoMappingManager class provides support for displaying
59     and interacting with maps.
60 */
61 
62 /*!
63     Constructs a new manager with the specified \a parent and with the
64     implementation provided by \a engine.
65 
66     This constructor is used internally by QGeoServiceProviderFactory. Regular
67     users should acquire instances of QGeoMappingManager with
68     QGeoServiceProvider::mappingManager()
69 */
QGeoMappingManager(QGeoMappingManagerEngine * engine,QObject * parent)70 QGeoMappingManager::QGeoMappingManager(QGeoMappingManagerEngine *engine, QObject *parent)
71     : QObject(parent),
72       d_ptr(new QGeoMappingManagerPrivate)
73 {
74     d_ptr->engine = engine;
75     if (!d_ptr->engine) {
76         qFatal("The mapping manager engine that was set for this mapping manager was NULL.");
77     }
78 
79     connect(d_ptr->engine,
80             SIGNAL(initialized()),
81             this,
82             SIGNAL(initialized()),
83             Qt::QueuedConnection);
84 
85     connect(d_ptr->engine,
86             SIGNAL(supportedMapTypesChanged()),
87             this,
88             SIGNAL(supportedMapTypesChanged()),
89             Qt::QueuedConnection);
90 }
91 
92 /*!
93     Destroys this mapping manager.
94 */
~QGeoMappingManager()95 QGeoMappingManager::~QGeoMappingManager()
96 {
97     delete d_ptr;
98 }
99 
100 /*!
101     \fn void QGeoMappingManager::initialized()
102 
103     This signal is emitted when the mapping manager has been initialized
104     and is ready to be used.
105 */
106 
107 /*!
108     Returns the name of the engine which implements the behaviour of this
109     mapping manager.
110 
111     The combination of managerName() and managerVersion() should be unique
112     amongst the plugin implementations.
113 */
managerName() const114 QString QGeoMappingManager::managerName() const
115 {
116     return d_ptr->engine->managerName();
117 }
118 
119 /*!
120     Returns the version of the engine which implements the behaviour of this
121     mapping manager.
122 
123     The combination of managerName() and managerVersion() should be unique
124     amongst the plugin implementations.
125 */
managerVersion() const126 int QGeoMappingManager::managerVersion() const
127 {
128     return d_ptr->engine->managerVersion();
129 }
130 
131 /*!
132     Returns a new QGeoMap instance which will be managed by this manager.
133 */
createMap(QObject * parent)134 QGeoMap *QGeoMappingManager::createMap(QObject *parent)
135 {
136     Q_UNUSED(parent);
137     return d_ptr->engine->createMap();
138 }
139 
supportedMapTypes() const140 QList<QGeoMapType> QGeoMappingManager::supportedMapTypes() const
141 {
142     return d_ptr->engine->supportedMapTypes();
143 }
144 
145 /*!
146     Return whether the manager has been initialized
147     (will be done automatically but may take some time).
148 
149 */
isInitialized() const150 bool QGeoMappingManager::isInitialized() const
151 {
152     return d_ptr->engine->isInitialized();
153 }
154 
155 /*!
156     Sets the locale to be used by the this manager to \a locale.
157 
158     If this mapping manager supports returning map labels
159     in different languages, they will be returned in the language of \a locale.
160 
161     The locale used defaults to the system locale if this is not set.
162 */
setLocale(const QLocale & locale)163 void QGeoMappingManager::setLocale(const QLocale &locale)
164 {
165     d_ptr->engine->setLocale(locale);
166 }
167 
168 /*!
169     Returns the locale used to hint to this mapping manager about what
170     language to use for map labels.
171 */
locale() const172 QLocale QGeoMappingManager::locale() const
173 {
174     return d_ptr->engine->locale();
175 }
176 
177 /*******************************************************************************
178 *******************************************************************************/
179 
QGeoMappingManagerPrivate()180 QGeoMappingManagerPrivate::QGeoMappingManagerPrivate()
181     : engine(0) {}
182 
~QGeoMappingManagerPrivate()183 QGeoMappingManagerPrivate::~QGeoMappingManagerPrivate()
184 {
185     delete engine;
186     engine = 0;
187 }
188 
189 QT_END_NAMESPACE
190