diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 557805699..dc5e401ee 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -2026,7 +2026,7 @@ void MainWindow::ShowInCollection() { } void MainWindow::PlaylistRemoveCurrent() { - ui_->playlist->view()->RemoveSelected(false); + ui_->playlist->view()->RemoveSelected(); } void MainWindow::PlaylistClearCurrent() { diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index adce8d72e..7edbfd409 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -930,7 +930,8 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, int pos, bool play_n // Too big to keep in the undo stack. Also clear the stack because it might have been invalidated. InsertItemsWithoutUndo(items, pos, enqueue, enqueue_next); undo_stack_->clear(); - } else { + } + else { undo_stack_->push(new PlaylistUndoCommands::InsertItems(this, items, pos, enqueue, enqueue_next)); } @@ -1384,6 +1385,8 @@ void Playlist::RemoveItemsWithoutUndo(const QList &indicesIn) { bool Playlist::removeRows(int row, int count, const QModelIndex &parent) { + Q_UNUSED(parent); + if (row < 0 || row >= items_.size() || row + count > items_.size()) { return false; } @@ -1393,9 +1396,6 @@ bool Playlist::removeRows(int row, int count, const QModelIndex &parent) { RemoveItemsWithoutUndo(row, count); undo_stack_->clear(); } - else if (parent == QModelIndex()) { - RemoveItemsWithoutUndo(row, count); - } else { undo_stack_->push(new PlaylistUndoCommands::RemoveItems(this, row, count)); } diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 918c4dd55..487e5ab59 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -543,12 +543,12 @@ void PlaylistView::keyPressEvent(QKeyEvent *event) { QTreeView::keyPressEvent(event); } else if (event == QKeySequence::Delete) { - RemoveSelected(false); + RemoveSelected(); event->accept(); #ifdef Q_OS_MACOS } else if (event->key() == Qt::Key_Backspace) { - RemoveSelected(false); + RemoveSelected(); event->accept(); #endif } @@ -586,7 +586,7 @@ void PlaylistView::contextMenuEvent(QContextMenuEvent *e) { e->accept(); } -void PlaylistView::RemoveSelected(bool deleting_from_disk) { +void PlaylistView::RemoveSelected() { int rows_removed = 0; QItemSelection selection(selectionModel()->selection()); @@ -603,13 +603,7 @@ void PlaylistView::RemoveSelected(bool deleting_from_disk) { for (const QItemSelectionRange &range : selection) { if (range.top() < last_row) rows_removed += range.height(); - - if (!deleting_from_disk) { - model()->removeRows(range.top(), range.height(), range.topLeft()); - } - else { - model()->removeRows(range.top(), range.height(), QModelIndex()); - } + model()->removeRows(range.top(), range.height(), range.parent()); } int new_row = last_row - rows_removed; diff --git a/src/playlist/playlistview.h b/src/playlist/playlistview.h index dda95a431..03b89e2ae 100644 --- a/src/playlist/playlistview.h +++ b/src/playlist/playlistview.h @@ -101,7 +101,7 @@ class PlaylistView : public QTreeView { void SetApplication(Application *app); void SetItemDelegates(CollectionBackend *backend); void SetPlaylist(Playlist *playlist); - void RemoveSelected(bool deleting_from_disk); + void RemoveSelected(); void SetReadOnlySettings(bool read_only) { read_only_settings_ = read_only; }