Port last.fm cover provider to closures.
This commit is contained in:
parent
16fe238d98
commit
e8f4496fea
|
@ -15,13 +15,15 @@
|
||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "albumcoverfetcher.h"
|
|
||||||
#include "coverprovider.h"
|
|
||||||
#include "lastfmcoverprovider.h"
|
#include "lastfmcoverprovider.h"
|
||||||
#include "internet/lastfmcompat.h"
|
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
|
#include "albumcoverfetcher.h"
|
||||||
|
#include "coverprovider.h"
|
||||||
|
#include "core/closure.h"
|
||||||
|
#include "internet/lastfmcompat.h"
|
||||||
|
|
||||||
LastFmCoverProvider::LastFmCoverProvider(QObject* parent)
|
LastFmCoverProvider::LastFmCoverProvider(QObject* parent)
|
||||||
: CoverProvider("last.fm", parent)
|
: CoverProvider("last.fm", parent)
|
||||||
{
|
{
|
||||||
|
@ -33,18 +35,13 @@ bool LastFmCoverProvider::StartSearch(const QString& artist, const QString& albu
|
||||||
params["album"] = album + " " + artist;
|
params["album"] = album + " " + artist;
|
||||||
|
|
||||||
QNetworkReply* reply = lastfm::ws::post(params);
|
QNetworkReply* reply = lastfm::ws::post(params);
|
||||||
connect(reply, SIGNAL(finished()), SLOT(QueryFinished()));
|
NewClosure(reply, SIGNAL(finished()), this,
|
||||||
pending_queries_[reply] = id;
|
SLOT(QueryFinished(QNetworkReply*, int)), reply, id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LastFmCoverProvider::QueryFinished() {
|
void LastFmCoverProvider::QueryFinished(QNetworkReply* reply, int id) {
|
||||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
|
|
||||||
if (!reply || !pending_queries_.contains(reply))
|
|
||||||
return;
|
|
||||||
|
|
||||||
int id = pending_queries_.take(reply);
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
CoverSearchResults results;
|
CoverSearchResults results;
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
bool StartSearch(const QString& artist, const QString& album, int id);
|
bool StartSearch(const QString& artist, const QString& album, int id);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void QueryFinished();
|
void QueryFinished(QNetworkReply* reply, int id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<QNetworkReply*, int> pending_queries_;
|
QMap<QNetworkReply*, int> pending_queries_;
|
||||||
|
|
Loading…
Reference in New Issue