Allow deleting CUE songs
This commit is contained in:
@@ -425,7 +425,7 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
#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
|
#else
|
||||||
action_delete_files_->setVisible(false);
|
action_delete_files_->setVisible(false);
|
||||||
#endif
|
#endif
|
||||||
@@ -440,7 +440,7 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
#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
|
#else
|
||||||
action_delete_files_->setEnabled(false);
|
action_delete_files_->setEnabled(false);
|
||||||
#endif
|
#endif
|
||||||
@@ -671,10 +671,17 @@ void CollectionView::Delete() {
|
|||||||
if (!delete_files_) return;
|
if (!delete_files_) return;
|
||||||
|
|
||||||
SongList selected_songs = GetSelectedSongs();
|
SongList selected_songs = GetSelectedSongs();
|
||||||
|
|
||||||
|
SongList songs;
|
||||||
QStringList files;
|
QStringList files;
|
||||||
|
songs.reserve(selected_songs.count());
|
||||||
files.reserve(selected_songs.count());
|
files.reserve(selected_songs.count());
|
||||||
for (const Song &song : selected_songs) {
|
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;
|
if (DeleteConfirmationDialog::warning(files) != QDialogButtonBox::Yes) return;
|
||||||
|
|
||||||
@@ -683,7 +690,7 @@ void CollectionView::Delete() {
|
|||||||
|
|
||||||
DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, true);
|
DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, true);
|
||||||
QObject::connect(delete_files, &DeleteFiles::Finished, this, &CollectionView::DeleteFilesFinished);
|
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);
|
QModelIndex source_idx = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_idx);
|
||||||
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_idx.row());
|
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_idx.row());
|
||||||
if (!item || !item->Metadata().url().isLocalFile()) continue;
|
if (!item || !item->Metadata().url().isLocalFile()) continue;
|
||||||
|
QString filename = item->Metadata().url().toLocalFile();
|
||||||
|
if (files.contains(filename)) continue;
|
||||||
selected_songs << item->Metadata();
|
selected_songs << item->Metadata();
|
||||||
files << item->Metadata().url().toLocalFile();
|
files << filename;
|
||||||
if (item == app_->player()->GetCurrentItem()) is_current_item = true;
|
if (item == app_->player()->GetCurrentItem()) is_current_item = true;
|
||||||
}
|
}
|
||||||
if (selected_songs.isEmpty()) return;
|
if (selected_songs.isEmpty()) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user