2019-05-31 14:09:14 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#ifndef TRIP_H
|
|
|
|
#define TRIP_H
|
|
|
|
|
|
|
|
#include "divelist.h"
|
|
|
|
|
2024-06-07 08:25:09 +00:00
|
|
|
struct divelog;
|
2024-05-31 15:15:47 +00:00
|
|
|
|
|
|
|
struct dive_trip
|
2019-05-31 14:09:14 +00:00
|
|
|
{
|
2024-05-31 15:15:47 +00:00
|
|
|
std::string location;
|
|
|
|
std::string notes;
|
2024-06-02 15:06:18 +00:00
|
|
|
std::vector<dive *> dives;
|
2019-09-14 17:26:34 +00:00
|
|
|
int id; /* unique ID for this trip: used to pass trips through QML. */
|
2019-05-31 14:09:14 +00:00
|
|
|
/* Used by the io-routines to mark trips that have already been written. */
|
2024-05-31 15:15:47 +00:00
|
|
|
bool saved = false;
|
|
|
|
bool autogen = false;
|
|
|
|
bool selected = false;
|
|
|
|
|
|
|
|
dive_trip();
|
|
|
|
~dive_trip();
|
2024-06-08 13:28:16 +00:00
|
|
|
|
|
|
|
void sort_dives();
|
|
|
|
void add_dive(struct dive *);
|
|
|
|
timestamp_t date() const;
|
|
|
|
bool is_single_day() const;
|
|
|
|
int shown_dives() const;
|
2024-05-31 15:15:47 +00:00
|
|
|
};
|
2019-05-31 14:09:14 +00:00
|
|
|
|
2024-06-01 20:05:57 +00:00
|
|
|
int comp_trips(const dive_trip &t1, const dive_trip &t2);
|
2019-05-31 14:09:14 +00:00
|
|
|
|
|
|
|
extern struct dive_trip *unregister_dive_from_trip(struct dive *dive);
|
|
|
|
|
2024-06-01 20:05:57 +00:00
|
|
|
extern std::unique_ptr<dive_trip> create_trip_from_dive(const struct dive *dive);
|
2019-05-31 14:09:14 +00:00
|
|
|
|
2024-06-01 20:05:57 +00:00
|
|
|
// Result item of get_dives_to_autogroup()
|
|
|
|
struct dives_to_autogroup_result {
|
2024-06-07 08:25:09 +00:00
|
|
|
size_t from, to; // Group dives in the range [from, to)
|
2024-06-01 20:05:57 +00:00
|
|
|
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 14:09:14 +00:00
|
|
|
|
2024-06-07 08:25:09 +00:00
|
|
|
extern std::vector<dives_to_autogroup_result> get_dives_to_autogroup(const struct dive_table &table);
|
|
|
|
extern std::pair<dive_trip *, std::unique_ptr<dive_trip>> get_trip_for_new_dive(const struct divelog &log, const struct dive *new_dive);
|
2024-06-01 20:05:57 +00:00
|
|
|
extern bool trips_overlap(const struct dive_trip &t1, const struct dive_trip &t2);
|
2019-05-31 14:09:14 +00:00
|
|
|
|
2024-06-01 20:05:57 +00:00
|
|
|
extern std::unique_ptr<dive_trip> combine_trips(struct dive_trip *trip_a, struct dive_trip *trip_b);
|
2019-05-31 14:09:14 +00:00
|
|
|
|
2024-06-07 08:25:09 +00:00
|
|
|
/* Make pointers to dive_trip "Qt metatypes" so that they can be
|
2019-05-31 14:09:14 +00:00
|
|
|
* passed through QVariants and through QML. See comment in dive.h. */
|
|
|
|
#include <QObject>
|
|
|
|
Q_DECLARE_METATYPE(struct dive_trip *);
|
|
|
|
|
|
|
|
#endif
|