mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
List only the gases used in the Info tab
The equipment tab will still show all defined gases, but the info for the dive should only list the ones used. Also change the name of the two gas related boxes to better reflect the data that is shown. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
34c7aa940c
commit
ff6e730e30
2 changed files with 58 additions and 8 deletions
|
@ -240,7 +240,7 @@
|
|||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>O²/HE</string>
|
||||
<string>Gases Used</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
|
@ -335,7 +335,7 @@
|
|||
<item row="0" column="2">
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Gas Used</string>
|
||||
<string>Gas Consumed</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
|
|
62
statistics.c
62
statistics.c
|
@ -290,23 +290,73 @@ volume_t get_gas_used(struct dive *dive)
|
|||
return gas_used;
|
||||
}
|
||||
|
||||
bool is_gas_used(struct dive *dive, int idx)
|
||||
{
|
||||
cylinder_t *cyl = &dive->cylinder[idx];
|
||||
int o2, he;
|
||||
struct divecomputer *dc;
|
||||
bool used = FALSE;
|
||||
bool firstGasExplicit = FALSE;
|
||||
if (cylinder_none(cyl))
|
||||
return FALSE;
|
||||
|
||||
o2 = get_o2(&cyl->gasmix);
|
||||
he = get_he(&cyl->gasmix);
|
||||
dc = &dive->dc;
|
||||
while (dc) {
|
||||
struct event *event = dc->events;
|
||||
while (event) {
|
||||
if (event->value) {
|
||||
if (event->name && !strcmp(event->name, "gaschange")) {
|
||||
unsigned int event_he = event->value >> 16;
|
||||
unsigned int event_o2 = event->value & 0xffff;
|
||||
if (event->time.seconds < 30)
|
||||
firstGasExplicit = TRUE;
|
||||
if (is_air(o2, he)) {
|
||||
if (is_air(event_o2 * 10, event_he * 10))
|
||||
used = TRUE;
|
||||
} else if (he == event_he * 10 && o2 == event_o2 * 10) {
|
||||
used = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (used)
|
||||
break;
|
||||
event = event->next;
|
||||
}
|
||||
if (used)
|
||||
break;
|
||||
dc = dc->next;
|
||||
}
|
||||
if (idx == 0 && !firstGasExplicit)
|
||||
used = TRUE;
|
||||
return used;
|
||||
}
|
||||
|
||||
#define MAXBUF 80
|
||||
/* for the O2/He readings just create a list of them */
|
||||
char *get_gaslist(struct dive *dive)
|
||||
{
|
||||
int idx, offset = 0;
|
||||
static char buf[MAXBUF];
|
||||
int o2, he;
|
||||
|
||||
buf[0] = '\0';
|
||||
for (idx = 0; idx < MAX_CYLINDERS; idx++) {
|
||||
cylinder_t *cyl = &dive->cylinder[idx];
|
||||
if (!cylinder_none(cyl)) {
|
||||
int o2 = get_o2(&cyl->gasmix);
|
||||
int he = get_he(&cyl->gasmix);
|
||||
cylinder_t *cyl;
|
||||
if (!is_gas_used(dive, idx))
|
||||
continue;
|
||||
cyl = &dive->cylinder[idx];
|
||||
o2 = get_o2(&cyl->gasmix);
|
||||
he = get_he(&cyl->gasmix);
|
||||
if (is_air(o2, he))
|
||||
snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? ", %s" : "%s", _("air"));
|
||||
else
|
||||
snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? ", %d/%d" : "%d/%d",
|
||||
(o2 + 5) / 10, (he + 5) / 10);
|
||||
offset = strlen(buf);
|
||||
}
|
||||
offset = strlen(buf);
|
||||
}
|
||||
if (*buf == '\0')
|
||||
strncpy(buf, _("air"), MAXBUF);
|
||||
return buf;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue