mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Dive list: signal correct trip in DiveTripModelTree::topLevelChanged
DiveTripModelTree::topLevelChanged() has pretty complex code, as it has to handle the fact that when adding/removing a dive from a trip, the trip can change its position. The code did not account for the fact that when moving an object back in the top level list, one has to subtract one from the new index, because the object was removed somewhere in the front of the list. To make matters worse, when an entry stayed where it was, this was realized by moving the entry right behind itself, which of course means that it stays where it is. But this meant that in the by far most common case (no moving) the wrong entry was updated. Fix this by subtracting 1 from the new index when moving an entry to the back. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5e29245e68
commit
2f77716e8f
1 changed files with 5 additions and 0 deletions
|
@ -759,6 +759,11 @@ void DiveTripModelTree::topLevelChanged(int idx)
|
|||
endMoveRows();
|
||||
}
|
||||
|
||||
// If we moved the object backwards in the array, we have to
|
||||
// subtract one from the index to account for the removed object.
|
||||
if (newIdx > idx)
|
||||
--newIdx;
|
||||
|
||||
// Finally, inform UI of changed trip header
|
||||
QModelIndex tripIdx = createIndex(newIdx, 0, noParent);
|
||||
dataChanged(tripIdx, tripIdx);
|
||||
|
|
Loading…
Reference in a new issue