Distinguish albums with same name with album_id

This commit is contained in:
Jonas Kvinge 2019-05-30 18:05:07 +02:00
parent 111712fd6d
commit 2b7d48ce77
1 changed files with 11 additions and 3 deletions

View File

@ -670,7 +670,8 @@ QVariant CollectionModel::data(const CollectionItem *item, int role) const {
} }
} }
return true; return true;
} else { }
else {
return false; return false;
} }
} }
@ -840,7 +841,7 @@ void CollectionModel::InitQuery(GroupBy type, CollectionQuery *q) {
q->SetColumnSpec("DISTINCT artist"); q->SetColumnSpec("DISTINCT artist");
break; break;
case GroupBy_Album: case GroupBy_Album:
q->SetColumnSpec("DISTINCT album"); q->SetColumnSpec("DISTINCT album, album_id");
break; break;
case GroupBy_Composer: case GroupBy_Composer:
q->SetColumnSpec("DISTINCT composer"); q->SetColumnSpec("DISTINCT composer");
@ -916,6 +917,7 @@ void CollectionModel::FilterQuery(GroupBy type, CollectionItem *item, Collection
break; break;
case GroupBy_Album: case GroupBy_Album:
q->AddWhere("album", item->key); q->AddWhere("album", item->key);
q->AddWhere("album_id", item->metadata.album_id());
break; break;
case GroupBy_YearAlbum: case GroupBy_YearAlbum:
q->AddWhere("year", item->metadata.year()); q->AddWhere("year", item->metadata.year());
@ -996,7 +998,6 @@ CollectionItem *CollectionModel::ItemFromQuery(GroupBy type, bool signal, bool c
switch (type) { switch (type) {
case GroupBy_AlbumArtist: case GroupBy_AlbumArtist:
case GroupBy_Artist: case GroupBy_Artist:
case GroupBy_Album:
case GroupBy_Composer: case GroupBy_Composer:
case GroupBy_Performer: case GroupBy_Performer:
case GroupBy_Grouping: case GroupBy_Grouping:
@ -1006,6 +1007,13 @@ CollectionItem *CollectionModel::ItemFromQuery(GroupBy type, bool signal, bool c
item->sort_text = SortTextForArtist(item->key); item->sort_text = SortTextForArtist(item->key);
break; 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:{ case GroupBy_OriginalYear:{
int year = qMax(0, row.value(0).toInt()); int year = qMax(0, row.value(0).toInt());
item->key = QString::number(year); item->key = QString::number(year);