diff options
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 19 |
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(); |