mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Use the default cylinder if defined
With this every cylinder downloaded from a divecomputer that doesn't provide cylinder data, and every cylinder manually added anywhere will default to the default cylinder that is set in the preferences. For people who most of the time dive with the same equipment (always on dive boats with AL80, or almost always diving their personal HP119) this should be a nice improvement. If you don't like this behavior, simply leave the default cylinder setting in the preferences empty. This commit also fixes the incorrect s->value call (should be s->setValue). I wonder what this did to the default filename before... Fixes #145 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
8e5c222e98
commit
904c20feef
2 changed files with 20 additions and 6 deletions
22
planner.c
22
planner.c
|
@ -172,9 +172,23 @@ static int time_at_last_depth(struct dive *dive, int o2, int he, unsigned int ne
|
|||
|
||||
void fill_default_cylinder(cylinder_t *cyl)
|
||||
{
|
||||
cyl->type.description = strdup("AL80");
|
||||
cyl->type.size.mliter = 11097;
|
||||
cyl->type.workingpressure.mbar = 206843;
|
||||
if (prefs.default_cylinder) {
|
||||
struct tank_info_t *ti = tank_info;
|
||||
while (ti->name != NULL) {
|
||||
if (strcmp(ti->name, prefs.default_cylinder) == 0) {
|
||||
cyl->type.description = strdup(prefs.default_cylinder);
|
||||
if (ti->ml) {
|
||||
cyl->type.size.mliter = ti->ml;
|
||||
cyl->type.workingpressure.mbar = ti->bar * 1000;
|
||||
} else {
|
||||
cyl->type.workingpressure.mbar = psi_to_mbar(ti->psi);
|
||||
cyl->type.size.mliter = cuft_to_l(ti->cuft) * 1000 / bar_to_atm(psi_to_bar(ti->psi));
|
||||
}
|
||||
return;
|
||||
}
|
||||
ti++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int add_gas(struct dive *dive, int o2, int he)
|
||||
|
@ -268,7 +282,7 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan, const char **error
|
|||
int plano2 = (o2 + 5) / 10 * 10;
|
||||
int planhe = (he + 5) / 10 * 10;
|
||||
int idx;
|
||||
if ((idx = add_gas(dive, plano2, planhe)) < 0)
|
||||
if ((idx = add_gas(dive, plano2, planhe)) < 0)
|
||||
goto gas_error_exit;
|
||||
add_gas_switch_event(dive, dc, lasttime, idx);
|
||||
oldo2 = o2; oldhe = he;
|
||||
|
|
|
@ -139,8 +139,8 @@ void PreferencesDialog::syncSettings()
|
|||
s.endGroup();
|
||||
// Defaults
|
||||
s.beginGroup("GeneralSettings");
|
||||
s.value("default_filename", ui.defaultfilename->text());
|
||||
s.value("default_cylinder", ui.defaultcylinder->text());
|
||||
s.setValue("default_filename", ui.defaultfilename->text());
|
||||
s.setValue("default_cylinder", ui.defaultcylinder->text());
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup("Display");
|
||||
|
|
Loading…
Reference in a new issue