summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-06-05 17:28:22 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-05 17:49:39 +0900
commit4b405caa2c4704fe51f0f9425a91050199c17ac0 (patch)
treeb49124ad838e976aa7c1f1f17968e3a4c3fd2748 /qt-ui
parent4d937051ca4390874f741c1a313fccf622cffcd3 (diff)
downloadsubsurface-4b405caa2c4704fe51f0f9425a91050199c17ac0.tar.gz
Clean up divelist dive selection
Since we have a "selectDive()" method, let's just use it rather than opencoding it. Similarly for "unselectDives()". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelistview.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 97daff88f..19d27a53e 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -91,7 +91,7 @@ void DiveListView::headerClicked(int i)
QItemSelection oldSelection = selectionModel()->selection();
QList<struct dive*> currentSelectedDives;
DiveTripModel::Layout newLayout;
- bool scrolled = false;
+ bool first = true;
newLayout = i == (int) TreeItemDT::NR ? DiveTripModel::TREE : DiveTripModel::LIST;
@@ -104,7 +104,7 @@ void DiveListView::headerClicked(int i)
currentSelectedDives.push_back(d);
}
- selectionModel()->clearSelection();
+ unselectDives();
/* No layout change? Just re-sort, and scroll to first selection, making sure all selections are expanded */
if (currentLayout == newLayout) {
@@ -119,19 +119,8 @@ void DiveListView::headerClicked(int i)
// repopulat the selections.
Q_FOREACH(struct dive *d, currentSelectedDives) {
- QModelIndexList match = m->match(m->index(0,0), TreeItemDT::NR, d->number, 1, Qt::MatchRecursive);
- QModelIndex idx = match.first();
-
- if (newLayout == DiveTripModel::TREE) {
- QModelIndex parent = idx.parent();
- if (parent.isValid())
- expand(parent);
- }
- selectionModel()->select( idx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
- if (!scrolled) {
- scrollTo(idx, PositionAtCenter);
- scrolled = true;
- }
+ selectDive(d, first);
+ first = false;
}
}