mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add ability to make a dive computer the first dive computer of a dive
If a dive has multiple dive computers we enable a special context menu when the user right-clicks on the dive computer name AND is not already showing the first dive computer. In that case we offer to make the currently shown dive computer the first one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
419434f494
commit
a117428ff4
4 changed files with 68 additions and 2 deletions
20
dive.c
20
dive.c
|
@ -19,6 +19,26 @@ static const char *default_tags[] = {
|
|||
QT_TRANSLATE_NOOP("gettextFromC", "deco")
|
||||
};
|
||||
|
||||
void make_first_dc()
|
||||
{
|
||||
struct divecomputer *dc = ¤t_dive->dc;
|
||||
struct divecomputer *newdc = malloc(sizeof(*newdc));
|
||||
struct divecomputer *cur_dc = current_dc; /* needs to be in a local variable so the macro isn't re-executed */
|
||||
|
||||
/* skip the current DC in the linked list */
|
||||
while (dc && dc->next != cur_dc)
|
||||
dc = dc->next;
|
||||
if (!dc) {
|
||||
fprintf(stderr, "data inconsistent: can't find the current DC");
|
||||
return;
|
||||
}
|
||||
dc->next = cur_dc->next;
|
||||
*newdc = current_dive->dc;
|
||||
current_dive->dc = *cur_dc;
|
||||
current_dive->dc.next = newdc;
|
||||
free(cur_dc);
|
||||
}
|
||||
|
||||
void add_event(struct divecomputer *dc, int time, int type, int flags, int value, const char *name)
|
||||
{
|
||||
struct event *ev, **p;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue