diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-09-24 03:42:40 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-09-24 03:42:40 -0700 |
commit | 446ab45858b509e56029e5c1557a12ca3680a674 (patch) | |
tree | 129888e7d75600c63bd43cbb099e5901549c9b9b /divelist.c | |
parent | 2d40172d78436b8aef3eab238faabe2ce3f9830f (diff) | |
download | subsurface-446ab45858b509e56029e5c1557a12ca3680a674.tar.gz |
Only offer to merge dives if they are consecutive in the divelist
You cannot merge dives if there is another, unselected dive "between"
them.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/divelist.c b/divelist.c index baf0428e0..777c53ba2 100644 --- a/divelist.c +++ b/divelist.c @@ -916,6 +916,30 @@ void add_single_dive(int idx, struct dive *dive) } } +bool consecutive_selected() +{ + struct dive *d; + int i; + bool consecutive = TRUE; + bool firstfound = FALSE; + bool lastfound = FALSE; + + if (amount_selected == 0 || amount_selected == 1) + return TRUE; + + for_each_dive(i, d) { + if (d->selected) { + if (!firstfound) + firstfound = TRUE; + else if (lastfound) + consecutive = FALSE; + } else if (firstfound) { + lastfound = TRUE; + } + } + return consecutive; +} + struct dive *merge_two_dives(struct dive *a, struct dive *b) { struct dive *res; |