Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qgeotiledmaposm.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 Aaron McCarthy <mccarthy.aaron@gmail.com>
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qgeotiledmaposm.h"
6
#
include
"qgeotiledmappingmanagerengineosm.h"
7
#
include
"qgeotilefetcherosm.h"
8
9
#
include
<
QtLocation
/
private
/
qgeotilespec_p
.
h
>
10
11
QT_BEGIN_NAMESPACE
12
13
QGeoTiledMapOsm
::
QGeoTiledMapOsm
(QGeoTiledMappingManagerEngineOsm *engine, QObject *parent)
14
: Map(engine, parent), m_mapId(-1), m_engine(engine)
15
{
16
// Needed because evaluateCopyrights() is only triggered if visible tiles change in the map.
17
// It fails the first time it gets called if providers aren't resolved, and subsequent calls
18
// to it will be skipped until visible tiles change.
19
// This connection makes sure the copyrights are evaluated when copyright data are ready regardless
20
// of what tiles are visible.
21
connect(qobject_cast<QGeoTileFetcherOsm *>(engine->tileFetcher()), &QGeoTileFetcherOsm::providerDataUpdated,
22
this
, &QGeoTiledMapOsm::onProviderDataUpdated);
23
}
24
25
QGeoTiledMapOsm
::~
QGeoTiledMapOsm
()
26
{
27
}
28
29
void
QGeoTiledMapOsm
::
evaluateCopyrights
(
const
QSet<QGeoTileSpec> &visibleTiles)
30
{
31
if
(visibleTiles.isEmpty())
32
return
;
33
34
QGeoTileSpec tile = *visibleTiles.constBegin();
35
if
(tile.mapId() == m_mapId)
36
return
;
37
38
int
providerId = tile.mapId() - 1;
39
if
(providerId < 0 || providerId >= m_engine->providers().size())
40
return
;
41
42
m_mapId = tile.mapId();
43
if
(!m_engine->providers().at(providerId)->isValid())
44
return
;
45
46
onProviderDataUpdated(m_engine->providers().at(providerId));
47
}
48
49
void
QGeoTiledMapOsm
::onProviderDataUpdated(
const
QGeoTileProviderOsm
*provider)
50
{
51
if
(!provider
->
isResolved
(
)
|| provider->mapType().mapId() != m_mapId)
52
return
;
53
QString copyRights;
54
const
QString mapCopy = provider->mapCopyRight();
55
const
QString dataCopy = provider->dataCopyRight();
56
const
QString styleCopy = provider->styleCopyRight();
57
if
(!mapCopy.isEmpty()) {
58
copyRights += QStringLiteral(
"Map © "
);
59
copyRights += mapCopy;
60
}
61
if
(!dataCopy.isEmpty()) {
62
if
(!copyRights.isEmpty())
63
copyRights += QStringLiteral(
" | "
);
64
copyRights += QStringLiteral(
"Data © "
);
65
copyRights += dataCopy;
66
}
67
if
(!styleCopy.isEmpty()) {
68
if
(!copyRights.isEmpty())
69
copyRights += QStringLiteral(
" | "
);
70
copyRights += QStringLiteral(
"Style © "
);
71
copyRights += styleCopy;
72
}
73
74
if
(copyRights.isEmpty() && provider->mapType().style() == QGeoMapType::CustomMap)
75
copyRights = m_engine->customCopyright();
76
77
// Update CameraCapabilities
78
setCameraCapabilities(provider->cameraCapabilities());
79
80
emit copyrightsChanged(copyRights);
81
}
82
83
QT_END_NAMESPACE
QGeoTileProviderOsm
Definition
qgeotileproviderosm.h:101
QGeoTileProviderOsm::isResolved
bool isResolved() const
Definition
qgeotileproviderosm.cpp:135
QGeoTiledMapOsm
Definition
qgeotiledmaposm.h:17
QGeoTiledMapOsm::evaluateCopyrights
void evaluateCopyrights(const QSet< QGeoTileSpec > &visibleTiles) override
Definition
qgeotiledmaposm.cpp:29
QGeoTiledMapOsm::~QGeoTiledMapOsm
~QGeoTiledMapOsm()
Definition
qgeotiledmaposm.cpp:25
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtlocation
src
plugins
geoservices
osm
qgeotiledmaposm.cpp
Generated on
for Qt by
1.18.0