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
qabstractgeotilecache.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
4
5#include "qgeotilespec_p.h"
6
8
9#include <QDir>
10#include <QStandardPaths>
11#include <QMetaType>
12#include <QPixmap>
13#include <QDebug>
14
16
18 : QObject(parent)
19{
20 qRegisterMetaType<QGeoTileSpec>();
21 qRegisterMetaType<QList<QGeoTileSpec> >();
22 qRegisterMetaType<QSet<QGeoTileSpec> >();
23}
24
28
32
34{
35 qWarning() << "tile request error " << error;
36}
37
42
44{
45 return 0;
46}
47
49{
50 return 0;
51}
52
57
59{
60 return 0;
61}
62
64{
65 return 0;
66}
67
69{
71
72 // Try the shared cache first and use a specific directory. (e.g. ~/.cache/QtLocation)
73 // If this is not supported by the platform, use the application-specific cache
74 // location. (e.g. ~/.cache/<app_name>/QtLocation)
76
77 if (!dir.isEmpty()) {
78 // The shared cache may not be writable when application isolation is enforced.
79 static bool writable = false;
80 static bool writableChecked = false;
81 if (!writableChecked) {
82 writableChecked = true;
83 QDir::root().mkpath(dir);
84 QFile writeTestFile(QDir(dir).filePath(QStringLiteral("qt_cache_check")));
85 writable = writeTestFile.open(QIODevice::WriteOnly);
86 if (writable)
87 writeTestFile.remove();
88 }
89 if (!writable)
90 dir = QString();
91 }
92
93 if (dir.isEmpty())
95
96 if (!dir.endsWith(QLatin1Char('/')))
97 dir += QLatin1Char('/');
98
99 return dir;
100}
101
103{
104 // This scheme allows to have the "tiles" prefix hardcoded here
105 // NOTE: changing the Qt version here requires changing it also in QGeoFileTileCache::init,
106 // in the code that remove old version tiles !
107 return baseCacheDirectory() + QLatin1String("QtLocation/5.8/tiles/");
108}
109
static QString baseCacheDirectory()
virtual void setMaxDiskUsage(int diskUsage)
virtual int diskUsage() const
static QString baseLocationCacheDirectory()
virtual int maxDiskUsage() const
virtual int memoryUsage() const
virtual void setMaxMemoryUsage(int memoryUsage)
virtual void handleError(const QGeoTileSpec &spec, const QString &errorString)
virtual int maxMemoryUsage() const
QAbstractGeoTileCache(QObject *parent=nullptr)
\inmodule QtCore
Definition qdir.h:20
static QDir root()
Returns the root directory.
Definition qdir.h:224
\inmodule QtCore
Definition qfile.h:93
\inmodule QtCore
Definition qobject.h:103
static QString writableLocation(StandardLocation type)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition qstring.cpp:5506
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
#define qWarning
Definition qlogging.h:166
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define QStringLiteral(str)
#define Q_UNUSED(x)
QString dir
[11]
\inmodule QtCore \reentrant
Definition qchar.h:18