From 25bcad4c8496431f1a5556803eaccea9dddc31e1 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 25 Feb 2017 06:46:51 +0100 Subject: Fix Indexer Well, as it turns out, an artist is not married to an album, but to a song, and so is the genre. Adjust the database layout, indexer and view accordingly. --- playerwidget.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'playerwidget.cpp') diff --git a/playerwidget.cpp b/playerwidget.cpp index b238f62..36910cc 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -129,9 +129,9 @@ void PlayerWidget::populateByArtist(){ QSqlQuery artistsQ(db); artistsQ.prepare("SELECT iartists_id, tartists_name FROM artists ORDER BY tartists_name ASC"); QSqlQuery albumQ(db); - albumQ.prepare("SELECT ialbums_id, talbum_name, siyear FROM albums WHERE iartists_id = :aid ORDER BY talbum_name ASC"); + albumQ.prepare("SELECT DISTINCT(songs.ialbums_id), talbum_name, siyear FROM songs, albums WHERE songs.iartists_id = :artistid AND songs.ialbums_id = albums.ialbums_id"); QSqlQuery songQ(db); - songQ.prepare("SELECT sipos, ttitle, tfullpath FROM songs WHERE ialbums_id = :alid ORDER BY sipos ASC"); + songQ.prepare("SELECT sipos, ttitle, tfullpath FROM songs WHERE ialbums_id = :alid AND iartists_id = :arid ORDER BY sipos ASC"); //reset view+model mView->setSortingEnabled(false); @@ -148,7 +148,7 @@ void PlayerWidget::populateByArtist(){ curArtist->setData(Artist, TypeRole); curArtist->setData(artistsQ.value(0).toInt(), IdRole); root->appendRow(curArtist); - albumQ.bindValue(":aid", artistsQ.value(0)); + albumQ.bindValue(":artistid", artistsQ.value(0)); albumQ.exec(); while(albumQ.next()){ QStandardItem *curAlbum = new QStandardItem; @@ -158,6 +158,7 @@ void PlayerWidget::populateByArtist(){ curAlbum->setData(albumQ.value(0), IdRole); curArtist->appendRow(curAlbum); songQ.bindValue(":alid", albumQ.value(0)); + songQ.bindValue(":arid", artistsQ.value(0)); songQ.exec(); while(songQ.next()){ QStandardItem *curSong = new QStandardItem; -- cgit v1.2.3-70-g09d2