Skip to content

Commit

Permalink
sidebar: Left key jumps to parent and activates it
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Aug 21, 2021
1 parent aed4dff commit 7f82634
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/widget/wlibrarysidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ void WLibrarySidebar::keyPressEvent(QKeyEvent* event) {
// // encoder click via "GoToItem"
// qDebug() << "GoToItem";
// TODO(xxx) decide what todo here instead of in librarycontrol
} else if (event->key() == Qt::Key_Left) {
QTreeView::keyPressEvent(event);
// If this is a child item jump to its parent and activate it
auto selModel = selectionModel();
QModelIndexList selectedRows = selModel->selectedRows();
if (selectedRows.size() > 0) {
QModelIndex parentIndex = selectedRows.at(0).parent();
if (parentIndex.isValid()) {
selectIndex(parentIndex);
emit pressed(parentIndex);
}
return;
}
}

// Fall through to default handler.
Expand Down

0 comments on commit 7f82634

Please sign in to comment.