Fix various clazy warnings
This commit is contained in:
@@ -164,8 +164,7 @@ QJsonArray AuddLyricsProvider::ExtractResult(QNetworkReply *reply, const QString
|
||||
Error("Json reply is missing error code or message.", json_error);
|
||||
return QJsonArray();
|
||||
}
|
||||
QString error_code(json_error["error_code"].toString());
|
||||
QString error_message(json_error["error_message"].toString());
|
||||
QString error_message = json_error["error_message"].toString();
|
||||
Error(error_message);
|
||||
return QJsonArray();
|
||||
}
|
||||
@@ -177,7 +176,7 @@ QJsonArray AuddLyricsProvider::ExtractResult(QNetworkReply *reply, const QString
|
||||
|
||||
QJsonArray json_result = json_obj["result"].toArray();
|
||||
if (json_result.isEmpty()) {
|
||||
Error(QString("No lyrics for %1 %2").arg(artist).arg(title));
|
||||
Error(QString("No lyrics for %1 %2").arg(artist, title));
|
||||
return QJsonArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ void LyricsFetcher::Clear() {
|
||||
|
||||
queued_requests_.clear();
|
||||
|
||||
for (LyricsFetcherSearch *search : active_requests_.values()) {
|
||||
QList<LyricsFetcherSearch*> searches = active_requests_.values();
|
||||
for (LyricsFetcherSearch *search : searches) {
|
||||
search->Cancel();
|
||||
search->deleteLater();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ LyricsFetcherSearch::LyricsFetcherSearch(const LyricsSearchRequest &request, QOb
|
||||
|
||||
void LyricsFetcherSearch::TerminateSearch() {
|
||||
|
||||
for (int id : pending_requests_.keys()) {
|
||||
QList<int> keys = pending_requests_.keys();
|
||||
for (const int id : keys) {
|
||||
pending_requests_.take(id)->CancelSearch(id);
|
||||
}
|
||||
AllProvidersFinished();
|
||||
|
||||
@@ -51,7 +51,8 @@ LyricsProviders::~LyricsProviders() {
|
||||
void LyricsProviders::ReloadSettings() {
|
||||
|
||||
QMap<int, QString> all_providers;
|
||||
for (LyricsProvider *provider : lyrics_providers_.keys()) {
|
||||
QList<LyricsProvider*> old_providers = lyrics_providers_.keys();
|
||||
for (LyricsProvider *provider : old_providers) {
|
||||
if (!provider->is_enabled()) continue;
|
||||
all_providers.insert(provider->order(), provider->name());
|
||||
}
|
||||
@@ -62,18 +63,19 @@ void LyricsProviders::ReloadSettings() {
|
||||
s.endGroup();
|
||||
|
||||
int i = 0;
|
||||
QList<LyricsProvider*> providers;
|
||||
QList<LyricsProvider*> new_providers;
|
||||
for (const QString &name : providers_enabled) {
|
||||
LyricsProvider *provider = ProviderByName(name);
|
||||
if (provider) {
|
||||
provider->set_enabled(true);
|
||||
provider->set_order(++i);
|
||||
providers << provider;
|
||||
new_providers << provider;
|
||||
}
|
||||
}
|
||||
|
||||
for (LyricsProvider *provider : lyrics_providers_.keys()) {
|
||||
if (!providers.contains(provider)) {
|
||||
old_providers = lyrics_providers_.keys();
|
||||
for (LyricsProvider *provider : old_providers) {
|
||||
if (!new_providers.contains(provider)) {
|
||||
provider->set_enabled(false);
|
||||
provider->set_order(++i);
|
||||
}
|
||||
@@ -83,7 +85,8 @@ void LyricsProviders::ReloadSettings() {
|
||||
|
||||
LyricsProvider *LyricsProviders::ProviderByName(const QString &name) const {
|
||||
|
||||
for (LyricsProvider *provider : lyrics_providers_.keys()) {
|
||||
QList<LyricsProvider*> providers = lyrics_providers_.keys();
|
||||
for (LyricsProvider *provider : providers) {
|
||||
if (provider->name() == name) return provider;
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -74,7 +74,7 @@ bool MusixmatchLyricsProvider::StartSearch(const QString &artist, const QString
|
||||
|
||||
if (artist_stripped.isEmpty() || title_stripped.isEmpty()) return false;
|
||||
|
||||
QUrl url(QString("https://www.musixmatch.com/lyrics/%1/%2").arg(artist_stripped).arg(title_stripped));
|
||||
QUrl url(QString("https://www.musixmatch.com/lyrics/%1/%2").arg(artist_stripped, title_stripped));
|
||||
QNetworkRequest req(url);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
|
||||
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
|
||||
Reference in New Issue
Block a user