Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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 */
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");
49
51
52 m_copyrightsSlab = QImage(m_logo.width() + textBounds.width() + spaceToLogo + blurRate * 2,
53 qMax(m_logo.height(), textBounds.height() + blurRate * 2),
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);
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(),
66 copyrightsString);
67 }
68 }
70 painter.drawText(0, 0, textBounds.width(), m_copyrightsSlab.height(),
72 copyrightsString);
73 painter.end();
74
75 m_lastCopyrightsString = copyrightsString;
76 }
77
78 emit copyrightsImageChanged(m_copyrightsSlab);
79}
80
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\reentrant \inmodule QtGui
QRect boundingRect(QChar) const
Returns the rectangle that is covered by ink if character ch were to be drawn at the origin of the co...
\reentrant
Definition qfont.h:22
@ SansSerif
Definition qfont.h:26
void setPixelSize(int)
Sets the font size to pixelSize pixels, with a maxiumum size of an unsigned 16-bit integer.
Definition qfont.cpp:1049
void setStyleHint(StyleHint, StyleStrategy=PreferDefault)
Sets the style hint and strategy to hint and strategy, respectively.
Definition qfont.cpp:1505
@ Bold
Definition qfont.h:70
void setWeight(Weight weight)
Sets the weight of the font to weight, using the scale defined by \l QFont::Weight enumeration.
Definition qfont.cpp:1205
QGeoMapType activeMapType() const
Definition qgeomap.cpp:128
void copyrightsImageChanged(const QImage &copyrightsImage)
const QGeoCameraData & cameraData() const
Definition qgeomap.cpp:111
int viewportHeight() const
Definition qgeomap.cpp:45
int viewportWidth() const
Definition qgeomap.cpp:39
QGeoTiledMapNokia(QGeoTiledMappingManagerEngineNokia *engine, QObject *parent=nullptr)
void evaluateCopyrights(const QSet< QGeoTileSpec > &visibleTiles) override
QString evaluateCopyrightsText(const QGeoMapType &mapType, qreal zoomLevel, const QSet< QGeoTileSpec > &tiles)
\inmodule QtGui
Definition qimage.h:37
int width() const
Returns the width of the image.
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition qimage.cpp:1222
int height() const
Returns the height of the image.
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
void fill(uint pixel)
Fills the entire image with the given pixelValue.
Definition qimage.cpp:1758
\inmodule QtCore
Definition qobject.h:103
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Draws the rectangular portion source of the given image into the target rectangle in the paint device...
void setFont(const QFont &f)
Sets the painter's font to the given font.
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position.
bool end()
Ends painting.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
\inmodule QtCore\reentrant
Definition qpoint.h:25
bool isNull() const noexcept
Definition qpointer.h:84
\inmodule QtCore\reentrant
Definition qrect.h:30
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
@ AlignBottom
Definition qnamespace.h:154
@ AlignLeft
Definition qnamespace.h:144
@ TextWordWrap
Definition qnamespace.h:174
@ white
Definition qnamespace.h:31
@ transparent
Definition qnamespace.h:47
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLint GLint GLint GLint GLint x
[0]
GLenum GLsizeiptr fontSize
GLint y
#define emit
QPainter painter(this)
[7]
QJSEngine engine
[0]