mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-26 12:10:49 +01:00
Code cleanup
This commit is contained in:
parent
fd65882907
commit
499461ff76
@ -105,6 +105,12 @@ void MapsforgeMap::updateTransform()
|
|||||||
_bounds.adjust(0.5, 0, -0.5, 0);
|
_bounds.adjust(0.5, 0, -0.5, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MapsforgeMap::key(int zoom, const QPoint &xy) const
|
||||||
|
{
|
||||||
|
return path() + "-" + QString::number(zoom) + "_"
|
||||||
|
+ QString::number(xy.x()) + "_" + QString::number(xy.y());
|
||||||
|
}
|
||||||
|
|
||||||
bool MapsforgeMap::isRunning(int zoom, const QPoint &xy) const
|
bool MapsforgeMap::isRunning(int zoom, const QPoint &xy) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _jobs.size(); i++) {
|
for (int i = 0; i < _jobs.size(); i++) {
|
||||||
@ -139,12 +145,8 @@ void MapsforgeMap::jobFinished(MapsforgeMapJob *job)
|
|||||||
|
|
||||||
for (int i = 0; i < tiles.size(); i++) {
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
const Mapsforge::RasterTile &mt = tiles.at(i);
|
const Mapsforge::RasterTile &mt = tiles.at(i);
|
||||||
if (!mt.isValid())
|
if (mt.isValid())
|
||||||
continue;
|
QPixmapCache::insert(key(mt.zoom(), mt.xy()), mt.pixmap());
|
||||||
|
|
||||||
QString key = path() + "-" + QString::number(mt.zoom()) + "_"
|
|
||||||
+ QString::number(mt.xy().x()) + "_" + QString::number(mt.xy().y());
|
|
||||||
QPixmapCache::insert(key, mt.pixmap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeJob(job);
|
removeJob(job);
|
||||||
@ -178,10 +180,7 @@ void MapsforgeMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
QPixmap pm;
|
QPixmap pm;
|
||||||
QString key = path() + "-" + QString::number(_zoom) + "_"
|
if (QPixmapCache::find(key(_zoom, ttl), &pm))
|
||||||
+ QString::number(ttl.x()) + "_" + QString::number(ttl.y());
|
|
||||||
|
|
||||||
if (QPixmapCache::find(key, &pm))
|
|
||||||
painter->drawPixmap(ttl, pm);
|
painter->drawPixmap(ttl, pm);
|
||||||
else {
|
else {
|
||||||
QList<MapData::Path> paths;
|
QList<MapData::Path> paths;
|
||||||
|
@ -15,14 +15,13 @@ class MapsforgeMapJob : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MapsforgeMapJob(const QList<Mapsforge::RasterTile> &tiles) : _tiles(tiles)
|
MapsforgeMapJob(const QList<Mapsforge::RasterTile> &tiles)
|
||||||
{
|
: _tiles(tiles) {}
|
||||||
connect(&_watcher, &QFutureWatcher<void>::finished, this,
|
|
||||||
&MapsforgeMapJob::handleFinished);
|
|
||||||
}
|
|
||||||
|
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
|
connect(&_watcher, &QFutureWatcher<void>::finished, this,
|
||||||
|
&MapsforgeMapJob::handleFinished);
|
||||||
_future = QtConcurrent::map(_tiles, &Mapsforge::RasterTile::render);
|
_future = QtConcurrent::map(_tiles, &Mapsforge::RasterTile::render);
|
||||||
_watcher.setFuture(_future);
|
_watcher.setFuture(_future);
|
||||||
}
|
}
|
||||||
@ -76,6 +75,7 @@ private slots:
|
|||||||
void jobFinished(MapsforgeMapJob *job);
|
void jobFinished(MapsforgeMapJob *job);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString key(int zoom, const QPoint &xy) const;
|
||||||
Transform transform(int zoom) const;
|
Transform transform(int zoom) const;
|
||||||
void updateTransform();
|
void updateTransform();
|
||||||
bool isRunning(int zoom, const QPoint &xy) const;
|
bool isRunning(int zoom, const QPoint &xy) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user