From bf229f2a7b20bbb1248f14b07bf2384e753381d4 Mon Sep 17 00:00:00 2001 From: Arno Date: Fri, 1 Dec 2017 04:53:20 +0100 Subject: Improve Musicbrainz search If we already have the album, use the release year from the database and indicate presence by different bullets in the list. --- playerwidget.cpp | 26 ++++++++++++++++++++++---- webdownloader.h | 2 -- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/playerwidget.cpp b/playerwidget.cpp index 0fb97ed..4464479 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -1472,9 +1472,18 @@ void PlayerWidget::searchMusicbrainzLeft(){ mWebDownloader->fetchData(artist, album); } - void PlayerWidget::webDlDone(){ QString aId = mWebDownloader->artistId(); + QString artist = mWebDownloader->artist(); + QHash dbAlbums; + QSqlDatabase db = QSqlDatabase::database("beetplayerdb"); + QSqlQuery aQ(db); + aQ.prepare("SELECT DISTINCT(albums.talbum_name), siyear FROM artists, albums, songs WHERE artists.tartists_name = :aname AND artists.iartists_id = songs.iartists_id AND songs.ialbums_id = albums.ialbums_id"); + aQ.bindValue(":aname", artist); + aQ.exec(); + while(aQ.next()){ + dbAlbums.insert(aQ.value(0).toString(), aQ.value(1).toString()); + } QString text; if(!aId.isEmpty()){ text.append(QString(tr("Musicbrainz:"))); @@ -1487,18 +1496,27 @@ void PlayerWidget::webDlDone(){ std::sort(other.begin(), other.end(), [](auto a, auto b){ return a.at(2).toInt() < b.at(2).toInt(); }); - text.append(QString(tr("All Albums (%1):"); + text.append(""); }else{ text.append(QString(tr("Musicbrainz: No match!
"))); const QMap alt = mWebDownloader->alternateArtists(); diff --git a/webdownloader.h b/webdownloader.h index 353bd5a..9bbc1c9 100644 --- a/webdownloader.h +++ b/webdownloader.h @@ -34,6 +34,4 @@ class WebDownloader : public QObject { QMap mAlternateArtists; }; - - #endif // WEBDOWNLOADER_H -- cgit v1.2.3-70-g09d2