diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-06-27 22:10:03 +0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-06-27 22:10:03 +0800 |
commit | de7506b44d03b4190d3a0205398d047e8303f75a (patch) | |
tree | 98a25573ac69f52ec10d35ed7e62c6e95b656ffa /qt-ui | |
parent | 3cdf8dc4c18cb4e4d2c0fe3908a03a51ff34ce04 (diff) | |
download | subsurface-de7506b44d03b4190d3a0205398d047e8303f75a.tar.gz |
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/diveplanner.cpp | 12 |
1 files 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 <QDebug> #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){ |