Fix various clazy warnings
This commit is contained in:
@@ -48,7 +48,8 @@ AlbumCoverFetcher::AlbumCoverFetcher(CoverProviders *cover_providers, QObject *p
|
||||
|
||||
AlbumCoverFetcher::~AlbumCoverFetcher() {
|
||||
|
||||
for (AlbumCoverFetcherSearch *search : active_requests_.values()) {
|
||||
QList<AlbumCoverFetcherSearch*> searches = active_requests_.values();
|
||||
for (AlbumCoverFetcherSearch *search : searches) {
|
||||
search->disconnect();
|
||||
search->deleteLater();
|
||||
}
|
||||
@@ -104,7 +105,8 @@ void AlbumCoverFetcher::Clear() {
|
||||
|
||||
queued_requests_.clear();
|
||||
|
||||
for (AlbumCoverFetcherSearch *search : active_requests_.values()) {
|
||||
QList<AlbumCoverFetcherSearch*> searches = active_requests_.values();
|
||||
for (AlbumCoverFetcherSearch *search : searches) {
|
||||
search->Cancel();
|
||||
search->deleteLater();
|
||||
}
|
||||
|
||||
@@ -73,7 +73,8 @@ AlbumCoverFetcherSearch::~AlbumCoverFetcherSearch() {
|
||||
|
||||
void AlbumCoverFetcherSearch::TerminateSearch() {
|
||||
|
||||
for (quint64 id : pending_requests_.keys()) {
|
||||
QList<int> ids = pending_requests_.keys();
|
||||
for (const quint64 id : ids) {
|
||||
pending_requests_.take(id)->CancelSearch(id);
|
||||
}
|
||||
|
||||
@@ -352,7 +353,8 @@ void AlbumCoverFetcherSearch::ProviderCoverFetchFinished(QNetworkReply *reply) {
|
||||
float best_score = 0.0;
|
||||
|
||||
if (!candidate_images_.isEmpty()) {
|
||||
best_score = candidate_images_.keys().last();
|
||||
QList<float> scores = candidate_images_.keys();
|
||||
best_score = scores.last();
|
||||
qLog(Debug) << "Best image so far has a score of" << best_score;
|
||||
}
|
||||
|
||||
@@ -385,7 +387,8 @@ void AlbumCoverFetcherSearch::SendBestImage() {
|
||||
AlbumCoverImageResult result;
|
||||
|
||||
if (!candidate_images_.isEmpty()) {
|
||||
const CandidateImage best_image = candidate_images_.values().back();
|
||||
QList<CandidateImage> candidate_images = candidate_images_.values();
|
||||
const CandidateImage best_image = candidate_images.back();
|
||||
result = best_image.album_cover;
|
||||
|
||||
qLog(Info) << "Using" << best_image.result.image_url << "from" << best_image.result.provider << "with score" << best_image.result.score();
|
||||
@@ -411,7 +414,8 @@ void AlbumCoverFetcherSearch::Cancel() {
|
||||
TerminateSearch();
|
||||
}
|
||||
else if (!pending_image_loads_.isEmpty()) {
|
||||
for (QNetworkReply *reply : pending_image_loads_.keys()) {
|
||||
QList<QNetworkReply*> replies = pending_image_loads_.keys();
|
||||
for (QNetworkReply *reply : replies) {
|
||||
QObject::disconnect(reply, &QNetworkReply::finished, this, nullptr);
|
||||
reply->abort();
|
||||
reply->deleteLater();
|
||||
|
||||
@@ -53,7 +53,8 @@ CoverProviders::~CoverProviders() {
|
||||
void CoverProviders::ReloadSettings() {
|
||||
|
||||
QMap<int, QString> all_providers;
|
||||
for (CoverProvider *provider : cover_providers_.keys()) {
|
||||
QList<CoverProvider*> old_providers = cover_providers_.keys();
|
||||
for (CoverProvider *provider : old_providers) {
|
||||
if (!provider->is_enabled()) continue;
|
||||
all_providers.insert(provider->order(), provider->name());
|
||||
}
|
||||
@@ -64,18 +65,19 @@ void CoverProviders::ReloadSettings() {
|
||||
s.endGroup();
|
||||
|
||||
int i = 0;
|
||||
QList<CoverProvider*> providers;
|
||||
QList<CoverProvider*> new_providers;
|
||||
for (const QString &name : providers_enabled) {
|
||||
CoverProvider *provider = ProviderByName(name);
|
||||
if (provider) {
|
||||
provider->set_enabled(true);
|
||||
provider->set_order(++i);
|
||||
providers << provider;
|
||||
new_providers << provider;
|
||||
}
|
||||
}
|
||||
|
||||
for (CoverProvider *provider : cover_providers_.keys()) {
|
||||
if (!providers.contains(provider)) {
|
||||
old_providers = cover_providers_.keys();
|
||||
for (CoverProvider *provider : old_providers) {
|
||||
if (!new_providers.contains(provider)) {
|
||||
provider->set_enabled(false);
|
||||
provider->set_order(++i);
|
||||
}
|
||||
@@ -85,7 +87,8 @@ void CoverProviders::ReloadSettings() {
|
||||
|
||||
CoverProvider *CoverProviders::ProviderByName(const QString &name) const {
|
||||
|
||||
for (CoverProvider *provider : cover_providers_.keys()) {
|
||||
QList<CoverProvider*> cover_providers = cover_providers_.keys();
|
||||
for (CoverProvider *provider : cover_providers) {
|
||||
if (provider->name() == name) return provider;
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -38,10 +38,12 @@ CoverSearchStatistics &CoverSearchStatistics::operator +=(const CoverSearchStati
|
||||
network_requests_made_ += other.network_requests_made_;
|
||||
bytes_transferred_ += other.bytes_transferred_;
|
||||
|
||||
for (const QString &key : other.chosen_images_by_provider_.keys()) {
|
||||
QStringList keys = other.chosen_images_by_provider_.keys();
|
||||
for (const QString &key : keys) {
|
||||
chosen_images_by_provider_[key] += other.chosen_images_by_provider_[key];
|
||||
}
|
||||
for (const QString &key : other.total_images_by_provider_.keys()) {
|
||||
keys = other.total_images_by_provider_.keys();
|
||||
for (const QString &key : keys) {
|
||||
total_images_by_provider_[key] += other.total_images_by_provider_[key];
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
|
||||
else if (json_obj.contains("error") && json_obj.contains("message")) {
|
||||
int error = json_obj["error"].toInt();
|
||||
QString message = json_obj["message"].toString();
|
||||
Error(QString("Error: %1: %2").arg(QString::number(error)).arg(message));
|
||||
Error(QString("Error: %1: %2").arg(QString::number(error), message));
|
||||
emit SearchFinished(id, results);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ bool MusicbrainzCoverProvider::StartSearch(const QString &artist, const QString
|
||||
|
||||
void MusicbrainzCoverProvider::SendSearchRequest(const SearchRequest &request) {
|
||||
|
||||
QString query = QString("release:\"%1\" AND artist:\"%2\"").arg(request.album.trimmed().replace('"', "\\\"")).arg(request.artist.trimmed().replace('"', "\\\""));
|
||||
QString query = QString("release:\"%1\" AND artist:\"%2\"").arg(request.album.trimmed().replace('"', "\\\""), request.artist.trimmed().replace('"', "\\\""));
|
||||
|
||||
QUrlQuery url_query;
|
||||
url_query.addQueryItem("query", query);
|
||||
|
||||
@@ -76,7 +76,7 @@ bool MusixmatchCoverProvider::StartSearch(const QString &artist, const QString &
|
||||
|
||||
if (artist_stripped.isEmpty() || album_stripped.isEmpty()) return false;
|
||||
|
||||
QUrl url(QString("https://www.musixmatch.com/album/%1/%2").arg(artist_stripped).arg(album_stripped));
|
||||
QUrl url(QString("https://www.musixmatch.com/album/%1/%2").arg(artist_stripped, album_stripped));
|
||||
QNetworkRequest req(url);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
|
||||
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
|
||||
@@ -183,7 +183,6 @@ void SpotifyCoverProvider::RedirectArrived() {
|
||||
else if (url_query.hasQueryItem("code") && url_query.hasQueryItem("state")) {
|
||||
qLog(Debug) << "Spotify: Authorization URL Received" << url;
|
||||
QString code = url_query.queryItemValue("code");
|
||||
QString state = url_query.queryItemValue("state");
|
||||
QUrl redirect_url(kOAuthRedirectUrl);
|
||||
redirect_url.setPort(server_->url().port());
|
||||
RequestAccessToken(code, redirect_url);
|
||||
@@ -282,7 +281,7 @@ void SpotifyCoverProvider::AccessTokenRequestFinished(QNetworkReply *reply) {
|
||||
if (!json_obj.isEmpty() && json_obj.contains("error") && json_obj.contains("error_description")) {
|
||||
QString error = json_obj["error"].toString();
|
||||
QString error_description = json_obj["error_description"].toString();
|
||||
login_errors_ << QString("Authentication failure: %1 (%2)").arg(error).arg(error_description);
|
||||
login_errors_ << QString("Authentication failure: %1 (%2)").arg(error, error_description);
|
||||
}
|
||||
}
|
||||
if (login_errors_.isEmpty()) {
|
||||
|
||||
@@ -271,7 +271,7 @@ void TidalCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
|
||||
<< qMakePair(QString("750x750"), QSize(750, 750))
|
||||
<< qMakePair(QString("640x640"), QSize(640, 640));
|
||||
for (const QPair<QString, QSize> &cover_size : cover_sizes) {
|
||||
QUrl cover_url(QString("%1/images/%2/%3.jpg").arg(kResourcesUrl).arg(cover).arg(cover_size.first));
|
||||
QUrl cover_url(QString("%1/images/%2/%3.jpg").arg(kResourcesUrl, cover, cover_size.first));
|
||||
cover_result.image_url = cover_url;
|
||||
cover_result.image_size = cover_size.second;
|
||||
results << cover_result;
|
||||
|
||||
Reference in New Issue
Block a user