From de7506b44d03b4190d3a0205398d047e8303f75a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 27 Jun 2013 22:10:03 +0800 Subject: Somewhat saner behavior for rescaling the planner time axis We always resize if the dive is longer than the current scale allows, but we don't shrink it overly aggressively and we never shrink it below the initial size. Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 4b8dd84d9..799e87c42 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -5,6 +5,8 @@ #include #include "ui_diveplanner.h" +#define TIME_INITIAL_MAX 30 + DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent), activeDraggedHandler(0), lastValidPos(0.0, 0.0) { @@ -22,7 +24,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) timeLine = new Ruler(); timeLine->setMinimum(0); - timeLine->setMaximum(20); + timeLine->setMaximum(TIME_INITIAL_MAX); timeLine->setTickInterval(10); timeLine->setLine(10, 90, 99, 90); timeLine->setOrientation(Qt::Horizontal); @@ -137,10 +139,12 @@ void DivePlannerGraphics::createDecoStops() while(dp->next) dp = dp->next; - //if (timeLine->maximum() < dp->time / 60.0 + 5) { - timeLine->setMaximum(dp->time / 60.0 + 5); + if (timeLine->maximum() < dp->time / 60.0 + 5 || + dp->time / 60.0 + 15 < timeLine->maximum()) { + double newMax = fmax(dp->time / 60.0 + 5, TIME_INITIAL_MAX); + timeLine->setMaximum(newMax); timeLine->updateTicks(); - //} + } // Re-position the user generated dive handlers Q_FOREACH(DiveHandler *h, handles){ -- cgit v1.2.3-70-g09d2