mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 18:23:23 +00:00
Deal with some trip issues when editing dive timestamps
The idea behind editing timestamps had of course been the typical "oops, I forgot to set my time correctly" which shifts a dive (or a few of them) by a few hours but keeps the overall order of dives the same). But reasonable people might argue that they can envision a scenario where more dramatic changes are being made. And we need to deal with the impact this has on dive trips. Here we handle a couple of simple cases: - this is the only dive in a trip; just update the trip (this can still cause problems if the new time is in the middle of an existing trip). - this dives moves before the start of the trip it is in; let's remove it from that trip (this response is a bit simplistic - but as I tried to say, I don't expect this to be a common use case; and removing it at least doesn't lead to entirely unexpected behavior). - this dive moves past the end of this trip into the range of a different trip (in this case we remove the dive from the current trip and allow it to interrupt the trip it is moving into). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
be9d924cf8
commit
2f9960f20b
1 changed files with 8 additions and 0 deletions
|
@ -1441,6 +1441,14 @@ void edit_dive_when_cb(GtkWidget *menuitem, struct dive *dive)
|
|||
gtk_widget_destroy(dialog);
|
||||
when = utc_mktime(&tm);
|
||||
if (dive->when != when) {
|
||||
/* if this is the only dive in the trip, just change the trip time */
|
||||
if (dive->divetrip && dive->divetrip->nrdives == 1)
|
||||
dive->divetrip->when = when;
|
||||
/* if this is suddenly before the start of the trip, remove it from the trip */
|
||||
else if (dive->divetrip && dive->divetrip->when > when)
|
||||
remove_dive_from_trip(dive);
|
||||
else if (find_matching_trip(when) != dive->divetrip)
|
||||
remove_dive_from_trip(dive);
|
||||
dive->when = when;
|
||||
mark_divelist_changed(TRUE);
|
||||
remember_tree_state();
|
||||
|
|
Loading…
Add table
Reference in a new issue