diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-10-03 15:13:24 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-10-03 16:19:04 -0700 |
commit | 61f8b8c00282519db18614c1a85036be769ee15c (patch) | |
tree | 35690d65ae474f3410d4dbc96af34c14ce5e2b71 /desktop-widgets | |
parent | 5bc6f5d36c491b305f66a03c8400666ccda0b044 (diff) | |
download | subsurface-61f8b8c00282519db18614c1a85036be769ee15c.tar.gz |
planner: limit depth and time of segments to sane values
Using non-sensical depth and times for segments in the planner may
lead to an unresponsive UI. Therefore limit depth to 1000 m/3300 ft
and time to 100 h. Limiting of depth is done in settingsChanged()
since it has to adapt to the user changig their preferred units.
Fixes #2762.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/diveplanner.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index cd0ae2c2d..00aaffdac 100644 --- a/desktop-widgets/diveplanner.cpp +++ b/desktop-widgets/diveplanner.cpp @@ -169,9 +169,10 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg connect(closeKey, &QShortcut::activated, plannerModel, &DivePlannerPointsModel::cancelPlan); // This makes shure the spinbox gets a setMinimum(0) on it so we can't have negative time or depth. - ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DEPTH, new SpinBoxDelegate(0, INT_MAX, 1, this)); + // Limit segments to a depth of 1000 m/3300 ft and a duration of 100 h. Setting the limit for + // the depth will be done in settingChanged() since this depends on the chosen units. ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::RUNTIME, new SpinBoxDelegate(0, INT_MAX, 1, this)); - ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DURATION, new SpinBoxDelegate(0, INT_MAX, 1, this)); + ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DURATION, new SpinBoxDelegate(0, 6000, 1, this)); ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::CCSETPOINT, new DoubleSpinBoxDelegate(0, 2, 0.1, this)); /* set defaults. */ @@ -227,15 +228,19 @@ void DivePlannerWidget::setSalinity(int salinity) void DivePlannerWidget::settingsChanged() { // Adopt units + int maxDepth; if (get_units()->length == units::FEET) { ui.atmHeight->setSuffix("ft"); ui.atmHeight->setMinimum(-300); ui.atmHeight->setMaximum(10000); + maxDepth = 3300; } else { ui.atmHeight->setSuffix(("m")); ui.atmHeight->setMinimum(-100); ui.atmHeight->setMaximum(3000); + maxDepth = 1000; } + ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DEPTH, new SpinBoxDelegate(0, maxDepth, 1, this)); ui.atmHeight->blockSignals(true); ui.atmHeight->setValue((int) get_depth_units((int) pressure_to_altitude(DivePlannerPointsModel::instance()->getSurfacePressure()), NULL,NULL)); ui.atmHeight->blockSignals(false); @@ -553,7 +558,7 @@ void PlannerSettingsWidget::settingsChanged() ui.asc6toSurf->setText(tr("6m to surface")); ui.bestmixEND->setSuffix(tr("m")); } - if(get_units()->volume == units::CUFT) { + if (get_units()->volume == units::CUFT) { ui.bottomSAC->setSuffix(tr("cuft/min")); ui.decoStopSAC->setSuffix(tr("cuft/min")); ui.bottomSAC->setDecimals(2); @@ -572,7 +577,7 @@ void PlannerSettingsWidget::settingsChanged() ui.bottomSAC->setValue(PlannerShared::bottomsac()); ui.decoStopSAC->setValue(PlannerShared::decosac()); } - if(get_units()->pressure == units::BAR) { + if (get_units()->pressure == units::BAR) { ui.reserve_gas->setSuffix(tr("bar")); ui.reserve_gas->setSingleStep(1); ui.reserve_gas->setValue(prefs.reserve_gas / 1000); |