mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Hook up adding a dive
This gets things mostly right. It creates a dive and uses the planner widget to create samples which are copied into the dive. It fills in some reasonable defaults (DC model, timestamp), but doesn't allow editing the timestamp (or the temperatures and air pressure). On accept the planner gets reset and the dive appears correctly in the dive list. Cancel still needs to be handled. And I bet there are many subtle bugs lurking here and there. But it's a start. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
5a96389cd3
commit
46b125782e
6 changed files with 53 additions and 10 deletions
13
dive.c
13
dive.c
|
|
@ -161,6 +161,19 @@ struct dive *alloc_dive(void)
|
|||
return dive;
|
||||
}
|
||||
|
||||
void copy_samples(struct dive* s, struct dive* d)
|
||||
{
|
||||
/* instead of carefully copying them one by one and calling add_sample
|
||||
* over and over again, let's just copy the whole blob */
|
||||
if (!s || !d)
|
||||
return;
|
||||
int nr = s->dc.samples;
|
||||
d->dc.samples = nr;
|
||||
d->dc.sample = malloc(nr * sizeof(struct sample));
|
||||
if (d->dc.sample)
|
||||
memcpy(d->dc.sample, s->dc.sample, nr * sizeof(struct sample));
|
||||
}
|
||||
|
||||
struct sample *prepare_sample(struct divecomputer *dc)
|
||||
{
|
||||
if (dc) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue