diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-05-02 14:34:40 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-03 15:02:21 -0700 |
commit | 09b7fcbcf4e26d19529486ddd2a0e672e60dce32 (patch) | |
tree | 06df630ace17077474fdec09a43c3aace1aa6d5d /commands | |
parent | 649b2f2a9ea581e4fbb97a6fd8cc519af880aaf2 (diff) | |
download | subsurface-09b7fcbcf4e26d19529486ddd2a0e672e60dce32.tar.gz |
selection: add selection flag for trips
In analogy to dives add a selection flag for trips. The reason
being that search for a selected trip can be painfully slow when
we do it through Qt's proxy model.
Make sure to deselect trips when they are removed from the core.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/command_divelist.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/commands/command_divelist.cpp b/commands/command_divelist.cpp index 83ae2fbca..8f769514a 100644 --- a/commands/command_divelist.cpp +++ b/commands/command_divelist.cpp @@ -13,6 +13,14 @@ namespace Command { +// Helper function that takes care to unselect trips that are removed from the backend +static void remove_trip_from_backend(dive_trip *trip) +{ + if (trip->selected) + deselect_trip(trip); + remove_trip(trip, &trip_table); // Remove trip from backend +} + // This helper function removes a dive, takes ownership of the dive and adds it to a DiveToAdd structure. // If the trip the dive belongs to becomes empty, it is removed and added to the tripsToAdd vector. // It is crucial that dives are added in reverse order of deletion, so that the indices are correctly @@ -32,7 +40,7 @@ DiveToAdd DiveListBase::removeDive(struct dive *d, std::vector<OwningTripPtr> &t diveSiteCountChanged(d->dive_site); res.site = unregister_dive_from_dive_site(d); if (res.trip && res.trip->dives.nr == 0) { - remove_trip(res.trip, &trip_table); // Remove trip from backend + remove_trip_from_backend(res.trip); // Remove trip from backend tripsToAdd.emplace_back(res.trip); // Take ownership of trip } @@ -265,7 +273,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); if (trip && trip->dives.nr == 0) { - remove_trip(trip, &trip_table); // Remove trip from backend + remove_trip_from_backend(trip); // Remove trip from backend res.reset(trip); } |