diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/dive.c | 15 | ||||
-rw-r--r-- | core/dive.h | 1 | ||||
-rw-r--r-- | core/subsurface-qt/DiveListNotifier.h | 3 |
3 files changed, 14 insertions, 5 deletions
diff --git a/core/dive.c b/core/dive.c index b82970862..14ab13f95 100644 --- a/core/dive.c +++ b/core/dive.c @@ -649,6 +649,15 @@ struct dive *clone_dive(struct dive *s) if (what._component) \ d->_component = copy_string(s->_component) +void copy_weights(const struct dive *s, struct dive *d) +{ + for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) { + free((void *)d->weightsystem[i].description); + d->weightsystem[i] = s->weightsystem[i]; + d->weightsystem[i].description = copy_string(s->weightsystem[i].description); + } +} + // copy elements, depending on bits in what that are set void selective_copy_dive(const struct dive *s, struct dive *d, struct dive_components what, bool clear) { @@ -671,11 +680,7 @@ void selective_copy_dive(const struct dive *s, struct dive *d, struct dive_compo if (what.cylinders) copy_cylinders(s, d, false); if (what.weights) - for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) { - free((void *)d->weightsystem[i].description); - d->weightsystem[i] = s->weightsystem[i]; - d->weightsystem[i].description = copy_string(s->weightsystem[i].description); - } + copy_weights(s, d); } #undef CONDITIONAL_COPY_STRING diff --git a/core/dive.h b/core/dive.h index 06abc0df2..6e4940452 100644 --- a/core/dive.h +++ b/core/dive.h @@ -546,6 +546,7 @@ extern void copy_events(const struct divecomputer *s, struct divecomputer *d); extern void free_events(struct event *ev); extern void copy_cylinders(const struct dive *s, struct dive *d, bool used_only); extern void copy_samples(const struct divecomputer *s, struct divecomputer *d); +extern void copy_weights(const struct dive *s, struct dive *d); extern bool is_cylinder_used(const struct dive *dive, int idx); extern bool is_cylinder_prot(const struct dive *dive, int idx); extern void fill_default_cylinder(cylinder_t *cyl); diff --git a/core/subsurface-qt/DiveListNotifier.h b/core/subsurface-qt/DiveListNotifier.h index 53009410e..46e160208 100644 --- a/core/subsurface-qt/DiveListNotifier.h +++ b/core/subsurface-qt/DiveListNotifier.h @@ -51,6 +51,9 @@ signals: void divesMovedBetweenTrips(dive_trip *from, dive_trip *to, bool deleteFrom, bool createTo, const QVector<dive *> &dives); void divesTimeChanged(dive_trip *trip, timestamp_t delta, const QVector<dive *> &dives); + void cylindersReset(dive_trip *trip, const QVector<dive *> &dives); + void weightsystemsReset(dive_trip *trip, const QVector<dive *> &dives); + // Selection-signals come in two kinds: // - divesSelected, divesDeselected and currentDiveChanged are finer grained and are // called batch-wise per trip (except currentDiveChanged, of course). These signals |