mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: fix undo of dive merging
When merging two dives, if a divesite is chosen that doesn't have a GPS location, but another divesite has a GPS location, then the GPS location of the former is set to that of the latter. However, that was done outside of the undo system, so that it is not undone and the frontend is not made aware of the change. Fix this. To simplify things, move the code from the undo machinery to the core. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
27a89b0232
commit
cc55c442a3
6 changed files with 81 additions and 44 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include "divesitetable.h"
|
||||
#include "units.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
struct dive;
|
||||
struct divelog;
|
||||
|
|
@ -17,7 +18,7 @@ int comp_dives_ptr(const struct dive *a, const struct dive *b);
|
|||
|
||||
struct merge_result {
|
||||
std::unique_ptr<struct dive> dive;
|
||||
dive_trip *trip;
|
||||
std::optional<location_t> set_location; // change location of dive site
|
||||
};
|
||||
|
||||
struct dive_table : public sorted_owning_table<dive, &comp_dives> {
|
||||
|
|
@ -40,13 +41,14 @@ struct dive_table : public sorted_owning_table<dive, &comp_dives> {
|
|||
std::array<std::unique_ptr<dive>, 2> split_divecomputer(const struct dive &src, int num) const;
|
||||
std::array<std::unique_ptr<dive>, 2> split_dive(const struct dive &dive) const;
|
||||
std::array<std::unique_ptr<dive>, 2> split_dive_at_time(const struct dive &dive, duration_t time) const;
|
||||
merge_result merge_dives(const struct dive &a_in, const struct dive &b_in, int offset, bool prefer_downloaded) const;
|
||||
merge_result merge_dives(const std::vector<dive *> &dives) const;
|
||||
std::unique_ptr<dive> try_to_merge(const struct dive &a, const struct dive &b, bool prefer_downloaded) const;
|
||||
bool has_dive(unsigned int deviceid, unsigned int diveid) const;
|
||||
std::unique_ptr<dive> clone_delete_divecomputer(const struct dive &d, int dc_number);
|
||||
private:
|
||||
int calculate_cns(struct dive &dive) const; // Note: writes into dive->cns
|
||||
std::array<std::unique_ptr<dive>, 2> split_dive_at(const struct dive &dive, int a, int b) const;
|
||||
std::unique_ptr<dive> merge_two_dives(const struct dive &a_in, const struct dive &b_in, int offset, bool prefer_downloaded) const;
|
||||
};
|
||||
|
||||
void clear_dive_file_data();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue