Desktop: Fix Inconsistencies in Handling of Salinity.

- add correct setting of the water type drop down for the dive shown
  initially after program start;
- change salinity to have 3 decimals in planner, to make it consistency
  with the log.

Fixes #4240.

Reported-by: @ccsieh
Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2024-06-09 08:13:44 +12:00
parent 10fc3bfd47
commit b126fccb1b
3 changed files with 9 additions and 9 deletions

View file

@ -185,13 +185,12 @@ void DivePlannerWidget::heightChanged(const int height)
void DivePlannerWidget::waterTypeUpdateTexts()
{
double density;
/* Do not set text in last/custom element */
for (int i = 0; i < ui.waterType->count()-1; i++) {
if (ui.waterType->itemData(i) != QVariant::Invalid) {
QString densityText = ui.waterType->itemText(i).split("(")[0].trimmed();
density = ui.waterType->itemData(i).toInt() / 10000.0;
densityText.append(QString(" (%L1%2)").arg(density, 0, 'f', 2).arg(tr("kg/")));
double density = ui.waterType->itemData(i).toInt() / 10000.0;
densityText.append(QStringLiteral(" (%L1%2)").arg(density, 0, 'f', 3).arg(tr("kg/")));
ui.waterType->setItemText(i, densityText);
}
}