From 7051bee7e1568d3cbe687d97fb65d40b4d078ce0 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 4 Oct 2021 21:41:17 +0200 Subject: [PATCH] profile: remove ProfileWidget2::zoomFactor member This is a constant, no point in keeping it as a member variable. Contains removal of a pointless #ifdef (guarding against mobile, but code not compiled on mobile), a typo-fix in a comment and replacement of Qt's idiosyncratic qreal by double. Signed-off-by: Berthold Stoeger --- profile-widget/profilewidget2.cpp | 10 +++++----- profile-widget/profilewidget2.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index d1371b146..890510245 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -41,16 +41,16 @@ // Constant describing at which z-level the thumbnails are located. // We might add more constants here for easier customability. -#ifndef SUBSURFACE_MOBILE static const double thumbnailBaseZValue = 100.0; -#endif + +// Base of exponential zoom function: one wheel-click will increase the zoom by 15%. +static const double zoomFactor = 1.15; ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, double dpr, QWidget *parent) : QGraphicsView(parent), profileScene(new ProfileScene(dpr, false, false)), currentState(INIT), plannerModel(plannerModelIn), zoomLevel(0), - zoomFactor(1.15), #ifndef SUBSURFACE_MOBILE toolTipItem(new ToolTipItem()), #endif @@ -182,7 +182,7 @@ void ProfileWidget2::resetZoom() { if (!zoomLevel) return; - const qreal defScale = 1.0 / qPow(zoomFactor, (qreal)zoomLevel); + const double defScale = 1.0 / pow(zoomFactor, (double)zoomLevel); scale(defScale, defScale); zoomLevel = 0; } @@ -320,7 +320,7 @@ void ProfileWidget2::scale(qreal sx, qreal sy) for (PictureEntry &p: pictures) updateDurationLine(p); - // Since we created new duration lines, we have to update the order in which the thumbnails is painted. + // Since we created new duration lines, we have to update the order in which the thumbnails are painted. updateThumbnailPaintOrder(); #endif } diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h index 8908a599a..122065b79 100644 --- a/profile-widget/profilewidget2.h +++ b/profile-widget/profilewidget2.h @@ -136,7 +136,6 @@ private: DivePlannerPointsModel *plannerModel; // If null, no planning supported. int zoomLevel; - qreal zoomFactor; #ifndef SUBSURFACE_MOBILE ToolTipItem *toolTipItem; #endif