Playlist: Remove veto listeners

We have never used this, it's basically dead code.
This commit is contained in:
Jonas Kvinge
2024-02-28 23:00:24 +01:00
parent a6ea4dd0d7
commit b365131363
2 changed files with 0 additions and 72 deletions

View File

@@ -1026,44 +1026,6 @@ void Playlist::InsertItems(const PlaylistItemPtrList &itemsIn, const int pos, co
PlaylistItemPtrList items = itemsIn;
// Exercise vetoes
SongList songs;
songs.reserve(items.count());
for (PlaylistItemPtr item : items) { // clazy:exclude=range-loop-reference
songs << item->Metadata();
}
const qint64 song_count = songs.length();
QSet<Song> vetoed;
for (SongInsertVetoListener *listener : veto_listeners_) {
for (const Song &song : listener->AboutToInsertSongs(GetAllSongs(), songs)) {
// Avoid veto-ing a song multiple times
vetoed.insert(song);
}
if (vetoed.count() == song_count) {
// All songs were vetoed and there's nothing more to do (there's no need for an undo step)
return;
}
}
if (!vetoed.isEmpty()) {
QMutableListIterator<PlaylistItemPtr> it(items);
while (it.hasNext()) {
PlaylistItemPtr item = it.next();
const Song &current = item->Metadata();
if (vetoed.contains(current)) {
vetoed.remove(current);
it.remove();
}
}
// Check for empty items once again after veto
if (items.isEmpty()) {
return;
}
}
const int start = pos == -1 ? static_cast<int>(items_.count()) : pos;
if (items.count() > kUndoItemLimit) {
@@ -1905,20 +1867,6 @@ void Playlist::ReloadItemsBlocking(const QList<int> &rows) {
}
void Playlist::AddSongInsertVetoListener(SongInsertVetoListener *listener) {
veto_listeners_.append(listener);
QObject::connect(listener, &SongInsertVetoListener::destroyed, this, &Playlist::SongInsertVetoListenerDestroyed);
}
void Playlist::RemoveSongInsertVetoListener(SongInsertVetoListener *listener) {
QObject::disconnect(listener, &SongInsertVetoListener::destroyed, this, &Playlist::SongInsertVetoListenerDestroyed);
veto_listeners_.removeAll(listener);
}
void Playlist::SongInsertVetoListenerDestroyed() {
veto_listeners_.removeAll(qobject_cast<SongInsertVetoListener*>(sender()));
}
void Playlist::Shuffle() {
PlaylistItemPtrList new_items(items_);