1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-27 03:29:16 +02:00

Added support for tiles cache clearing

This commit is contained in:
2016-04-01 19:25:34 +02:00
parent 9fa031ca4d
commit f247c2fa22
6 changed files with 174 additions and 125 deletions

View File

@ -238,9 +238,13 @@ void GUI::createActions()
_showMapAction->setCheckable(true);
_showMapAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
connect(_showMapAction, SIGNAL(triggered(bool)), this, SLOT(showMap(bool)));
if (_maps.empty())
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
connect(_clearMapCacheAction, SIGNAL(triggered()), this,
SLOT(clearMapCache()));
if (_maps.empty()) {
_showMapAction->setEnabled(false);
else {
_clearMapCacheAction->setEnabled(false);
} else {
createMapActions();
_showMapAction->setChecked(true);
}
@ -307,6 +311,8 @@ void GUI::createMenus()
_mapMenu = menuBar()->addMenu(tr("Map"));
_mapMenu->addActions(_mapActions);
_mapMenu->addSeparator();
_mapMenu->addAction(_clearMapCacheAction);
_mapMenu->addSeparator();
_mapMenu->addAction(_showMapAction);
_poiMenu = menuBar()->addMenu(tr("POI"));
@ -738,6 +744,12 @@ void GUI::showToolbars(bool checked)
}
}
void GUI::clearMapCache()
{
_currentMap->clearCache();
_track->redraw();
}
void GUI::updateStatusBarInfo()
{
if (_files.count() == 0) {

View File

@ -45,6 +45,7 @@ private slots:
void showMap(bool checked);
void showGraphs(bool checked);
void showToolbars(bool checked);
void clearMapCache();
void mapChanged(int);
void graphChanged(int);
@ -114,6 +115,7 @@ private:
QAction *_closePOIAction;
QAction *_showPOIAction;
QAction *_showMapAction;
QAction *_clearMapCacheAction;
QAction *_showGraphsAction;
QAction *_showToolbarsAction;
QAction *_nextAction;

View File

@ -5,6 +5,8 @@
#include "config.h"
#include "map.h"
#include <QDebug>
Map::Map(QObject *parent, const QString &name, const QString &url)
: QObject(parent)
@ -16,7 +18,7 @@ Map::Map(QObject *parent, const QString &name, const QString &url)
SLOT(emitLoaded()));
QString path = TILES_DIR + QString("/") + _name;
if (!QDir::home().mkpath(path))
if (!QDir().mkpath(path))
fprintf(stderr, "Error creating tiles dir: %s\n", qPrintable(path));
}
@ -54,3 +56,13 @@ void Map::loadTiles(QList<Tile> &list)
if (!dl.empty())
Downloader::instance().get(dl);
}
void Map::clearCache()
{
QString path = TILES_DIR + QString("/") + _name;
QDir dir = QDir(path);
QStringList list = dir.entryList();
for (int i = 0; i < list.count(); i++)
dir.remove(list.at(i));
}

View File

@ -24,15 +24,16 @@ class Map : public QObject
{
Q_OBJECT
signals:
void loaded();
public:
Map(QObject *parent = 0, const QString &name = QString(),
const QString &url = QString());
const QString &name() const {return _name;}
void loadTiles(QList<Tile> &list);
void clearCache();
signals:
void loaded();
private slots:
void emitLoaded();

View File

@ -42,8 +42,6 @@ public:
public slots:
void movePositionMarker(qreal val);
private slots:
void redraw();
private: