summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2019-09-08 23:00:04 +0200
committerArno <arno@disconnect.de>2019-09-08 23:00:04 +0200
commit6f59de4d3e4103f98f49eff5c6dd35ba1c1594a0 (patch)
treeeaf566331edf2b26570967181e61ab243f20b46d
parent8e6dcd6db53eacdb4426f7a21dbdc211fe6b05f2 (diff)
downloadBeetPlayer-6f59de4d3e4103f98f49eff5c6dd35ba1c1594a0.tar.gz
BeetPlayer-6f59de4d3e4103f98f49eff5c6dd35ba1c1594a0.tar.bz2
BeetPlayer-6f59de4d3e4103f98f49eff5c6dd35ba1c1594a0.zip
Fix the date display (again)
Hopefully this time for good. Don't duplicate albums when they have multiple artists. Grab the one with the most instead and be good.
-rw-r--r--collectiondatesview.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/collectiondatesview.cpp b/collectiondatesview.cpp
index 6dad995..f0991cb 100644
--- a/collectiondatesview.cpp
+++ b/collectiondatesview.cpp
@@ -23,7 +23,7 @@ void CollectionDatesView::populate(){
QSqlQuery songQ(db);
songQ.prepare("SELECT sipos, ttitle, tfullpath, igenres_id, artists.tartists_name, albums.talbum_name, ilength FROM songs, artists, albums WHERE albums.ialbums_id = :id AND songs.iartists_id = artists.iartists_id and songs.ialbums_id = albums.ialbums_id ORDER BY sipos");
QSqlQuery artistQ(db);
- artistQ.prepare("SELECT DISTINCT(tartists_name) FROM artists, songs WHERE songs.ialbums_id = :aid AND songs.iartists_id = artists.iartists_id LIMIT 1");
+ artistQ.prepare("SELECT DISTINCT(tartists_name), COUNT(tartists_name) FROM artists, songs WHERE songs.ialbums_id = :aid AND songs.iartists_id = artists.iartists_id GROUP BY tartists_name");
QHash<int, QStandardItem*> years;
QHash<QString, QStandardItem*> yearMonths;
QSqlQuery q1("SELECT ialbums_id, talbum_name, dadded FROM albums ORDER BY dadded DESC", db);
@@ -53,11 +53,16 @@ void CollectionDatesView::populate(){
}
QStandardItem *albumItem = new QStandardItem;
QString artist;
+ int artistCount = 0;
artistQ.bindValue(":aid", q1.value(0));
artistQ.exec();
while(artistQ.next()){
- artist = artistQ.value(0).toString();
+ if(artistQ.value(1).toInt() > artistCount){
+ artistCount = artistQ.value(1).toInt();
+ artist = artistQ.value(0).toString();
+ }
}
+
QString albumText = QString("%1 - %2").arg(artist).arg(q1.value(1).toString());
albumItem->setText(albumText);
albumItem->setIcon(albumIcon);