CollectionBackend: Add delete songs by URLs function

This commit is contained in:
Jonas Kvinge
2025-03-08 21:46:27 +01:00
parent 31671af5f5
commit 5ae0320911
2 changed files with 28 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
* Strawberry Music Player * Strawberry Music Player
* This file was part of Clementine. * This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com> * Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net> * Copyright 2018-2025, Jonas Kvinge <jonas@jkvinge.net>
* *
* Strawberry is free software: you can redistribute it and/or modify * Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -853,6 +853,10 @@ void CollectionBackend::UpdateMTimesOnly(const SongList &songs) {
} }
void CollectionBackend::DeleteSongsAsync(const SongList &songs) {
QMetaObject::invokeMethod(this, "DeleteSongs", Qt::QueuedConnection, Q_ARG(SongList, songs));
}
void CollectionBackend::DeleteSongs(const SongList &songs) { void CollectionBackend::DeleteSongs(const SongList &songs) {
QMutexLocker l(db_->Mutex()); QMutexLocker l(db_->Mutex());
@@ -879,6 +883,24 @@ void CollectionBackend::DeleteSongs(const SongList &songs) {
} }
void CollectionBackend::DeleteSongsByUrlsAsync(const QList<QUrl> &urls) {
QMetaObject::invokeMethod(this, "DeleteSongsByUrl", Qt::QueuedConnection, Q_ARG(QList<QUrl>, urls));
}
void CollectionBackend::DeleteSongsByUrls(const QList<QUrl> &urls) {
SongList songs;
songs.reserve(urls.count());
for (const QUrl &url : urls) {
songs << GetSongsByUrl(url);
}
if (!songs.isEmpty()) {
DeleteSongs(songs);
}
}
void CollectionBackend::MarkSongsUnavailable(const SongList &songs, const bool unavailable) { void CollectionBackend::MarkSongsUnavailable(const SongList &songs, const bool unavailable) {
QMutexLocker l(db_->Mutex()); QMutexLocker l(db_->Mutex());

View File

@@ -2,7 +2,7 @@
* Strawberry Music Player * Strawberry Music Player
* This file was part of Clementine. * This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com> * Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net> * Copyright 2018-2025, Jonas Kvinge <jonas@jkvinge.net>
* *
* Strawberry is free software: you can redistribute it and/or modify * Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -234,6 +234,9 @@ class CollectionBackend : public CollectionBackendInterface {
void UpdateSongRatingAsync(const int id, const float rating, const bool save_tags = false); void UpdateSongRatingAsync(const int id, const float rating, const bool save_tags = false);
void UpdateSongsRatingAsync(const QList<int> &ids, const float rating, const bool save_tags = false); void UpdateSongsRatingAsync(const QList<int> &ids, const float rating, const bool save_tags = false);
void DeleteSongsAsync(const SongList &songs);
void DeleteSongsByUrlsAsync(const QList<QUrl> &url);
public Q_SLOTS: public Q_SLOTS:
void Exit(); void Exit();
void GetAllSongs(const int id); void GetAllSongs(const int id);
@@ -247,6 +250,7 @@ class CollectionBackend : public CollectionBackendInterface {
void UpdateSongsBySongID(const SongMap &new_songs); void UpdateSongsBySongID(const SongMap &new_songs);
void UpdateMTimesOnly(const SongList &songs); void UpdateMTimesOnly(const SongList &songs);
void DeleteSongs(const SongList &songs); void DeleteSongs(const SongList &songs);
void DeleteSongsByUrls(const QList<QUrl> &url);
void MarkSongsUnavailable(const SongList &songs, const bool unavailable = true); void MarkSongsUnavailable(const SongList &songs, const bool unavailable = true);
void AddOrUpdateSubdirs(const CollectionSubdirectoryList &subdirs); void AddOrUpdateSubdirs(const CollectionSubdirectoryList &subdirs);
void CompilationsNeedUpdating(); void CompilationsNeedUpdating();