Dive list: replace dive-list of trips by a table

The dives of each trip were kept in a list. Replace this by a
struct dive_table. This will make it significantly easier to
keep the dives of a trip in sorted state.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-11-08 16:58:33 +01:00 committed by Dirk Hohndel
parent bc7afebc23
commit 6b283e598a
9 changed files with 63 additions and 80 deletions

View file

@ -1275,8 +1275,6 @@ bool QMLManager::undoDelete(int id)
struct dive_trip *trip = deletedDive->divetrip;
tripflag_t tripflag = deletedDive->tripflag; // this gets overwritten in add_dive_to_trip()
deletedDive->divetrip = NULL;
deletedDive->next = NULL;
deletedDive->pprev = NULL;
add_dive_to_trip(deletedDive, trip);
deletedDive->tripflag = tripflag;
}
@ -1309,11 +1307,11 @@ void QMLManager::deleteDive(int id)
memset(deletedTrip, 0, sizeof(struct dive_trip));
}
// if this is the last dive in that trip, remember the trip as well
if (d->divetrip && d->divetrip->nrdives == 1) {
if (d->divetrip && d->divetrip->dives.nr == 1) {
*deletedTrip = *d->divetrip;
deletedTrip->location = copy_string(d->divetrip->location);
deletedTrip->notes = copy_string(d->divetrip->notes);
deletedTrip->nrdives = 0;
deletedTrip->dives.nr = 0;
deletedDive->divetrip = deletedTrip;
}
DiveListModel::instance()->removeDiveById(id);