2019-02-11 14:34:43 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2019-11-24 12:26:29 +00:00
|
|
|
// Selection related functions
|
2019-02-11 14:34:43 +00:00
|
|
|
|
2019-11-24 12:26:29 +00:00
|
|
|
#ifndef SELECTION_H
|
|
|
|
#define SELECTION_H
|
2019-02-11 14:34:43 +00:00
|
|
|
|
2019-11-24 14:02:34 +00:00
|
|
|
struct dive;
|
|
|
|
|
|
|
|
extern int amount_selected;
|
2022-04-04 16:57:28 +00:00
|
|
|
extern struct dive *current_dive;
|
2019-11-24 14:02:34 +00:00
|
|
|
|
|
|
|
/*** C and C++ functions ***/
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
extern struct dive *first_selected_dive(void);
|
|
|
|
extern struct dive *last_selected_dive(void);
|
|
|
|
extern bool consecutive_selected(void);
|
2019-11-25 18:00:38 +00:00
|
|
|
extern void select_newest_visible_dive();
|
2019-12-06 08:47:59 +00:00
|
|
|
extern void select_single_dive(struct dive *d); // wrapper for setSelection() with a single dive. NULL clears the selection.
|
2020-05-02 12:34:40 +00:00
|
|
|
extern void select_trip(struct dive_trip *trip);
|
|
|
|
extern void deselect_trip(struct dive_trip *trip);
|
2020-05-02 16:14:44 +00:00
|
|
|
extern struct dive_trip *single_selected_trip(); // returns trip if exactly one trip is selected, NULL otherwise.
|
2020-05-02 12:41:52 +00:00
|
|
|
extern void clear_selection(void);
|
2019-11-24 14:02:34 +00:00
|
|
|
|
|
|
|
#if DEBUG_SELECTION_TRACKING
|
|
|
|
extern void dump_selection(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-11-24 12:26:29 +00:00
|
|
|
/*** C++-only functions ***/
|
2019-02-17 09:18:00 +00:00
|
|
|
|
2019-02-11 14:34:43 +00:00
|
|
|
#include <vector>
|
2022-05-21 18:38:17 +00:00
|
|
|
#include <QVector>
|
2019-02-11 14:34:43 +00:00
|
|
|
|
2019-02-17 09:18:00 +00:00
|
|
|
// Reset the selection to the dives of the "selection" vector and send the appropriate signals.
|
2022-04-04 16:57:28 +00:00
|
|
|
// Set the current dive to "currentDive" and the current dive computer to "currentDc".
|
|
|
|
// "currentDive" must be an element of "selection" (or null if "seletion" is empty).
|
|
|
|
// If "currentDc" is negative, an attempt will be made to keep the current computer number.
|
2022-05-21 18:38:17 +00:00
|
|
|
// Returns the list of selected dives
|
2022-09-17 17:07:35 +00:00
|
|
|
QVector<dive *> setSelectionCore(const std::vector<dive *> &selection, dive *currentDive);
|
2022-05-21 18:38:17 +00:00
|
|
|
|
|
|
|
// As above, but sends a signal to inform the frontend of the changed selection.
|
2022-05-21 11:14:47 +00:00
|
|
|
// Returns true if the current dive changed.
|
2022-05-21 18:38:17 +00:00
|
|
|
void setSelection(const std::vector<dive *> &selection, dive *currentDive, int currentDc);
|
2019-02-17 09:18:00 +00:00
|
|
|
|
2022-05-21 11:14:47 +00:00
|
|
|
// Set selection, but try to keep the current dive. If current dive is not in selection,
|
|
|
|
// find the nearest current dive in the selection
|
|
|
|
// Returns true if the current dive changed.
|
2022-05-21 18:38:17 +00:00
|
|
|
// Does not send a signal.
|
|
|
|
bool setSelectionKeepCurrent(const std::vector<dive *> &selection);
|
2022-05-21 11:14:47 +00:00
|
|
|
|
2022-08-27 15:28:34 +00:00
|
|
|
// Select all dive in a trip and sends a trip-selected signal
|
|
|
|
void setTripSelection(dive_trip *trip, dive *currentDive);
|
|
|
|
|
2022-05-21 11:14:47 +00:00
|
|
|
// Get currently selected dives
|
2019-02-17 09:18:00 +00:00
|
|
|
std::vector<dive *> getDiveSelection();
|
2022-05-21 11:14:47 +00:00
|
|
|
bool diveInSelection(const std::vector<dive *> &selection, const dive *d);
|
|
|
|
void updateSelection(std::vector<dive *> &selection, const std::vector<dive *> &add, const std::vector<dive *> &remove);
|
2019-02-17 09:18:00 +00:00
|
|
|
|
2019-11-24 12:26:29 +00:00
|
|
|
#endif // SELECTION_H
|