diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/selection.cpp | 24 | ||||
-rw-r--r-- | core/selection.h | 2 | ||||
-rw-r--r-- | core/trip.h | 1 |
3 files changed, 26 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--; + } +} diff --git a/core/selection.h b/core/selection.h index 8fe5707ce..55055de4a 100644 --- a/core/selection.h +++ b/core/selection.h @@ -21,6 +21,8 @@ extern struct dive *last_selected_dive(void); extern bool consecutive_selected(void); extern void select_newest_visible_dive(); extern void select_single_dive(struct dive *d); // wrapper for setSelection() with a single dive. NULL clears the selection. +extern void select_trip(struct dive_trip *trip); +extern void deselect_trip(struct dive_trip *trip); #if DEBUG_SELECTION_TRACKING extern void dump_selection(void); diff --git a/core/trip.h b/core/trip.h index c9335fc0a..976275736 100644 --- a/core/trip.h +++ b/core/trip.h @@ -17,6 +17,7 @@ typedef struct dive_trip /* Used by the io-routines to mark trips that have already been written. */ bool saved; bool autogen; + bool selected; } dive_trip_t; typedef struct trip_table { |