Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
8
9#include <QtLocation/private/qgeotilespec_p.h>
10
12
13QGeoTiledMapOsm::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
28
29void 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
49void 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 &copy; ");
59 copyRights += mapCopy;
60 }
61 if (!dataCopy.isEmpty()) {
62 if (!copyRights.isEmpty())
63 copyRights += QStringLiteral(" | ");
64 copyRights += QStringLiteral("Data &copy; ");
65 copyRights += dataCopy;
66 }
67 if (!styleCopy.isEmpty()) {
68 if (!copyRights.isEmpty())
69 copyRights += QStringLiteral(" | ");
70 copyRights += QStringLiteral("Style &copy; ");
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
83QT_END_NAMESPACE
void evaluateCopyrights(const QSet< QGeoTileSpec > &visibleTiles) override
Combined button and popup list for selecting options.