From 2b7d48ce77ce511db6064dfde1a4147762145ab5 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Thu, 30 May 2019 18:05:07 +0200 Subject: [PATCH] Distinguish albums with same name with album_id --- src/collection/collectionmodel.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/collection/collectionmodel.cpp b/src/collection/collectionmodel.cpp index 2f4b30686..04f77c82e 100644 --- a/src/collection/collectionmodel.cpp +++ b/src/collection/collectionmodel.cpp @@ -670,7 +670,8 @@ QVariant CollectionModel::data(const CollectionItem *item, int role) const { } } return true; - } else { + } + else { return false; } } @@ -840,7 +841,7 @@ void CollectionModel::InitQuery(GroupBy type, CollectionQuery *q) { q->SetColumnSpec("DISTINCT artist"); break; case GroupBy_Album: - q->SetColumnSpec("DISTINCT album"); + q->SetColumnSpec("DISTINCT album, album_id"); break; case GroupBy_Composer: q->SetColumnSpec("DISTINCT composer"); @@ -916,6 +917,7 @@ void CollectionModel::FilterQuery(GroupBy type, CollectionItem *item, Collection break; case GroupBy_Album: q->AddWhere("album", item->key); + q->AddWhere("album_id", item->metadata.album_id()); break; case GroupBy_YearAlbum: q->AddWhere("year", item->metadata.year()); @@ -996,7 +998,6 @@ CollectionItem *CollectionModel::ItemFromQuery(GroupBy type, bool signal, bool c switch (type) { case GroupBy_AlbumArtist: case GroupBy_Artist: - case GroupBy_Album: case GroupBy_Composer: case GroupBy_Performer: case GroupBy_Grouping: @@ -1006,6 +1007,13 @@ CollectionItem *CollectionModel::ItemFromQuery(GroupBy type, bool signal, bool c item->sort_text = SortTextForArtist(item->key); break; + case GroupBy_Album: + item->key = row.value(0).toString(); + item->display_text = TextOrUnknown(item->key); + item->sort_text = SortTextForArtist(item->key); + item->metadata.set_album_id(row.value(1).toInt()); + break; + case GroupBy_OriginalYear:{ int year = qMax(0, row.value(0).toInt()); item->key = QString::number(year);