From bd20d40ba7d29be4bb8852f73acc2d8b2cf6da66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 20 Aug 2017 10:49:58 +0200 Subject: [PATCH] Fixed content margin computation. Code cleanup. --- src/pathview.cpp | 12 ++++++------ src/pathview.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pathview.cpp b/src/pathview.cpp index 998de694..11f48e87 100644 --- a/src/pathview.cpp +++ b/src/pathview.cpp @@ -144,7 +144,7 @@ void PathView::addWaypoints(const QList &waypoints) QList PathView::loadData(const Data &data) { QList paths; - qreal scale = _map->zoom(); + qreal zoom = _map->zoom(); for (int i = 0; i < data.tracks().count(); i++) paths.append(addTrack(*(data.tracks().at(i)))); @@ -155,7 +155,7 @@ QList PathView::loadData(const Data &data) if (_tracks.empty() && _routes.empty() && _waypoints.empty()) return paths; - if (mapScale() != scale) + if (mapZoom() != zoom) rescale(); else updatePOIVisibility(); @@ -179,11 +179,11 @@ void PathView::updateWaypointsBoundingRect(const Coordinates &wp) _wr.unite(wp); } -qreal PathView::mapScale() const +qreal PathView::mapZoom() const { RectC br = _tr | _rr | _wr; - return _map->zoomFit(viewport()->size() - QSize(MARGIN/2, MARGIN/2), br); + return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN), br); } QPointF PathView::contentCenter() const @@ -647,8 +647,8 @@ void PathView::drawBackground(QPainter *painter, const QRectF &rect) void PathView::resizeEvent(QResizeEvent *event) { - qreal scale = _map->zoom(); - if (mapScale() != scale) + qreal zoom = _map->zoom(); + if (mapZoom() != zoom) rescale(); QPointF center = contentCenter(); diff --git a/src/pathview.h b/src/pathview.h index 56453df4..81a89618 100644 --- a/src/pathview.h +++ b/src/pathview.h @@ -75,7 +75,7 @@ private: void loadPOI(); void clearPOI(); - qreal mapScale() const; + qreal mapZoom() const; QPointF contentCenter() const; void rescale(); void zoom(int zoom, const QPoint &pos, const Coordinates &c);