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
qgeofiletilecachenokia.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 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
4
#
include
"qgeofiletilecachenokia.h"
5
#
include
<
QtLocation
/
private
/
qgeotilespec_p
.
h
>
6
#
include
<
QDir
>
7
8
QT_BEGIN_NAMESPACE
9
10
QGeoFileTileCacheNokia::QGeoFileTileCacheNokia(
int
ppi,
const
QString &directory, QObject *parent)
11
:QGeoFileTileCache(directory, parent)
12
{
13
m_ppi = QString::number(ppi) + QLatin1String(
"p"
);
14
}
15
16
QGeoFileTileCacheNokia::~QGeoFileTileCacheNokia()
17
{
18
19
}
20
21
QString QGeoFileTileCacheNokia::tileSpecToFilename(
const
QGeoTileSpec &spec,
const
QString &format,
const
QString &directory)
const
22
{
23
QString filename = spec.plugin();
24
filename += QLatin1String(
"-"
);
25
filename += QString::number(spec.mapId());
26
filename += QLatin1String(
"-"
);
27
filename += QString::number(spec.zoom());
28
filename += QLatin1String(
"-"
);
29
filename += QString::number(spec.x());
30
filename += QLatin1String(
"-"
);
31
filename += QString::number(spec.y());
32
33
//Append version if real version number to ensure backwards compatibility and eviction of old tiles
34
if
(spec.version() != -1) {
35
filename += QLatin1String(
"-"
);
36
filename += QString::number(spec.version());
37
}
38
39
filename += QLatin1String(
"-"
);
40
filename += m_ppi;
41
42
filename += QLatin1String(
"."
);
43
filename += format;
44
45
QDir dir = QDir(directory);
46
47
return
dir.filePath(filename);
48
}
49
50
QGeoTileSpec QGeoFileTileCacheNokia::filenameToTileSpec(
const
QString &filename)
const
51
{
52
QGeoTileSpec emptySpec;
53
54
const
QStringList parts = filename.split(
'.'
);
55
56
if
(parts.length() != 2)
57
return
emptySpec;
58
59
const
QString name = parts.at(0);
60
const
QStringList fields = name.split(
'-'
);
61
62
const
qsizetype length = fields.length();
63
if
(length != 6 && length != 7)
64
return
emptySpec;
65
else
if
(fields.last() != m_ppi)
66
return
QGeoTileSpec();
67
68
QList<
int
> numbers;
69
70
bool
ok =
false
;
71
for
(qsizetype i = 1; i < length-1; ++i) {
// skipping -<ppi>
72
ok =
false
;
73
int
value = fields.at(i).toInt(&ok);
74
if
(!ok)
75
return
emptySpec;
76
numbers.append(value);
77
}
78
79
//File name without version, append default
80
if
(numbers.length() < 5)
81
numbers.append(-1);
82
83
return
QGeoTileSpec(fields.at(0),
84
numbers.at(0),
85
numbers.at(1),
86
numbers.at(2),
87
numbers.at(3),
88
numbers.at(4));
89
}
90
91
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtlocation
src
plugins
geoservices
nokia
qgeofiletilecachenokia.cpp
Generated on
for Qt by
1.18.0