Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracks table: fix initial track selection with BackTab #11130

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/widget/wlibrarytableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,17 @@ void WLibraryTableView::focusInEvent(QFocusEvent* event) {
// Select the first row if no row is focused
selectRow(0);
DEBUG_ASSERT(currentIndex().row() == 0);
} else {
// Select the row of the currently focused index.
// For some reason selectRow(currentIndex().row()) would not
// select for the first Qt::BacktabFocusReason in a session
// even though currentIndex() is valid.
selectionModel()->select(currentIndex(),
QItemSelectionModel::Select | QItemSelectionModel::Rows);
// Unfortunately, even though we now have a valid currentIndex(),
// that would still not be selected by now if we're here because of
// the first Qt::BacktabFocusReason to tracks in this session. (Qt 5.12.8)
// So let's use the currentIndex below.
}
// Select the row of the currently focused index.
// For some reason selectRow(currentIndex().row()) would not
// select for the first Qt::BacktabFocusReason in a session
// even though currentIndex() is valid.
selectionModel()->select(currentIndex(),
QItemSelectionModel::Select | QItemSelectionModel::Rows);
}
DEBUG_ASSERT(currentIndex().isValid());
DEBUG_ASSERT(selectionModel()->isSelected(currentIndex()));
Expand Down