From 53d519247798bed1c0cc5f1cb83cafda335257fb Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 5 Feb 2022 15:56:01 +0100 Subject: [PATCH] Allow deleting CUE songs --- src/collection/collectionview.cpp | 15 +++++++++++---- src/core/mainwindow.cpp | 4 +++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/collection/collectionview.cpp b/src/collection/collectionview.cpp index 79bb2b67b..e56d5d55c 100644 --- a/src/collection/collectionview.cpp +++ b/src/collection/collectionview.cpp @@ -425,7 +425,7 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) { #endif #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - action_delete_files_->setVisible(regular_elements == regular_editable && delete_files_); + action_delete_files_->setVisible(delete_files_); #else action_delete_files_->setVisible(false); #endif @@ -440,7 +440,7 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) { #endif #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - action_delete_files_->setEnabled(regular_elements == regular_editable && delete_files_); + action_delete_files_->setEnabled(delete_files_); #else action_delete_files_->setEnabled(false); #endif @@ -671,10 +671,17 @@ void CollectionView::Delete() { if (!delete_files_) return; SongList selected_songs = GetSelectedSongs(); + + SongList songs; QStringList files; + songs.reserve(selected_songs.count()); files.reserve(selected_songs.count()); for (const Song &song : selected_songs) { - files << song.url().toString(); + QString filename = song.url().toLocalFile(); + if (!files.contains(filename)) { + songs << song; + files << filename; + } } if (DeleteConfirmationDialog::warning(files) != QDialogButtonBox::Yes) return; @@ -683,7 +690,7 @@ void CollectionView::Delete() { DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, true); QObject::connect(delete_files, &DeleteFiles::Finished, this, &CollectionView::DeleteFilesFinished); - delete_files->Start(selected_songs); + delete_files->Start(songs); } diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 327475f27..280b02f62 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -3135,8 +3135,10 @@ void MainWindow::PlaylistDelete() { QModelIndex source_idx = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_idx); PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_idx.row()); if (!item || !item->Metadata().url().isLocalFile()) continue; + QString filename = item->Metadata().url().toLocalFile(); + if (files.contains(filename)) continue; selected_songs << item->Metadata(); - files << item->Metadata().url().toLocalFile(); + files << filename; if (item == app_->player()->GetCurrentItem()) is_current_item = true; } if (selected_songs.isEmpty()) return;