mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Dive list: keep dives-in-trip list ordered after shift-times
On shift-times, the list of dives in a trip may become disordered. Reestablish order with sort_table(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9d3a5fa997
commit
ef98a4ff5a
1 changed files with 5 additions and 3 deletions
|
@ -605,15 +605,17 @@ void ShiftTime::redoit()
|
||||||
// Changing times may have unsorted the dive table
|
// Changing times may have unsorted the dive table
|
||||||
sort_table(&dive_table);
|
sort_table(&dive_table);
|
||||||
|
|
||||||
// We send one dives-deleted signal per trip (see comments in DiveListNotifier.h).
|
// We send one time changed signal per trip (see comments in DiveListNotifier.h).
|
||||||
// Therefore, collect all dives in a array and sort by trip.
|
// Therefore, collect all dives in an array and sort by trip.
|
||||||
std::vector<std::pair<dive_trip *, dive *>> dives;
|
std::vector<std::pair<dive_trip *, dive *>> dives;
|
||||||
dives.reserve(diveList.size());
|
dives.reserve(diveList.size());
|
||||||
for (dive *d: diveList)
|
for (dive *d: diveList)
|
||||||
dives.push_back({ d->divetrip, d });
|
dives.push_back({ d->divetrip, d });
|
||||||
|
|
||||||
// Send signals.
|
// Send signals and sort tables.
|
||||||
processByTrip(dives, [&](dive_trip *trip, const QVector<dive *> &divesInTrip) {
|
processByTrip(dives, [&](dive_trip *trip, const QVector<dive *> &divesInTrip) {
|
||||||
|
if (trip)
|
||||||
|
sort_table(&trip->dives); // Keep the trip-table in order
|
||||||
emit diveListNotifier.divesTimeChanged(trip, timeChanged, divesInTrip);
|
emit diveListNotifier.divesTimeChanged(trip, timeChanged, divesInTrip);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue