summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-10-02 18:47:05 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-02 11:10:28 -0700
commit06c35026d650e2d35f4007012879b37672508e32 (patch)
treeaadfc29ca73cb26fef0922b3840d17057c7e61ad /desktop-widgets/divelistview.cpp
parentd8f35711ff1f79fc8d2d39e53d6cfbb0db254ecc (diff)
downloadsubsurface-06c35026d650e2d35f4007012879b37672508e32.tar.gz
desktop: fix paging through dive list with page-up key, etc
In the dive list we have horrible code, which intercepts all events to save the selection before/after the event. This was necessary because we couldn't get Qt's selection data flow under control. This means intercepting all events that can change the selection. The page-up, page-down, home and end keys were forgotten. Add these cases. Fixes #2957. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/divelistview.cpp')
-rw-r--r--desktop-widgets/divelistview.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp
index 900114d05..390c78216 100644
--- a/desktop-widgets/divelistview.cpp
+++ b/desktop-widgets/divelistview.cpp
@@ -448,10 +448,21 @@ void DiveListView::mouseReleaseEvent(QMouseEvent *event)
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);
+ // Hook into key events that change the selection (i.e. cursor-up, cursor-down,
+ // page-up, page-down, home and end) and update selection if necessary.
+ // See comment in mouseReleaseEvent().
+ switch (event->key()) {
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ case Qt::Key_PageUp:
+ case Qt::Key_PageDown:
+ case Qt::Key_Home:
+ case Qt::Key_End:
+ break;
+ default:
+ return QTreeView::keyPressEvent(event);
+ }
+
QModelIndexList selectionBefore = selectionModel()->selectedRows();
QTreeView::keyPressEvent(event);
QModelIndexList selectionAfter = selectionModel()->selectedRows();