Maintain opened the trips of the selected dive.

In various occasions the branches of selected dives
got collapsed because I'm dummy boy and didn't programmed
the logic correctly.

This one correctly works for the few cases that I'v tried,
I'm verifying if the current selected index is a trip or
a dive, and asking to expand it.

The expanded state is lost because we delete and recreate
the model ( and we do that because we can switch between
tree and table model ).

Now I think we correctly track the cornercases.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2013-11-15 12:01:56 -02:00 committed by Dirk Hohndel
parent 1e63579cc6
commit bae41ddafb

View file

@ -274,9 +274,15 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort)
}
}
setupUi();
QModelIndex curr = selectionModel()->currentIndex();
if (curr.parent().isValid() && !isExpanded(curr.parent()))
expand(curr.parent());
if(selectedIndexes().count()){
QModelIndex curr = selectedIndexes().first();
curr = curr.parent().isValid() ? curr.parent() : curr;
if(!isExpanded(curr)){
setAnimated(false);
expand(curr);
setAnimated(true);
}
}
}
void DiveListView::reloadHeaderActions()