core: move get_dive_salinity() to struct dive

Feels natural in a C++ code base.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-30 18:31:43 +02:00 committed by bstoeger
parent 0aa4efb3d9
commit 718523e01d
3 changed files with 4 additions and 4 deletions

View file

@ -704,9 +704,9 @@ static void fixup_water_salinity(struct dive &dive)
dive.salinity = (sum + nr / 2) / nr; dive.salinity = (sum + nr / 2) / nr;
} }
int get_dive_salinity(const struct dive *dive) int dive::get_salinity() const
{ {
return dive->user_salinity ? dive->user_salinity : dive->salinity; return user_salinity ? user_salinity : salinity;
} }
static void fixup_meandepth(struct dive &dive) static void fixup_meandepth(struct dive &dive)

View file

@ -107,6 +107,7 @@ struct dive {
cylinder_t *get_cylinder(int idx); cylinder_t *get_cylinder(int idx);
const cylinder_t *get_cylinder(int idx) const; const cylinder_t *get_cylinder(int idx) const;
weight_t total_weight() const; weight_t total_weight() const;
int get_salinity() const;
int depth_to_mbar(int depth) const; int depth_to_mbar(int depth) const;
double depth_to_mbarf(int depth) const; double depth_to_mbarf(int depth) const;
@ -191,7 +192,6 @@ extern int legacy_format_o2pressures(const struct dive *dive, const struct divec
extern bool dive_less_than(const struct dive &a, const struct dive &b); extern bool dive_less_than(const struct dive &a, const struct dive &b);
extern bool dive_less_than_ptr(const struct dive *a, const struct dive *b); extern bool dive_less_than_ptr(const struct dive *a, const struct dive *b);
extern bool dive_or_trip_less_than(struct dive_or_trip a, struct dive_or_trip b); extern bool dive_or_trip_less_than(struct dive_or_trip a, struct dive_or_trip b);
extern int get_dive_salinity(const struct dive *dive);
extern int dive_getUniqID(); extern int dive_getUniqID();
extern void copy_events_until(const struct dive *sd, struct dive *dd, int dcNr, int time); extern void copy_events_until(const struct dive *sd, struct dive *dd, int dcNr, int time);

View file

@ -221,7 +221,7 @@ void TabDiveInformation::updateData(const std::vector<dive *> &, dive *currentDi
ui->airtemp->setText(get_temperature_string(currentDive->airtemp, true)); ui->airtemp->setText(get_temperature_string(currentDive->airtemp, true));
ui->atmPressType->setItemText(1, get_depth_unit()); // Check for changes in depth unit (imperial/metric) ui->atmPressType->setItemText(1, get_depth_unit()); // Check for changes in depth unit (imperial/metric)
setIndexNoSignal(ui->atmPressType, 0); // Set the atmospheric pressure combo box to mbar setIndexNoSignal(ui->atmPressType, 0); // Set the atmospheric pressure combo box to mbar
salinity_value = get_dive_salinity(currentDive); salinity_value = currentDive->get_salinity();
if (salinity_value) { // Set water type indicator (EN13319 = 1.020 g/l) if (salinity_value) { // Set water type indicator (EN13319 = 1.020 g/l)
setIndexNoSignal(ui->waterTypeCombo, updateSalinityComboIndex(salinity_value)); setIndexNoSignal(ui->waterTypeCombo, updateSalinityComboIndex(salinity_value));
ui->waterTypeText->setText(get_water_type_string(salinity_value)); ui->waterTypeText->setText(get_water_type_string(salinity_value));