Don't record an undo step when all the songs inserted into the playlist were vetoed. Thanks schizosfera.
This commit is contained in:
parent
36ffec7778
commit
c8305c0eee
|
@ -1255,6 +1255,11 @@ bool Song::operator==(const Song& other) const {
|
|||
beginning_nanosec() == other.beginning_nanosec();
|
||||
}
|
||||
|
||||
uint qHash(const Song& song) {
|
||||
// Should compare the same fields as operator==
|
||||
return qHash(song.url().toString()) ^ qHash(song.beginning_nanosec());
|
||||
}
|
||||
|
||||
QImage Song::LoadEmbeddedArt(const QString& filename) {
|
||||
QImage ret;
|
||||
if (filename.isEmpty())
|
||||
|
|
|
@ -385,4 +385,6 @@ Q_DECLARE_METATYPE(Song);
|
|||
typedef QList<Song> SongList;
|
||||
Q_DECLARE_METATYPE(QList<Song>);
|
||||
|
||||
uint qHash(const Song& song);
|
||||
|
||||
#endif // SONG_H
|
||||
|
|
|
@ -833,10 +833,16 @@ void Playlist::InsertItems(const PlaylistItemList& itemsIn, int pos, bool play_n
|
|||
songs << item->Metadata();
|
||||
}
|
||||
|
||||
QList<Song> vetoed;
|
||||
const int song_count = songs.length();
|
||||
QSet<Song> vetoed;
|
||||
foreach(SongInsertVetoListener* listener, veto_listeners_) {
|
||||
foreach(const Song& song, listener->AboutToInsertSongs(GetAllSongs(), songs)) {
|
||||
vetoed.append(song);
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -847,7 +853,7 @@ void Playlist::InsertItems(const PlaylistItemList& itemsIn, int pos, bool play_n
|
|||
const Song& current = item->Metadata();
|
||||
|
||||
if(vetoed.contains(current)) {
|
||||
vetoed.removeOne(current);
|
||||
vetoed.remove(current);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue