diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-11-23 21:54:51 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-23 22:01:11 -0800 |
commit | 904c20feef907440bc8a8070fdfe56b7389db404 (patch) | |
tree | 97dda830c22b4c4ff4325e23580c6cc07652e46e | |
parent | 8e5c222e98bc9cc5ce9dfd29733b6d5bba2c108a (diff) | |
download | subsurface-904c20feef907440bc8a8070fdfe56b7389db404.tar.gz |
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>
-rw-r--r-- | planner.c | 22 | ||||
-rw-r--r-- | qt-ui/preferences.cpp | 4 |
2 files changed, 20 insertions, 6 deletions
@@ -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; diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 0740d3f51..e0ac4039f 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -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"); |