diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-02 19:19:01 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-02 19:19:01 -0700 |
commit | 1cbe2444cc6c0c8da9e730561914986506d83770 (patch) | |
tree | dc9e16169410158163dc52fc72b77288f9ad575f /parse-xml.c | |
parent | 3a7d577ff1109c701656854ceb23ed690c340fbc (diff) | |
download | subsurface-1cbe2444cc6c0c8da9e730561914986506d83770.tar.gz |
Add the ugliest 'delete dive' model ever
This interface works the same way the "edit dive" menu item does: it's a
text entry meny item on the dive text entries (ie buddy/divemaster/notes
sections). Except you pick the "Delete" entry rather than the "Edit"
entry.
It kind of works, but it really is a pretty horrible interface. I'll
need to add a top-level dive menu entry for just deleting all selected
dives instead. And it would be good to be able to get a drop-down menu
from the divelist instead of having to do it from the dive text entries,
which is just insane.
But that requires gtk work. I'm not quite ready to get back into that.
Thus the "exact same insane interface as the explicit 'Edit' mode".
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/parse-xml.c b/parse-xml.c index e920a11f6..552786b7a 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -39,6 +39,29 @@ void record_dive(struct dive *dive) dive_table.nr = nr+1; } +/* + * Remove a dive from the dive_table array + */ +void delete_dive(struct dive *dive) +{ + int nr = dive_table.nr, i; + struct dive **dives = dive_table.dives; + + /* + * Stupid. We know the dive table is sorted by date, + * we could do a binary lookup. Sue me. + */ + for (i = 0; i < nr; i++) { + struct dive *d = dives[i]; + if (d != dive) + continue; + memmove(dives+i, dives+i+1, sizeof(struct dive *)*(nr-i-1)); + dives[nr] = NULL; + dive_table.nr = nr-1; + break; + } +} + static void start_match(const char *type, const char *name, char *buffer) { if (verbose > 2) |