2019-05-31 16:09:14 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#ifndef TRIP_H
|
|
|
|
#define TRIP_H
|
|
|
|
|
|
|
|
#include "divelist.h"
|
2024-06-01 22:05:57 +02:00
|
|
|
#include "owning_table.h"
|
2019-05-31 16:09:14 +02:00
|
|
|
|
2024-05-31 17:15:47 +02:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
struct dive_trip
|
2019-05-31 16:09:14 +02:00
|
|
|
{
|
2024-05-31 17:15:47 +02:00
|
|
|
std::string location;
|
|
|
|
std::string notes;
|
2024-06-02 17:06:18 +02:00
|
|
|
std::vector<dive *> dives;
|
2019-09-14 19:26:34 +02:00
|
|
|
int id; /* unique ID for this trip: used to pass trips through QML. */
|
2019-05-31 16:09:14 +02:00
|
|
|
/* Used by the io-routines to mark trips that have already been written. */
|
2024-05-31 17:15:47 +02:00
|
|
|
bool saved = false;
|
|
|
|
bool autogen = false;
|
|
|
|
bool selected = false;
|
|
|
|
|
2024-06-02 17:06:18 +02:00
|
|
|
void sort_dives();
|
|
|
|
|
2024-05-31 17:15:47 +02:00
|
|
|
dive_trip();
|
|
|
|
~dive_trip();
|
|
|
|
};
|
2019-05-31 16:09:14 +02:00
|
|
|
|
2024-06-01 22:05:57 +02:00
|
|
|
int comp_trips(const dive_trip &t1, const dive_trip &t2);
|
2019-05-31 16:09:14 +02:00
|
|
|
|
2024-06-01 22:05:57 +02:00
|
|
|
struct trip_table : public sorted_owning_table<dive_trip, &comp_trips> {
|
2024-06-02 00:36:20 +02:00
|
|
|
dive_trip *get_by_uniq_id(int tripId) const;
|
2024-06-01 22:05:57 +02:00
|
|
|
};
|
2020-01-08 21:25:02 -08:00
|
|
|
|
2024-05-31 17:15:47 +02:00
|
|
|
extern void add_dive_to_trip(struct dive *, dive_trip *);
|
2019-05-31 16:09:14 +02:00
|
|
|
extern struct dive_trip *unregister_dive_from_trip(struct dive *dive);
|
|
|
|
|
2024-06-01 22:05:57 +02:00
|
|
|
extern timestamp_t trip_date(const struct dive_trip &trip);
|
|
|
|
|
|
|
|
extern std::unique_ptr<dive_trip> create_trip_from_dive(const struct dive *dive);
|
|
|
|
extern dive_trip *create_and_hookup_trip_from_dive(const struct dive *dive, struct trip_table &trip_table_arg);
|
2019-05-31 16:09:14 +02:00
|
|
|
|
2024-06-01 22:05:57 +02:00
|
|
|
// Result item of get_dives_to_autogroup()
|
|
|
|
struct dives_to_autogroup_result {
|
|
|
|
int from, to; // Group dives in the range [from, to)
|
|
|
|
dive_trip *trip; // Pointer to trip
|
|
|
|
std::unique_ptr<dive_trip> created_trip;
|
|
|
|
// Is set if the trip was newly created - caller has to store it.
|
|
|
|
};
|
2019-05-31 16:09:14 +02:00
|
|
|
|
2024-06-01 22:05:57 +02:00
|
|
|
extern std::vector<dives_to_autogroup_result> get_dives_to_autogroup(struct dive_table *table);
|
|
|
|
extern std::pair<dive_trip *, std::unique_ptr<dive_trip>> get_trip_for_new_dive(const struct dive *new_dive);
|
|
|
|
extern bool trips_overlap(const struct dive_trip &t1, const struct dive_trip &t2);
|
2019-05-31 16:09:14 +02:00
|
|
|
|
2024-06-01 22:05:57 +02:00
|
|
|
extern std::unique_ptr<dive_trip> combine_trips(struct dive_trip *trip_a, struct dive_trip *trip_b);
|
2019-05-31 16:09:14 +02:00
|
|
|
extern bool is_trip_before_after(const struct dive *dive, bool before);
|
2024-06-01 22:05:57 +02:00
|
|
|
extern bool trip_is_single_day(const struct dive_trip &trip);
|
2019-05-31 16:09:14 +02:00
|
|
|
extern int trip_shown_dives(const struct dive_trip *trip);
|
|
|
|
|
|
|
|
#ifdef DEBUG_TRIP
|
2024-05-04 18:53:41 +02:00
|
|
|
extern void dump_trip_list();
|
2019-05-31 16:09:14 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Make pointers to dive_trip and trip_table "Qt metatypes" so that they can be
|
|
|
|
* passed through QVariants and through QML. See comment in dive.h. */
|
|
|
|
#include <QObject>
|
|
|
|
Q_DECLARE_METATYPE(struct dive_trip *);
|
2024-06-01 22:05:57 +02:00
|
|
|
Q_DECLARE_METATYPE(trip_table *);
|
2019-05-31 16:09:14 +02:00
|
|
|
|
|
|
|
#endif
|