Select the current item if the selection is empty when using Tab to move from
the playlist filter to the playlist view. Fixes #4116
This commit is contained in:
parent
827ed9425c
commit
d3749eace9
@ -1254,3 +1254,24 @@ void PlaylistView::FadePreviousBackgroundImage(qreal value) {
|
|||||||
void PlaylistView::PlayerStopped() {
|
void PlaylistView::PlayerStopped() {
|
||||||
CurrentSongChanged(Song(), QString(), QImage());
|
CurrentSongChanged(Song(), QString(), QImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlaylistView::focusInEvent(QFocusEvent* event) {
|
||||||
|
QTreeView::focusInEvent(event);
|
||||||
|
|
||||||
|
if (event->reason() == Qt::TabFocusReason ||
|
||||||
|
event->reason() == Qt::BacktabFocusReason) {
|
||||||
|
// If there's a current item but no selection it probably means the list was
|
||||||
|
// filtered, and the selected item does not match the filter. If there's
|
||||||
|
// only 1 item in the view it is now impossible to select that item without
|
||||||
|
// using the mouse.
|
||||||
|
const QModelIndex& current = selectionModel()->currentIndex();
|
||||||
|
if (current.isValid() &&
|
||||||
|
selectionModel()->selectedIndexes().isEmpty()) {
|
||||||
|
QItemSelection new_selection(
|
||||||
|
current.sibling(current.row(), 0),
|
||||||
|
current.sibling(current.row(),
|
||||||
|
current.model()->columnCount(current.parent()) - 1));
|
||||||
|
selectionModel()->select(new_selection, QItemSelectionModel::Select);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -134,6 +134,7 @@ class PlaylistView : public QTreeView {
|
|||||||
void dropEvent(QDropEvent *event);
|
void dropEvent(QDropEvent *event);
|
||||||
void resizeEvent(QResizeEvent* event);
|
void resizeEvent(QResizeEvent* event);
|
||||||
bool eventFilter(QObject* object, QEvent* event);
|
bool eventFilter(QObject* object, QEvent* event);
|
||||||
|
void focusInEvent(QFocusEvent* event);
|
||||||
|
|
||||||
// QAbstractScrollArea
|
// QAbstractScrollArea
|
||||||
void scrollContentsBy(int dx, int dy);
|
void scrollContentsBy(int dx, int dy);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user