From 6b283e598a3a08c6133d66b5d5617370296e7d0e Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 8 Nov 2018 16:58:33 +0100 Subject: Dive list: replace dive-list of trips by a table The dives of each trip were kept in a list. Replace this by a struct dive_table. This will make it significantly easier to keep the dives of a trip in sorted state. Signed-off-by: Berthold Stoeger --- desktop-widgets/command_divelist.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/command_divelist.cpp b/desktop-widgets/command_divelist.cpp index 3d1aae2e7..d5fbc2139 100644 --- a/desktop-widgets/command_divelist.cpp +++ b/desktop-widgets/command_divelist.cpp @@ -66,7 +66,7 @@ DiveToAdd DiveListBase::removeDive(struct dive *d) // remove dive from trip - if this is the last dive in the trip // remove the whole trip. res.trip = unregister_dive_from_trip(d, false); - if (res.trip && res.trip->nrdives == 0) { + if (res.trip && res.trip->dives.nr == 0) { unregister_trip(res.trip); // Remove trip from backend res.tripToAdd.reset(res.trip); // Take ownership of trip } @@ -231,7 +231,7 @@ static OwningTripPtr moveDiveToTrip(DiveToTrip &diveToTrip) // Remove dive from trip - if this is the last dive in the trip, remove the whole trip. dive_trip *trip = unregister_dive_from_trip(diveToTrip.dive, false); - if (trip && trip->nrdives == 0) { + if (trip && trip->dives.nr == 0) { unregister_trip(trip); // Remove trip from backend res.reset(trip); } @@ -737,10 +737,10 @@ MergeTrips::MergeTrips(dive_trip *trip1, dive_trip *trip2) return; dive_trip *newTrip = combine_trips_create(trip1, trip2); divesToMove.tripsToAdd.emplace_back(newTrip); - for (dive *d = trip1->dives; d; d = d->next) - divesToMove.divesToMove.push_back( { d, newTrip } ); - for (dive *d = trip2->dives; d; d = d->next) - divesToMove.divesToMove.push_back( { d, newTrip } ); + for (int i = 0; i < trip1->dives.nr; ++i) + divesToMove.divesToMove.push_back( { trip1->dives.dives[i], newTrip } ); + for (int i = 0; i < trip2->dives.nr; ++i) + divesToMove.divesToMove.push_back( { trip2->dives.dives[i], newTrip } ); } SplitDives::SplitDives(dive *d, duration_t time) -- cgit v1.2.3-70-g09d2