summaryrefslogtreecommitdiffstats
path: root/qt-ui/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-06-05 15:41:52 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-05 16:40:27 +0900
commita737f595538584844041adda02bea5a5dae48d3d (patch)
tree3c0e1ca5be9075360167e53324235bf83f0ec821 /qt-ui/divelistview.cpp
parentb533cf299fba1b2d9dd4737f109caf5aba042d7a (diff)
downloadsubsurface-a737f595538584844041adda02bea5a5dae48d3d.tar.gz
First cut at selecting dives from the map
We'll want to enhance this: better logic for which dives are near the selection, and it's probably best to have a "control-click" that adds the dives to the selection rather than deselecting all the old ones. But it's already useful. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r--qt-ui/divelistview.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 1e822869b..6306f5f8d 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -40,6 +40,25 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec
connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString)));
}
+void DiveListView::unselectDives()
+{
+ selectionModel()->clearSelection();
+}
+
+void DiveListView::selectDive(struct dive *dive, bool scrollto)
+{
+ QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
+ QModelIndexList match = m->match(m->index(0,0), TreeItemDT::NR, dive->number, 1, Qt::MatchRecursive);
+ QModelIndex idx = match.first();
+
+ QModelIndex parent = idx.parent();
+ if (parent.isValid())
+ expand(parent);
+ selectionModel()->select( idx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
+ if (scrollto)
+ scrollTo(idx, PositionAtCenter);
+}
+
void DiveListView::showSearchEdit()
{
searchBox->show();