mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Undo: update cylinder and weight models on paste
When pasting (or undoing paste) the cylinders or weights may change. Send the appropriate signals and update the models accordingly. Currently, this means copying from current dive to displayed dive, but hopefully we can get rid of "displayed_dive" in the not so distant future. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9ed5cf16a4
commit
9fd87fa080
8 changed files with 52 additions and 5 deletions
15
core/dive.c
15
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue