From 77a1ef9ebec188865c01b08b32ea1fde29575e69 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 13 Nov 2013 18:07:10 -0200 Subject: Expand the trip of the first selected dive. I probably broke this a while ago, as I was not using the big dirk dive file to test ( just using some random files over the test folder. ) Now it's working as it should. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/divelistview.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 9c30f99e4..c1dde082b 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -104,25 +104,21 @@ int DiveListView::lastVisibleColumn() void DiveListView::backupExpandedRows(){ expandedRows.clear(); - for(int i = 0; i < model()->rowCount(); i++){ - if(isExpanded( model()->index(i, 0) )){ + for(int i = 0; i < model()->rowCount(); i++) + if(isExpanded( model()->index(i, 0) )) expandedRows.push_back(i); - } - } } void DiveListView::restoreExpandedRows(){ - Q_FOREACH(const int &i, expandedRows){ + Q_FOREACH(const int &i, expandedRows) setExpanded( model()->index(i, 0), true ); - } } void DiveListView::fixMessyQtModelBehaviour() { QAbstractItemModel *m = model(); - for(int i = 0; i < model()->rowCount(); i++){ + for(int i = 0; i < model()->rowCount(); i++) if (m->rowCount( m->index(i, 0) ) != 0) setFirstColumnSpanned(i, QModelIndex(), true); - } } // this only remembers dives that were selected, not trips @@ -278,6 +274,9 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort) } } setupUi(); + QModelIndex curr = selectionModel()->currentIndex(); + if (curr.parent().isValid() && !isExpanded(curr.parent())) + expand(curr.parent()); } void DiveListView::reloadHeaderActions() -- cgit v1.2.3-70-g09d2