summaryrefslogtreecommitdiffstats
path: root/subsurfacestartup.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-20 06:11:32 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-20 06:11:32 +0900
commitb303f217a9d66ef031c58534b3796ddefbe362c5 (patch)
tree7c127cdffb59e42a68be4f4a15ebb35efb262f88 /subsurfacestartup.c
parent4d14059d7c309534d9932375958b561fa464bde2 (diff)
downloadsubsurface-b303f217a9d66ef031c58534b3796ddefbe362c5.tar.gz
Dive list: add context menu function to renumber dive(s)
No attempt is made to ensure that what the user does is sane. So this can result in duplicate numbers, non-consecutive numbers, non-monotonous numbers, whatever floats the users boat. You can renumber a single dive or all selected dives (with a starting number given that is applied to the oldest selected dive and then for each newer selected dive that number is incremented by one). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurfacestartup.c')
-rw-r--r--subsurfacestartup.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/subsurfacestartup.c b/subsurfacestartup.c
index 471fea64e..4ae426d1c 100644
--- a/subsurfacestartup.c
+++ b/subsurfacestartup.c
@@ -149,13 +149,14 @@ void parse_argument(const char *arg)
} while (*++p);
}
-void renumber_dives(int nr)
+void renumber_dives(int start_nr, bool selected_only)
{
- int i;
+ int i, nr = start_nr;
+ struct dive *dive;
- for (i = 0; i < dive_table.nr; i++) {
- struct dive *dive = dive_table.dives[i];
- dive->number = nr + i;
+ for_each_dive (i, dive) {
+ if (dive->selected)
+ dive->number = nr++;
}
mark_divelist_changed(true);
}