mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 03:27:40 +01:00
Delete on playlist selects next item
This commit is contained in:
parent
4ab13c03de
commit
27315ac631
1
TODO
1
TODO
@ -7,7 +7,6 @@
|
||||
- Global shortcut keys
|
||||
- Make QSortFilterProxyModel on the library obey hasChildren()
|
||||
- Database versioning
|
||||
- Delete on playlist focuses next item
|
||||
- Enter on playlist plays
|
||||
- Clicking play plays selected item
|
||||
- More actions in playlist context menu
|
||||
|
@ -298,8 +298,13 @@ bool CompareSelectionRanges(const QItemSelectionRange& a, const QItemSelectionRa
|
||||
}
|
||||
|
||||
void PlaylistView::keyPressEvent(QKeyEvent* event) {
|
||||
if (model() && (event->matches(QKeySequence::Delete) ||
|
||||
event->key() == Qt::Key_Backspace)) {
|
||||
if (!model()) {
|
||||
QTreeView::keyPressEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->matches(QKeySequence::Delete) ||
|
||||
event->key() == Qt::Key_Backspace) {
|
||||
QItemSelection selection(selectionModel()->selection());
|
||||
|
||||
// Sort the selection so we remove the items at the *bottom* first, ensuring
|
||||
@ -310,6 +315,19 @@ void PlaylistView::keyPressEvent(QKeyEvent* event) {
|
||||
model()->removeRows(range.top(), range.height(), range.parent());
|
||||
}
|
||||
|
||||
// Select the new current item
|
||||
if (currentIndex().isValid())
|
||||
selectionModel()->select(
|
||||
QItemSelection(currentIndex().sibling(currentIndex().row(), 0),
|
||||
currentIndex().sibling(currentIndex().row(), model()->columnCount()-1)),
|
||||
QItemSelectionModel::Select);
|
||||
|
||||
event->accept();
|
||||
} else if (event->key() == Qt::Key_Enter ||
|
||||
event->key() == Qt::Key_Return ||
|
||||
event->key() == Qt::Key_Space) {
|
||||
if (currentIndex().isValid())
|
||||
emit PlayPauseItem(currentIndex());
|
||||
event->accept();
|
||||
} else {
|
||||
QTreeView::keyPressEvent(event);
|
||||
|
@ -55,6 +55,9 @@ class PlaylistView : public QTreeView {
|
||||
void StartRadioLoading();
|
||||
void StopRadioLoading();
|
||||
|
||||
signals:
|
||||
void PlayPauseItem(const QModelIndex& index);
|
||||
|
||||
protected:
|
||||
void hideEvent(QHideEvent* event);
|
||||
void showEvent(QShowEvent* event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user