diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-11-11 15:02:50 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-11-11 15:09:00 +0100 |
commit | b304562fa89aa67fd5639d6c14c6e12472287515 (patch) | |
tree | a68b48355791099db2dc177da1ec59e865da296d | |
parent | 80485114ba34ff8390f489ad8cf7c66dc5d38fad (diff) | |
download | subsurface-b304562fa89aa67fd5639d6c14c6e12472287515.tar.gz |
Be stricter about when we allow merging of dives
If the surface interval between two dives is more than half an hour,
don't try to call it a single dive. Just the dive profile will be
looking ridiculous.
Things like tank refills etc could also be a good thing to check (again,
the dive profile would look ridiculous), but the cylinder pressure going
up a small amount is actually normal (ie cylinder warming up in warmer
water on the surface). So I don't know what the proper limit for that
would be.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | divelist.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/divelist.c b/divelist.c index 10c1ce4b3..3e48d2fb9 100644 --- a/divelist.c +++ b/divelist.c @@ -2118,16 +2118,25 @@ static void merge_dives_cb(GtkWidget *menuitem, void *unused) /* Called if there are exactly two selected dives and the dive at idx is one of them */ static void add_dive_merge_label(int idx, GtkMenuShell *menu) { - struct dive *d; + struct dive *a, *b; GtkWidget *menuitem; /* The other selected dive must be next to it.. */ - if (!((d = get_dive(idx-1)) && d->selected) && - !((d = get_dive(idx+1)) && d->selected)) - return; + a = get_dive(idx); + b = get_dive(idx+1); + if (!b || !b->selected) { + b = a; + a = get_dive(idx-1); + if (!a || !a->selected) + return; + } /* .. and they had better be in the same dive trip */ - if (d->divetrip != get_dive(idx)->divetrip) + if (a->divetrip != b->divetrip) + return; + + /* .. and if the surface interval is excessive, you must be kidding us */ + if (b->when > a->when + a->duration.seconds + 30*60) return; /* If so, we can add a "merge dive" menu entry */ |