undo: more fine-grained editing of cylinder

Don't overwrite the full cylinder when editing a single field.
Implement three "modes": editing of type, pressure and gasmix.

Don't consider individual fields, because some of them are
related. E.g. you can change the gasmix by setting the MOD.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-03-27 21:09:59 +01:00
parent 4e8a838f74
commit 2eeb5f4fc2
7 changed files with 64 additions and 22 deletions

View file

@ -282,15 +282,6 @@ void remove_cylinder(struct dive *dive, int idx)
remove_from_cylinder_table(&dive->cylinders, idx);
}
// cyl is cloned.
void set_cylinder(struct dive *dive, int idx, cylinder_t cyl)
{
if (idx < 0 || idx >= dive->cylinders.nr)
return;
free_cylinder(dive->cylinders.cylinders[idx]);
dive->cylinders.cylinders[idx] = clone_cylinder(cyl);
}
void remove_weightsystem(struct dive *dive, int idx)
{
remove_from_weightsystem_table(&dive->weightsystems, idx);

View file

@ -85,7 +85,6 @@ extern void add_cylinder_description(const cylinder_type_t *);
extern void add_weightsystem_description(const weightsystem_t *);
extern bool same_weightsystem(weightsystem_t w1, weightsystem_t w2);
extern void remove_cylinder(struct dive *dive, int idx);
extern void set_cylinder(struct dive *dive, int idx, cylinder_t ws);
extern void remove_weightsystem(struct dive *dive, int idx);
extern void set_weightsystem(struct dive *dive, int idx, weightsystem_t ws);
extern void reset_cylinders(struct dive *dive, bool track_gas);