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
qgeotiledmap_nokia.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6
7#include <QDebug>
8#include <QObject>
9#include <QColor>
10#include <QFont>
11#include <QPainter>
12#include <QImage>
13#include <QRect>
14
15#include <QStaticText>
16
17#include <QtLocation/private/qgeocameradata_p.h>
18
20
21/*
22 Constructs a new tiled map data object, which stores the map data required by
23 \a geoMap and makes use of the functionality provided by \a engine.
24 */
25QGeoTiledMapNokia::QGeoTiledMapNokia(QGeoTiledMappingManagerEngineNokia *engine, QObject *parent /*= 0*/) :
26 Map(engine, parent),
27 m_logo(":/nokia/logo.png"), // HERE logo image
28 m_engine(engine)
29{}
30
32
33void QGeoTiledMapNokia::evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles)
34{
35 const int spaceToLogo = 4;
36 const int blurRate = 1;
37 const int fontSize = 10;
38
39 if (m_engine.isNull())
40 return;
41
42 const QString copyrightsString = m_engine->evaluateCopyrightsText(activeMapType(), cameraData().zoomLevel(), visibleTiles);
43
44 if (viewportWidth() > 0 && viewportHeight() > 0 && ((copyrightsString.isNull() && m_copyrightsSlab.isNull()) || copyrightsString != m_lastCopyrightsString)) {
45 QFont font("Sans Serif");
46 font.setPixelSize(fontSize);
47 font.setStyleHint(QFont::SansSerif);
48 font.setWeight(QFont::Bold);
49
50 QRect textBounds = QFontMetrics(font).boundingRect(0, 0, viewportWidth(), viewportHeight(), Qt::AlignBottom | Qt::AlignLeft | Qt::TextWordWrap, copyrightsString);
51
52 m_copyrightsSlab = QImage(m_logo.width() + textBounds.width() + spaceToLogo + blurRate * 2,
53 qMax(m_logo.height(), textBounds.height() + blurRate * 2),
54 QImage::Format_ARGB32_Premultiplied);
55 m_copyrightsSlab.fill(Qt::transparent);
56
57 QPainter painter(&m_copyrightsSlab);
58 painter.drawImage(QPoint(0, m_copyrightsSlab.height() - m_logo.height()), m_logo);
59 painter.setFont(font);
60 painter.setPen(QColor(0, 0, 0, 64));
61 painter.translate(spaceToLogo + m_logo.width(), -blurRate);
62 for (int x=-blurRate; x<=blurRate; ++x) {
63 for (int y=-blurRate; y<=blurRate; ++y) {
64 painter.drawText(x, y, textBounds.width(), m_copyrightsSlab.height(),
65 Qt::AlignBottom | Qt::AlignLeft | Qt::TextWordWrap,
66 copyrightsString);
67 }
68 }
69 painter.setPen(Qt::white);
70 painter.drawText(0, 0, textBounds.width(), m_copyrightsSlab.height(),
71 Qt::AlignBottom | Qt::AlignLeft | Qt::TextWordWrap,
72 copyrightsString);
73 painter.end();
74
75 m_lastCopyrightsString = copyrightsString;
76 }
77
78 emit copyrightsImageChanged(m_copyrightsSlab);
79}
80
81QT_END_NAMESPACE
void evaluateCopyrights(const QSet< QGeoTileSpec > &visibleTiles) override