Skip to content

Commit

Permalink
sidebar: also process PageUp/Down, Home & End events
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Aug 29, 2021
1 parent 0b72fc6 commit 7a6be47
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/widget/wlibrarysidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,18 @@ void WLibrarySidebar::keyPressEvent(QKeyEvent* event) {
if (event->key() == Qt::Key_Return) {
toggleSelectedItem();
return;
} else if (event->key() == Qt::Key_Down || event->key() == Qt::Key_Up) {
} else if (event->key() == Qt::Key_Down ||
event->key() == Qt::Key_Up ||
event->key() == Qt::Key_PageDown ||
event->key() == Qt::Key_PageUp ||
event->key() == Qt::Key_End ||
event->key() == Qt::Key_Home) {
// Let the tree view move up and down for us.
QTreeView::keyPressEvent(event);

// But force the index to be activated/clicked after the selection
// changes. (Saves you from having to push "enter" after changing the
// selection.)
QModelIndexList selectedIndices = this->selectionModel()->selectedRows();

QModelIndexList selectedIndices = selectionModel()->selectedRows();
//Note: have to get the selected indices _after_ QTreeView::keyPressEvent()
if (selectedIndices.size() > 0) {
QModelIndex index = selectedIndices.at(0);
Expand Down

0 comments on commit 7a6be47

Please sign in to comment.