diff options
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index d192d84aa..d2354d910 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -55,6 +55,24 @@ void DiveListView::keyReleaseEvent(QKeyEvent* event) QWidget::keyReleaseEvent(event); } +void DiveListView::currentChanged(const QModelIndex& current, const QModelIndex& previous) +{ + if (!current.isValid()) + return; + const QAbstractItemModel *model = current.model(); + int selectedDive = 0; + struct dive *dive = (struct dive*) model->data(current, TreeItemDT::DIVE_ROLE).value<void*>(); + if (!dive) { // it's a trip! select first child. + dive = (struct dive*) model->data(current.child(0,0), TreeItemDT::DIVE_ROLE).value<void*>(); + selectedDive = get_divenr(dive); + }else{ + selectedDive = get_divenr(dive); + } + if (selectedDive == selected_dive) + return; + Q_EMIT currentDiveChanged(selectedDive); +} + void DiveListView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) { QList<QModelIndex> parents; |