mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Dive list: retain selection on moval of dives
The current code cheats when it comes to move dives inside a trip or move dives between trips: Instead of using the *MoveRows() functionality, the dives are removed from and re-added to the respective trips. This loses the selection. Therefore, remember which of the moved dives are selected and select them manually after they are re-added. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3c6cdfd8c0
commit
0cca36377b
1 changed files with 18 additions and 0 deletions
|
@ -1075,6 +1075,16 @@ void DiveTripModel::divesChanged(dive_trip *trip, const QVector<dive *> &divesIn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<dive *> filterSelectedDives(const QVector<dive *> &dives)
|
||||||
|
{
|
||||||
|
QVector<dive *> res;
|
||||||
|
res.reserve(dives.size());
|
||||||
|
for (dive *d: dives)
|
||||||
|
if (d->selected)
|
||||||
|
res.append(d);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
void DiveTripModel::divesMovedBetweenTrips(dive_trip *from, dive_trip *to, bool deleteFrom, bool createTo, const QVector<dive *> &dives)
|
void DiveTripModel::divesMovedBetweenTrips(dive_trip *from, dive_trip *to, bool deleteFrom, bool createTo, const QVector<dive *> &dives)
|
||||||
{
|
{
|
||||||
// Move dives between trips. This is an "interesting" problem, as we might
|
// Move dives between trips. This is an "interesting" problem, as we might
|
||||||
|
@ -1090,8 +1100,12 @@ void DiveTripModel::divesMovedBetweenTrips(dive_trip *from, dive_trip *to, bool
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Cheating!
|
// Cheating!
|
||||||
|
// Unfortunately, removing the dives means that their selection is lost.
|
||||||
|
// Thus, remember the selection and re-add it later.
|
||||||
|
QVector<dive *> selectedDives = filterSelectedDives(dives);
|
||||||
divesAdded(to, createTo, dives);
|
divesAdded(to, createTo, dives);
|
||||||
divesDeleted(from, deleteFrom, dives);
|
divesDeleted(from, deleteFrom, dives);
|
||||||
|
divesSelected(to, selectedDives);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveTripModel::divesTimeChanged(dive_trip *trip, timestamp_t delta, const QVector<dive *> &dives)
|
void DiveTripModel::divesTimeChanged(dive_trip *trip, timestamp_t delta, const QVector<dive *> &dives)
|
||||||
|
@ -1104,8 +1118,12 @@ void DiveTripModel::divesTimeChanged(dive_trip *trip, timestamp_t delta, const Q
|
||||||
// moved by the same delta.
|
// moved by the same delta.
|
||||||
|
|
||||||
// Cheating!
|
// Cheating!
|
||||||
|
// Unfortunately, removing the dives means that their selection is lost.
|
||||||
|
// Thus, remember the selection and re-add it later.
|
||||||
|
QVector<dive *> selectedDives = filterSelectedDives(dives);
|
||||||
divesDeleted(trip, false, dives);
|
divesDeleted(trip, false, dives);
|
||||||
divesAdded(trip, false, dives);
|
divesAdded(trip, false, dives);
|
||||||
|
divesSelected(trip, selectedDives);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveTripModel::divesSelected(dive_trip *trip, const QVector<dive *> &dives)
|
void DiveTripModel::divesSelected(dive_trip *trip, const QVector<dive *> &dives)
|
||||||
|
|
Loading…
Add table
Reference in a new issue