diff options
-rw-r--r-- | desktop-widgets/divelistview.cpp | 13 | ||||
-rw-r--r-- | desktop-widgets/divelistview.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 4af42e713..29dabfa36 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -554,6 +554,19 @@ void DiveListView::mouseReleaseEvent(QMouseEvent *event) selectionChangeDone(); } +void DiveListView::keyPressEvent(QKeyEvent *event) +{ + // Hook into cursor-up and cursor-down events and update selection if necessary. + // See comment in mouseReleaseEvent() + if (event->key() != Qt::Key_Down && event->key() != Qt::Key_Up) + return QTreeView::keyPressEvent(event); + QModelIndexList selectionBefore = selectionModel()->selectedRows(); + QTreeView::keyPressEvent(event); + QModelIndexList selectionAfter = selectionModel()->selectedRows(); + if (selectionBefore != selectionAfter) + selectionChangeDone(); +} + void DiveListView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags) { // We hook into QTreeView's setSelection() to update the UI diff --git a/desktop-widgets/divelistview.h b/desktop-widgets/divelistview.h index 20f568479..b31d8039e 100644 --- a/desktop-widgets/divelistview.h +++ b/desktop-widgets/divelistview.h @@ -66,6 +66,7 @@ slots: private: void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags) override; void mouseReleaseEvent(QMouseEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; void selectAll() override; void selectionChangeDone(); DiveTripModelBase::Layout currentLayout; |