Allow deleting CUE songs
This commit is contained in:
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user