diff options
author | willemferguson <willemferguson@zoology.up.ac.za> | 2019-11-19 19:16:45 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-01-06 07:00:34 +0900 |
commit | d2cf58e07e64b4e1e6a81f07c2efce38c55be78b (patch) | |
tree | 1b0ad636f59da7600f4a38a819f8ddd5d03fc437 /desktop-widgets | |
parent | ebabbfb457184ea4d9e939ad8501986c35699264 (diff) | |
download | subsurface-d2cf58e07e64b4e1e6a81f07c2efce38c55be78b.tar.gz |
core: read and write the user-specified salinity
Both XML and git storage are added.
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.cpp | 29 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.h | 1 |
2 files changed, 15 insertions, 15 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index 1c7f30496..d588cce80 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -189,22 +189,23 @@ int TabDiveInformation::updateSalinityComboIndex(int salinity) // If dive->user_salinity != dive->salinity (i.e. dc value) then show the salinity-overwrite indicator void TabDiveInformation::checkDcSalinityOverWritten() { - if (current_dive && current_dive->dc.salinity && current_dive->user_salinity) { - if (current_dive->dc.salinity != current_dive->user_salinity) - ui->salinityOverWrittenIcon->setVisible(true); - } else { - ui->salinityOverWrittenIcon->setVisible(false); - } + int dc_value = current_dive->dc.salinity; + int user_value = current_dive->user_salinity; + bool show_indicator = false; + if (current_dive && dc_value && user_value && (user_value != dc_value)) + if ((dc_value < 10250) || (user_value < 10250)) // Provide for libdivecomputer that defines seawater density + show_indicator = true; // as 1.025 in contrast to Subsurface's value of 1.03 + ui->salinityOverWrittenIcon->setVisible(show_indicator); } void TabDiveInformation::showCurrentWidget(bool show, int position) { - ui->groupBox_wavesize->setVisible(show); - ui->groupBox_surge->setVisible(show); - ui->groupBox_chill->setVisible(show); - int layoutPosition = ui->diveInfoScrollAreaLayout->indexOf(ui->groupBox_current); - ui->diveInfoScrollAreaLayout->takeAt(layoutPosition); - ui->diveInfoScrollAreaLayout->addWidget(ui->groupBox_current, 6, position, 1, 1); + ui->groupBox_wavesize->setVisible(show); + ui->groupBox_surge->setVisible(show); + ui->groupBox_chill->setVisible(show); + int layoutPosition = ui->diveInfoScrollAreaLayout->indexOf(ui->groupBox_current); + ui->diveInfoScrollAreaLayout->takeAt(layoutPosition); + ui->diveInfoScrollAreaLayout->addWidget(ui->groupBox_current, 6, position, 1, 1); } void TabDiveInformation::updateData() @@ -258,6 +259,7 @@ void TabDiveInformation::updateData() showCurrentWidget(false, 0); // Show current star widget at lefthand side } +// From the index of the water type combo box, set the dive->salinity to an appropriate value void TabDiveInformation::on_waterTypeCombo_activated(int index) { int combobox_salinity = 0; int dc_salinity = current_dive->dc.salinity; @@ -284,8 +286,7 @@ void TabDiveInformation::on_waterTypeCombo_activated(int index) { } // Save and display the new salinity value ui->salinityText->setText(QString("%1g/ℓ").arg(combobox_salinity / 10.0)); -// divesEdited(Command::editWaterTypeUser(combobox_salinity, false)); // This will be enabled in step 4 when the undo is implemented. - current_dive->user_salinity = combobox_salinity; // This will be removed in step 4. This statement allows executable code. + divesEdited(Command::editWaterTypeUser(combobox_salinity, false)); if (dc_salinity == combobox_salinity) // If salinity differs from that of dc, then save it ui->salinityOverWrittenIcon->setVisible(false); else diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.h b/desktop-widgets/tab-widgets/TabDiveInformation.h index 0ff142f76..f905bc597 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.h +++ b/desktop-widgets/tab-widgets/TabDiveInformation.h @@ -32,7 +32,6 @@ private slots: private: Ui::TabDiveInformation *ui; void updateProfile(); - void updateSalinity(); int updateSalinityComboIndex(int salinity); void checkDcSalinityOverWritten(); void updateWhen(); |