From bae41ddafb95a56e29f3ef423288197b98b3fa68 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 15 Nov 2013 12:01:56 -0200 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/divelistview.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 89ee6a6e7..da4229de8 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -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() -- cgit v1.2.3-70-g09d2