core: replace list of dives in trip by std::vector<>

The dive_table will be converted into a table of owning pointers.
Since the trip has only non-owning pointers to dives, turn
its dive_table into an std::vector<dive *>.

Add a helper functions to add/remove items in a sorted list.
These could be used elsewhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-02 17:06:18 +02:00 committed by bstoeger
parent 71518fa77e
commit 5c7cfb1057
12 changed files with 107 additions and 86 deletions

View file

@ -496,8 +496,8 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS
removeFromSelection.push_back(dive);
} else if (dive_trip *trip = model->data(index, DiveTripModelBase::TRIP_ROLE).value<dive_trip *>()) {
deselect_trip(trip);
for (int i = 0; i < trip->dives.nr; ++i)
removeFromSelection.push_back(trip->dives.dives[i]);
for (auto dive: trip->dives)
removeFromSelection.push_back(dive);
}
}
for (const QModelIndex &index: newSelected.indexes()) {
@ -510,8 +510,8 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS
addToSelection.push_back(dive);
} else if (dive_trip *trip = model->data(index, DiveTripModelBase::TRIP_ROLE).value<dive_trip *>()) {
select_trip(trip);
for (int i = 0; i < trip->dives.nr; ++i)
addToSelection.push_back(trip->dives.dives[i]);
for (struct dive *d: trip->dives)
addToSelection.push_back(d);
selectTripItems(index);
}
}