10#include <QStandardPaths>
64 QDir baseDir(basePath);
65 if (baseDir.exists()) {
70 for (
const QString&
d : oldCacheDirs) {
72 if (oldCacheDir.exists())
73 oldCacheDir.removeRecursively();
79 qWarning() <<
"Plugin uses uninitialized QGeoFileTileCache directory which was deleted during startup";
83 if (!directoryCreated)
122 for (
int i = 1;
i<=4;
i++) {
127 QList<QSharedPointer<QGeoCachedTileDisk> >
queue;
128 QList<QGeoTileSpec> specs;
133 if (
dir.exists(filename)){
134 files.removeOne(filename);
136 if (spec.
zoom() == -1)
139 tileDisk->filename =
dir.filePath(filename);
140 tileDisk->cache =
this;
141 tileDisk->spec = spec;
144 queue.append(tileDisk);
146 costs.append(fi.size());
162 if (spec.
zoom() == -1)
174 for (
int i = 1;
i<=4;
i++) {
178 qWarning() <<
"Unable to write tile cache file " << filename;
181 QList<QSharedPointer<QGeoCachedTileDisk> >
queue;
183 for (
const QSharedPointer<QGeoCachedTileDisk> &tile :
queue) {
273 for (
const QString &dirFile :
dir.entryList()) {
281 if (k.mapId() == mapId)
284 if (k.mapId() == mapId)
287 if (k.mapId() == mapId)
297 qWarning() <<
"Old tile data detected. Cache eviction left out "<<
files.size() <<
"tiles";
300 if (spec.
mapId() != mapId)
347 QAbstractGeoTileCache::CacheAreas areas)
389 return dir.filePath(filename);
398 if (parts.length() != 2)
413 int value = fields.at(
i).toInt(&
ok);
416 numbers.append(
value);
420 if (numbers.length() < 5)
444 td->filename = filename;
460 td->filename = filename;
517 if (!
image.loadFromData(tm->bytes)) {
519 return QSharedPointer<QGeoTileTexture>();
525 return QSharedPointer<QGeoTileTexture>();
550 if (!
image.loadFromData(bytes)) {
552 return QSharedPointer<QGeoTileTexture>();
565 return QSharedPointer<QGeoTileTexture>();
static QString baseCacheDirectory()
static QString baseLocationCacheDirectory()
virtual void handleError(const QGeoTileSpec &spec, const QString &errorString)
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
void aboutToBeEvicted(const QGeoTileSpec &key, QSharedPointer< QGeoCachedTileDisk > obj)
void aboutToBeRemoved(const QGeoTileSpec &key, QSharedPointer< QGeoCachedTileDisk > obj)
void deserializeQueue(int queueNumber, const QList< Key > &keys, const QList< QSharedPointer< T > > &values, const QList< int > &costs)
bool insert(const Key &key, QSharedPointer< T > object, int cost=1)
void remove(const Key &key, bool force=false)
QSharedPointer< T > object(const Key &key) const
void setMaxCost(int maxCost, int minRecent=-1, int maxOldPopular=-1)
QList< Key > keys() const
void serializeQueue(int queueNumber, QList< QSharedPointer< T > > &buffer)
static QDir root()
Returns the root directory.
bool atEnd() const override
Returns true if the end of the file has been reached; otherwise returns false.
void close() override
Calls QFileDevice::flush() and closes the file.
QString suffix() const
Returns the suffix (extension) of the file.
QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
bool remove()
Removes the file specified by fileName().
QGeoFileTileCache * cache
QGeoFileTileCache * cache
QSharedPointer< QGeoTileTexture > get(const QGeoTileSpec &spec) override
void setMaxMemoryUsage(int memoryUsage) override
CostStrategy costStrategyMemory_
void setMaxDiskUsage(int diskUsage) override
virtual QGeoTileSpec filenameToTileSpec(const QString &filename) const
int minTextureUsage() const override
QCache3Q< QGeoTileSpec, QGeoCachedTileMemory > memoryCache_
void setCostStrategyDisk(CostStrategy costStrategy) override
QSharedPointer< QGeoTileTexture > getFromDisk(const QGeoTileSpec &spec)
CostStrategy costStrategyDisk() const override
QSharedPointer< QGeoTileTexture > addToTextureCache(const QGeoTileSpec &spec, const QImage &image)
int maxDiskUsage() const override
QGeoFileTileCache(const QString &directory=QString(), QObject *parent=nullptr)
CostStrategy costStrategyTexture() const override
static void evictFromMemoryCache(QGeoCachedTileMemory *tm)
QCache3Q< QGeoTileSpec, QGeoTileTexture > textureCache_
void setCostStrategyTexture(CostStrategy costStrategy) override
int diskUsage() const override
void addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format)
CostStrategy costStrategyDisk_
QString directory() const
void setExtraTextureUsage(int textureUsage) override
int maxMemoryUsage() const override
void clearMapId(int mapId)
virtual bool isTileBogus(const QByteArray &bytes) const
static QString tileSpecToFilenameDefault(const QGeoTileSpec &spec, const QString &format, const QString &directory)
void setMinTextureUsage(int textureUsage) override
void insert(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format, QAbstractGeoTileCache::CacheAreas areas=QAbstractGeoTileCache::AllCaches) override
void setCostStrategyMemory(CostStrategy costStrategy) override
int textureUsage() const override
int maxTextureUsage() const override
static void evictFromDiskCache(QGeoCachedTileDisk *td)
virtual QString tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory) const
QCache3Q< QGeoTileSpec, QGeoCachedTileDisk, QCache3QTileEvictionPolicy > diskCache_
CostStrategy costStrategyMemory() const override
QSharedPointer< QGeoCachedTileDisk > addToDiskCache(const QGeoTileSpec &spec, const QString &filename)
QSharedPointer< QGeoTileTexture > getFromMemory(const QGeoTileSpec &spec)
int memoryUsage() const override
CostStrategy costStrategyTexture_
void printStats() override
static QGeoTileSpec filenameToTileSpecDefault(const QString &filename)
qint64 readLine(char *data, qint64 maxlen)
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes,...
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
@ Format_ARGB32_Premultiplied
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
QString mid(qsizetype position, qsizetype n=-1) const &
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
const QChar * constData() const
Returns a pointer to the data stored in the QString.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
qsizetype length() const noexcept
Returns the number of characters in this string.
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum format
static qsizetype cost(const QPixmap &pixmap)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
\inmodule QtCore \reentrant