Don't treat songs with different album as duplicates

This commit is contained in:
Jonas Kvinge 2019-08-21 20:46:08 +02:00
parent 882f80de1e
commit f81ecffda6
2 changed files with 8 additions and 2 deletions

View File

@ -1372,12 +1372,14 @@ uint qHash(const Song &song) {
}
bool Song::IsSimilar(const Song &other) const {
return title().compare(other.title(), Qt::CaseInsensitive) == 0 && artist().compare(other.artist(), Qt::CaseInsensitive) == 0;
return title().compare(other.title(), Qt::CaseInsensitive) == 0 &&
artist().compare(other.artist(), Qt::CaseInsensitive) == 0 &&
album().compare(other.album(), Qt::CaseInsensitive) == 0;
}
uint HashSimilar(const Song &song) {
// Should compare the same fields as function IsSimilar
return qHash(song.title().toLower()) ^ qHash(song.artist().toLower());
return qHash(song.title().toLower()) ^ qHash(song.artist().toLower()) ^ qHash(song.album().toLower());
}
bool Song::IsOnSameAlbum(const Song &other) const {

View File

@ -1860,6 +1860,8 @@ void Playlist::RemoveDeletedSongs() {
}
namespace {
struct SongSimilarHash {
long operator() (const Song &song) const {
return HashSimilar(song);
@ -1872,6 +1874,8 @@ struct SongSimilarEqual {
}
};
} // namespace
void Playlist::RemoveDuplicateSongs() {
QList<int> rows_to_remove;