2017-04-27 18:18:03 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2011-09-05 19:12:58 +00:00
|
|
|
#ifndef DIVELIST_H
|
|
|
|
#define DIVELIST_H
|
|
|
|
|
2019-03-04 22:20:29 +00:00
|
|
|
#include "dive.h"
|
|
|
|
|
2013-04-01 10:51:49 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
2013-04-24 23:52:18 +00:00
|
|
|
#endif
|
2013-04-24 23:33:29 +00:00
|
|
|
|
2015-06-20 13:45:12 +00:00
|
|
|
/* this is used for both git and xml format */
|
|
|
|
#define DATAFORMAT_VERSION 3
|
|
|
|
|
2011-11-13 17:29:07 +00:00
|
|
|
extern void update_cylinder_related_info(struct dive *);
|
2017-12-11 21:23:52 +00:00
|
|
|
extern void mark_divelist_changed(bool);
|
2011-09-21 04:29:09 +00:00
|
|
|
extern int unsaved_changes(void);
|
2017-11-22 19:42:33 +00:00
|
|
|
extern int init_decompression(struct deco_state *ds, struct dive *dive);
|
2013-04-07 03:49:06 +00:00
|
|
|
|
|
|
|
/* divelist core logic functions */
|
2018-09-23 10:53:35 +00:00
|
|
|
extern void process_loaded_dives();
|
2019-01-13 20:53:57 +00:00
|
|
|
/* flags for process_imported_dives() */
|
|
|
|
#define IMPORT_PREFER_IMPORTED (1 << 0)
|
|
|
|
#define IMPORT_IS_DOWNLOADED (1 << 1)
|
|
|
|
#define IMPORT_MERGE_ALL_TRIPS (1 << 2)
|
|
|
|
#define IMPORT_ADD_TO_NEW_TRIP (1 << 3)
|
2019-03-03 14:12:22 +00:00
|
|
|
extern void add_imported_dives(struct dive_table *import_table, struct trip_table *import_trip_table, struct dive_site_table *import_sites_table,
|
|
|
|
int flags);
|
|
|
|
extern void process_imported_dives(struct dive_table *import_table, struct trip_table *import_trip_table, struct dive_site_table *import_sites_table,
|
|
|
|
int flags,
|
2018-12-23 21:08:00 +00:00
|
|
|
struct dive_table *dives_to_add, struct dive_table *dives_to_remove,
|
2019-03-03 14:12:22 +00:00
|
|
|
struct trip_table *trips_to_add, struct dive_site_table *sites_to_add);
|
2018-10-13 20:32:53 +00:00
|
|
|
extern char *get_dive_gas_string(const struct dive *dive);
|
2013-10-07 20:43:17 +00:00
|
|
|
|
2018-11-24 09:11:07 +00:00
|
|
|
extern int dive_table_get_insertion_index(struct dive_table *table, struct dive *dive);
|
2019-03-04 22:20:29 +00:00
|
|
|
extern void add_to_dive_table(struct dive_table *table, int idx, struct dive *dive);
|
2019-04-14 13:37:19 +00:00
|
|
|
extern void append_dive(struct dive *dive);
|
2019-05-31 14:09:14 +00:00
|
|
|
extern void insert_dive(struct dive_table *table, struct dive *d);
|
2018-10-13 20:32:53 +00:00
|
|
|
extern void get_dive_gas(const struct dive *dive, int *o2_p, int *he_p, int *o2low_p);
|
2018-08-23 17:18:43 +00:00
|
|
|
extern int get_divenr(const struct dive *dive);
|
2019-03-11 23:25:31 +00:00
|
|
|
extern int remove_dive(const struct dive *dive, struct dive_table *table);
|
2013-09-24 10:42:40 +00:00
|
|
|
extern bool consecutive_selected();
|
Undo: select dives after add, remove, merge, split dive commands
Select the proper dives after the add, remove, split and merge
dives commands on undo *and* redo. Generally, select the added
dives. For undo of add, remember the pre-addition selection.
For redo of remove, select the closest dive to the first removed
dive.
The biggest part of the commit is the signal-interface between
the dive commands and the dive-list model and dive-list view.
This is done in two steps:
1) To the DiveTripModel in batches of trips. The dive trip model
transforms the dives into indices.
2) To the DiveListView. The DiveListView has to translate the
DiveTripModel indexes to actual indexes via its QSortFilterProxy-
model.
For code-reuse, derive all divelist-changing commands from a new base-class,
which has a flag that describes whether the divelist changed. The helper
functions which add and remove dives are made members of the base class and
set the flag is a selected dive is added or removed.
To properly detect when the current dive was deleted it
became necessary to turn the current dive from an index
to a pointer, because indices are not stable.
Unfortunately, in some cases an index was expected and these
places now have to transform the dive into an index. These
should be converted in due course.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-03 09:35:43 +00:00
|
|
|
extern void select_dive(struct dive *dive);
|
|
|
|
extern void deselect_dive(struct dive *dive);
|
2014-11-12 06:59:04 +00:00
|
|
|
extern void filter_dive(struct dive *d, bool shown);
|
2014-05-24 15:27:42 +00:00
|
|
|
extern struct dive *first_selected_dive();
|
|
|
|
extern struct dive *last_selected_dive();
|
2018-07-19 20:35:25 +00:00
|
|
|
extern int get_dive_nr_at_idx(int idx);
|
2014-08-18 19:12:05 +00:00
|
|
|
extern void set_dive_nr_for_current_dive();
|
2018-10-06 07:21:27 +00:00
|
|
|
extern timestamp_t get_surface_interval(timestamp_t when);
|
2018-09-28 08:21:23 +00:00
|
|
|
extern void delete_dive_from_table(struct dive_table *table, int idx);
|
Undo: select dives after add, remove, merge, split dive commands
Select the proper dives after the add, remove, split and merge
dives commands on undo *and* redo. Generally, select the added
dives. For undo of add, remember the pre-addition selection.
For redo of remove, select the closest dive to the first removed
dive.
The biggest part of the commit is the signal-interface between
the dive commands and the dive-list model and dive-list view.
This is done in two steps:
1) To the DiveTripModel in batches of trips. The dive trip model
transforms the dives into indices.
2) To the DiveListView. The DiveListView has to translate the
DiveTripModel indexes to actual indexes via its QSortFilterProxy-
model.
For code-reuse, derive all divelist-changing commands from a new base-class,
which has a flag that describes whether the divelist changed. The helper
functions which add and remove dives are made members of the base class and
set the flag is a selected dive is added or removed.
To properly detect when the current dive was deleted it
became necessary to turn the current dive from an index
to a pointer, because indices are not stable.
Unfortunately, in some cases an index was expected and these
places now have to transform the dive into an index. These
should be converted in due course.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-03 09:35:43 +00:00
|
|
|
extern struct dive *find_next_visible_dive(timestamp_t when);
|
2019-05-31 14:09:14 +00:00
|
|
|
|
|
|
|
extern int comp_dives(const struct dive *a, const struct dive *b);
|
2013-04-07 03:49:06 +00:00
|
|
|
|
2015-06-20 13:45:12 +00:00
|
|
|
int get_min_datafile_version();
|
|
|
|
void reset_min_datafile_version();
|
|
|
|
void report_datafile_version(int version);
|
2016-04-14 12:34:19 +00:00
|
|
|
int get_dive_id_closest_to(timestamp_t when);
|
2015-07-24 20:18:30 +00:00
|
|
|
void clear_dive_file_data();
|
2019-06-04 18:59:08 +00:00
|
|
|
void clear_dive_table(struct dive_table *table);
|
2015-06-20 13:45:12 +00:00
|
|
|
|
2013-04-07 03:49:06 +00:00
|
|
|
#ifdef DEBUG_TRIP
|
|
|
|
extern void dump_selection(void);
|
|
|
|
#endif
|
|
|
|
|
2013-04-01 10:51:49 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // DIVELIST_H
|