mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
ebabbfb457
commit
d2cf58e07e
10 changed files with 62 additions and 18 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue