From abc987cb0ceda49081a9a804c221e301c4cda9d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Thu, 3 May 2018 19:11:55 +0200 Subject: [PATCH] Code cleanup --- src/GUI/mapview.cpp | 17 +++++++---------- src/GUI/mapview.h | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/GUI/mapview.cpp b/src/GUI/mapview.cpp index 15e6529d..b00981f8 100644 --- a/src/GUI/mapview.cpp +++ b/src/GUI/mapview.cpp @@ -421,7 +421,7 @@ void MapView::digitalZoom(int zoom) _mapScale->setDigitalZoom(_digitalZoom); } -void MapView::zoom(int zoom, const QPoint &pos, const Coordinates &c) +void MapView::zoom(int zoom, const QPoint &pos) { bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier; @@ -433,9 +433,9 @@ void MapView::zoom(int zoom, const QPoint &pos, const Coordinates &c) digitalZoom(zoom); } else { - qreal os, ns; - os = _map->zoom(); - ns = (zoom > 0) ? _map->zoomIn() : _map->zoomOut(); + Coordinates c = _map->xy2ll(mapToScene(pos)); + qreal os = _map->zoom(); + qreal ns = (zoom > 0) ? _map->zoomIn() : _map->zoomOut(); if (ns != os) { rescale(); @@ -456,8 +456,7 @@ void MapView::wheelEvent(QWheelEvent *event) return; deg = 0; - Coordinates c = _map->xy2ll(mapToScene(event->pos())); - zoom((event->delta() > 0) ? 1 : -1, event->pos(), c); + zoom((event->delta() > 0) ? 1 : -1, event->pos()); } void MapView::mouseDoubleClickEvent(QMouseEvent *event) @@ -465,8 +464,7 @@ void MapView::mouseDoubleClickEvent(QMouseEvent *event) if (event->button() != Qt::LeftButton && event->button() != Qt::RightButton) return; - Coordinates c = _map->xy2ll(mapToScene(event->pos())); - zoom((event->button() == Qt::LeftButton) ? 1 : -1, event->pos(), c); + zoom((event->button() == Qt::LeftButton) ? 1 : -1, event->pos()); } void MapView::keyPressEvent(QKeyEvent *event) @@ -474,7 +472,6 @@ void MapView::keyPressEvent(QKeyEvent *event) int z; QPoint pos = viewport()->rect().center(); - Coordinates c = _map->xy2ll(mapToScene(pos)); if (event->matches(ZOOM_IN)) z = 1; @@ -488,7 +485,7 @@ void MapView::keyPressEvent(QKeyEvent *event) return; } - zoom(z, pos, c); + zoom(z, pos); } void MapView::plot(QPainter *painter, const QRectF &target, qreal scale, diff --git a/src/GUI/mapview.h b/src/GUI/mapview.h index 6150f71d..9e55e841 100644 --- a/src/GUI/mapview.h +++ b/src/GUI/mapview.h @@ -84,7 +84,7 @@ private: QPointF contentCenter() const; void rescale(); void centerOn(const QPointF &pos); - void zoom(int zoom, const QPoint &pos, const Coordinates &c); + void zoom(int zoom, const QPoint &pos); void digitalZoom(int zoom); void updatePOIVisibility();