diff options
author | Arno <arno@disconnect.de> | 2017-02-25 06:46:51 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2017-02-25 06:46:51 +0100 |
commit | 25bcad4c8496431f1a5556803eaccea9dddc31e1 (patch) | |
tree | 62b220ecf3b7773f171fc78279f8e53e0ab40cf4 /playerwidget.cpp | |
parent | 0e883223783a0e3ee5bc83f4ffeb4acc0beed1aa (diff) | |
download | BeetPlayer-25bcad4c8496431f1a5556803eaccea9dddc31e1.tar.gz BeetPlayer-25bcad4c8496431f1a5556803eaccea9dddc31e1.tar.bz2 BeetPlayer-25bcad4c8496431f1a5556803eaccea9dddc31e1.zip |
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.
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r-- | playerwidget.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
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; |