1
0
Fork 0
mirror of https://github.com/subsurface/subsurface.git synced 2025-02-19 22:16:15 +00:00

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>
This commit is contained in:
Dirk Hohndel 2013-06-27 22:10:03 +08:00
parent 3cdf8dc4c1
commit de7506b44d

View file

@ -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){