mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-02-06 20:33:30 +01:00
Playlist: Remove veto listeners
We have never used this, it's basically dead code.
This commit is contained in:
parent
a6ea4dd0d7
commit
b365131363
@ -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 ¤t = 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_);
|
||||
|
@ -74,18 +74,6 @@ using ColumnAlignmentMap = QMap<int, Qt::Alignment>;
|
||||
Q_DECLARE_METATYPE(Qt::Alignment)
|
||||
Q_DECLARE_METATYPE(ColumnAlignmentMap)
|
||||
|
||||
// Objects that may prevent a song being added to the playlist.
|
||||
// When there is something about to be inserted into it,
|
||||
// Playlist notifies all of its listeners about the fact and every one of them picks 'invalid' songs.
|
||||
class SongInsertVetoListener : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Listener returns a list of 'invalid' songs.
|
||||
// 'old_songs' are songs that are currently in the playlist and 'new_songs' are the songs about to be added if nobody exercises a veto.
|
||||
virtual SongList AboutToInsertSongs(const SongList &old_songs, const SongList &new_songs) = 0;
|
||||
};
|
||||
|
||||
class Playlist : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
|
||||
@ -258,11 +246,6 @@ class Playlist : public QAbstractListModel {
|
||||
void ReloadItemsBlocking(const QList<int> &rows);
|
||||
void InformOfCurrentSongChange(const AutoScroll autoscroll, const bool minor);
|
||||
|
||||
// Registers an object which will get notifications when new songs are about to be inserted into this playlist.
|
||||
void AddSongInsertVetoListener(SongInsertVetoListener *listener);
|
||||
// Unregisters a SongInsertVetoListener object.
|
||||
void RemoveSongInsertVetoListener(SongInsertVetoListener *listener);
|
||||
|
||||
// Just emits the dataChanged() signal so the mood column is repainted.
|
||||
#ifdef HAVE_MOODBAR
|
||||
void MoodbarUpdated(const QModelIndex &idx);
|
||||
@ -376,7 +359,6 @@ class Playlist : public QAbstractListModel {
|
||||
void SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &idx, const Song &old_metadata);
|
||||
void ItemReloadComplete(const QPersistentModelIndex &idx, const Song &old_metadata, const bool metadata_edit);
|
||||
void ItemsLoaded();
|
||||
void SongInsertVetoListenerDestroyed();
|
||||
void ScheduleSave();
|
||||
void Save();
|
||||
|
||||
@ -420,8 +402,6 @@ class Playlist : public QAbstractListModel {
|
||||
|
||||
ColumnAlignmentMap column_alignments_;
|
||||
|
||||
QList<SongInsertVetoListener*> veto_listeners_;
|
||||
|
||||
QString special_type_;
|
||||
|
||||
// Cancel async restore if songs are already replaced
|
||||
|
Loading…
x
Reference in New Issue
Block a user