diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-11-08 16:58:33 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-11-18 16:50:09 -0800 |
commit | 6b283e598a3a08c6133d66b5d5617370296e7d0e (patch) | |
tree | 685ccf1fd839d72471b179bf12aa72d2bdcec7de /desktop-widgets/command_divelist.cpp | |
parent | bc7afebc23477ef23f2b9741bf45b2180cbafe15 (diff) | |
download | subsurface-6b283e598a3a08c6133d66b5d5617370296e7d0e.tar.gz |
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_divelist.cpp')
-rw-r--r-- | desktop-widgets/command_divelist.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
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) |