Update altitude properly when changing unit systems

We need to change the displayed numeric value of the altitutde and not just the
unit suffix when changing unit systems.

Fixes #681

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2014-08-03 22:24:56 +02:00 committed by Dirk Hohndel
parent 0c3fa77354
commit a3fe1c560f
2 changed files with 10 additions and 1 deletions

View file

@ -323,6 +323,9 @@ void DivePlannerWidget::settingsChanged()
} else { } else {
ui.atmHeight->setSuffix(("m")); ui.atmHeight->setSuffix(("m"));
} }
ui.atmHeight->blockSignals(true);
ui.atmHeight->setValue((int) get_depth_units((int) (log(1013.0 / plannerModel->getSurfacePressure()) * 7800000), NULL,NULL));
ui.atmHeight->blockSignals(false);
} }
void DivePlannerPointsModel::addCylinder_clicked() void DivePlannerPointsModel::addCylinder_clicked()
@ -334,7 +337,7 @@ void DivePlannerWidget::atmPressureChanged(const int pressure)
{ {
plannerModel->setSurfacePressure(pressure); plannerModel->setSurfacePressure(pressure);
ui.atmHeight->blockSignals(true); ui.atmHeight->blockSignals(true);
ui.atmHeight->setValue((int) get_depth_units((int)(log(1013.0 / pressure) * 7800000), NULL,NULL)); ui.atmHeight->setValue((int) get_depth_units((int) (log(1013.0 / pressure) * 7800000), NULL,NULL));
ui.atmHeight->blockSignals(false); ui.atmHeight->blockSignals(false);
} }
@ -712,6 +715,11 @@ void DivePlannerPointsModel::setSurfacePressure(int pressure)
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
} }
int DivePlannerPointsModel::getSurfacePressure()
{
return diveplan.surface_pressure;
}
void DivePlannerPointsModel::setLastStop6m(bool value) void DivePlannerPointsModel::setLastStop6m(bool value)
{ {
set_last_stop(value); set_last_stop(value);

View file

@ -67,6 +67,7 @@ slots:
void setGFHigh(const int gfhigh); void setGFHigh(const int gfhigh);
void setGFLow(const int ghflow); void setGFLow(const int ghflow);
void setSurfacePressure(int pressure); void setSurfacePressure(int pressure);
int getSurfacePressure();
void setBottomSac(int sac); void setBottomSac(int sac);
void setDecoSac(int sac); void setDecoSac(int sac);
void setStartTime(const QTime &t); void setStartTime(const QTime &t);