mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-10 17:13:39 +01:00
lyrics: Use lambda for UltimateLyricsProvider requests
Remove map of requests to ids and pass info directly to reply handler.
This commit is contained in:
parent
40575e854e
commit
02a1fc9a07
@ -55,18 +55,11 @@ void UltimateLyricsProvider::FetchInfo(int id, const Song& metadata) {
|
||||
metadata_ = metadata;
|
||||
redirect_count_ = 0;
|
||||
QNetworkReply* reply = network_->get(QNetworkRequest(url));
|
||||
requests_[reply] = id;
|
||||
connect(reply, SIGNAL(finished()), SLOT(LyricsFetched()));
|
||||
connect(reply, &QNetworkReply::finished,
|
||||
[=] { this->RequestFinished(reply, id); });
|
||||
}
|
||||
|
||||
void UltimateLyricsProvider::LyricsFetched() {
|
||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
|
||||
if (!reply) {
|
||||
url_hop_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int id = requests_.take(reply);
|
||||
void UltimateLyricsProvider::RequestFinished(QNetworkReply* reply, int id) {
|
||||
reply->deleteLater();
|
||||
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
@ -94,8 +87,8 @@ void UltimateLyricsProvider::LyricsFetched() {
|
||||
|
||||
redirect_count_++;
|
||||
QNetworkReply* reply = network_->get(QNetworkRequest(target));
|
||||
requests_[reply] = id;
|
||||
connect(reply, SIGNAL(finished()), SLOT(LyricsFetched()));
|
||||
connect(reply, &QNetworkReply::finished,
|
||||
[=] { this->RequestFinished(reply, id); });
|
||||
return;
|
||||
}
|
||||
|
||||
@ -129,8 +122,8 @@ void UltimateLyricsProvider::LyricsFetched() {
|
||||
QUrl url(content);
|
||||
qLog(Debug) << "Next url hop: " << url;
|
||||
QNetworkReply* reply = network_->get(QNetworkRequest(url));
|
||||
requests_[reply] = id;
|
||||
connect(reply, SIGNAL(finished()), SLOT(LyricsFetched()));
|
||||
connect(reply, &QNetworkReply::finished,
|
||||
[=] { this->RequestFinished(reply, id); });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ class UltimateLyricsProvider : public SongInfoProvider {
|
||||
void FetchInfo(int id, const Song& metadata);
|
||||
|
||||
private slots:
|
||||
void LyricsFetched();
|
||||
void RequestFinished(QNetworkReply* reply, int id);
|
||||
|
||||
private:
|
||||
bool ApplyExtractRule(const Rule& rule, QString* content) const;
|
||||
@ -86,7 +86,6 @@ class UltimateLyricsProvider : public SongInfoProvider {
|
||||
|
||||
private:
|
||||
NetworkAccessManager* network_;
|
||||
QMap<QNetworkReply*, int> requests_;
|
||||
|
||||
QString name_;
|
||||
QString title_;
|
||||
|
Loading…
Reference in New Issue
Block a user