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 /core/selection.cpp | |
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 'core/selection.cpp')
-rw-r--r-- | core/selection.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/core/selection.cpp b/core/selection.cpp index 2919f6486..f763afcc6 100644 --- a/core/selection.cpp +++ b/core/selection.cpp @@ -3,12 +3,13 @@ #include "selection.h" #include "divelist.h" -#include "display.h" // for amount_selected +#include "trip.h" #include "subsurface-qt/divelistnotifier.h" #include <QVector> int amount_selected; +static int amount_trips_selected; extern "C" void select_dive(struct dive *dive) { @@ -155,6 +156,11 @@ void setSelection(const std::vector<dive *> &selection, dive *currentDive) QVector<dive *> divesToSelect; divesToSelect.reserve(selection.size()); + // Since we select only dives, there are no selected trips! + amount_trips_selected = 0; + for (int i = 0; i < trip_table.nr; ++i) + trip_table.trips[i]->selected = false; + // TODO: We might want to keep track of selected dives in a more efficient way! int i; dive *d; @@ -231,3 +237,19 @@ extern "C" void select_newest_visible_dive() // No visible dive -> deselect all select_single_dive(nullptr); } + +extern "C" void select_trip(struct dive_trip *trip) +{ + if (trip && !trip->selected) { + trip->selected = true; + amount_trips_selected++; + } +} + +extern "C" void deselect_trip(struct dive_trip *trip) +{ + if (trip && trip->selected) { + trip->selected = false; + amount_trips_selected--; + } +} |