From 6c6e384862f2dc896620911f6ff21b3bb2d22e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 1 Dec 2017 21:27:12 +0100 Subject: [PATCH] Some more code cleanup --- src/GUI/mapview.cpp | 34 ++++++++++------------------------ src/GUI/mapview.h | 1 - 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/GUI/mapview.cpp b/src/GUI/mapview.cpp index c11b886c..d0fc1390 100644 --- a/src/GUI/mapview.cpp +++ b/src/GUI/mapview.cpp @@ -273,7 +273,7 @@ void MapView::setMap(Map *map) _map->load(); connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap())); - resetDigitalZoom(); + digitalZoom(0); _map->zoomFit(resolution, center); _scene->setSceneRect(_map->bounds()); @@ -374,31 +374,17 @@ void MapView::clearMapCache() resetCachedContent(); } -void MapView::resetDigitalZoom() -{ - QHash, WaypointItem*>::const_iterator it; - - _digitalZoom = 0; - resetTransform(); - - for (int i = 0; i < _tracks.size(); i++) - _tracks.at(i)->setDigitalZoom(0); - for (int i = 0; i < _routes.size(); i++) - _routes.at(i)->setDigitalZoom(0); - for (int i = 0; i < _waypoints.size(); i++) - _waypoints.at(i)->setDigitalZoom(0); - for (it = _pois.constBegin(); it != _pois.constEnd(); it++) - it.value()->setDigitalZoom(0); - - _mapScale->setDigitalZoom(0); -} - void MapView::digitalZoom(int zoom) { QHash, WaypointItem*>::const_iterator it; - _digitalZoom += zoom; - scale(pow(2, zoom), pow(2, zoom)); + if (zoom) { + _digitalZoom += zoom; + scale(pow(2, zoom), pow(2, zoom)); + } else { + _digitalZoom = 0; + resetTransform(); + } for (int i = 0; i < _tracks.size(); i++) _tracks.at(i)->setDigitalZoom(_digitalZoom); @@ -472,7 +458,7 @@ void MapView::keyPressEvent(QKeyEvent *event) else if (event->matches(ZOOM_OUT)) z = -1; else if (_digitalZoom && event->key() == Qt::Key_Escape) { - resetDigitalZoom(); + digitalZoom(0); return; } else { QGraphicsView::keyPressEvent(event); @@ -575,7 +561,7 @@ void MapView::clear() _rr = RectC(); _wr = RectC(); - resetDigitalZoom(); + digitalZoom(0); resetCachedContent(); QPixmapCache::clear(); } diff --git a/src/GUI/mapview.h b/src/GUI/mapview.h index 089eb6d7..09b47195 100644 --- a/src/GUI/mapview.h +++ b/src/GUI/mapview.h @@ -83,7 +83,6 @@ private: void centerOn(const QPointF &pos); void zoom(int zoom, const QPoint &pos, const Coordinates &c); void digitalZoom(int zoom); - void resetDigitalZoom(); void updatePOIVisibility(); void mouseDoubleClickEvent(QMouseEvent *event);