Use QJsonValueRef

This commit is contained in:
Jonas Kvinge
2021-03-26 22:10:43 +01:00
parent 14fb647647
commit 91ab8e22b7
16 changed files with 50 additions and 48 deletions

View File

@@ -221,10 +221,10 @@ void DeezerCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
QMap<QUrl, CoverProviderSearchResult> results;
int i = 0;
for (const QJsonValue json_value : array_data) {
for (const QJsonValueRef json_value : array_data) {
if (!json_value.isObject()) {
Error("Invalid Json reply, data array value is not a object.", json_value);
Error("Invalid Json reply, data array value is not a object.");
continue;
}
QJsonObject json_obj = json_value.toObject();

View File

@@ -273,10 +273,10 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
array_results = value_results.toArray();
}
for (const QJsonValue value_result : array_results) {
for (const QJsonValueRef value_result : array_results) {
if (!value_result.isObject()) {
Error("Invalid Json reply, results value is not a object.", value_result);
Error("Invalid Json reply, results value is not a object.");
continue;
}
QJsonObject obj_result = value_result.toObject();
@@ -380,9 +380,9 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
QJsonArray array_artists = value_artists.toArray();
int i = 0;
QString artist;
for (const QJsonValue value_artist : array_artists) {
for (const QJsonValueRef value_artist : array_artists) {
if (!value_artist.isObject()) {
Error("Invalid Json reply, atists array value is not a object.", value_artist);
Error("Invalid Json reply, atists array value is not a object.");
continue;
}
QJsonObject obj_artist = value_artist.toObject();
@@ -421,10 +421,10 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
return;
}
for (const QJsonValue value_image : array_images) {
for (const QJsonValueRef value_image : array_images) {
if (!value_image.isObject()) {
Error("Invalid Json reply, images array value is not an object.", value_image);
Error("Invalid Json reply, images array value is not an object.");
continue;
}
QJsonObject obj_image = value_image.toObject();

View File

@@ -230,10 +230,10 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
}
QJsonArray array_type = value_type.toArray();
for (const QJsonValue value : array_type) {
for (const QJsonValueRef value : array_type) {
if (!value.isObject()) {
Error("Invalid Json reply, value in albummatches/trackmatches array is not a object.", value);
Error("Invalid Json reply, value in albummatches/trackmatches array is not a object.");
continue;
}
QJsonObject obj = value.toObject();
@@ -255,9 +255,9 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
QJsonArray array_image = json_image.toArray();
QUrl url;
LastFmImageSize size(LastFmImageSize::Unknown);
for (const QJsonValue value_image : array_image) {
for (const QJsonValueRef value_image : array_image) {
if (!value_image.isObject()) {
Error("Invalid Json reply, album image value is not an object.", value_image);
Error("Invalid Json reply, album image value is not an object.");
continue;
}
QJsonObject obj_image = value_image.toObject();

View File

@@ -167,10 +167,10 @@ void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
return;
}
for (const QJsonValue value_release : array_releases) {
for (const QJsonValueRef value_release : array_releases) {
if (!value_release.isObject()) {
Error("Invalid Json reply, releases array value is not an object.", value_release);
Error("Invalid Json reply, releases array value is not an object.");
continue;
}
QJsonObject obj_release = value_release.toObject();
@@ -187,9 +187,9 @@ void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
QJsonArray array_artists = json_artists.toArray();
int i = 0;
QString artist;
for (const QJsonValue value_artist : array_artists) {
for (const QJsonValueRef value_artist : array_artists) {
if (!value_artist.isObject()) {
Error("Invalid Json reply, artist is not a object.", value_artist);
Error("Invalid Json reply, artist is not a object.");
continue;
}
QJsonObject obj_artist = value_artist.toObject();

View File

@@ -217,10 +217,10 @@ void QobuzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
}
QJsonArray array_items = value_items.toArray();
for (const QJsonValue value : array_items) {
for (const QJsonValueRef value : array_items) {
if (!value.isObject()) {
Error("Invalid Json reply, value in items is not a object.", value);
Error("Invalid Json reply, value in items is not a object.");
continue;
}
QJsonObject item_obj = value.toObject();

View File

@@ -495,7 +495,7 @@ void SpotifyCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id,
}
CoverProviderSearchResults results;
for (const QJsonValue value_item : array_items) {
for (const QJsonValueRef value_item : array_items) {
if (!value_item.isObject()) {
continue;
@@ -515,14 +515,14 @@ void SpotifyCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id,
QString album = obj_album["name"].toString();
QStringList artists;
for (const QJsonValue value_artist : array_artists) {
for (const QJsonValueRef value_artist : array_artists) {
if (!value_artist.isObject()) continue;
QJsonObject obj_artist = value_artist.toObject();
if (!obj_artist.contains("name")) continue;
artists << obj_artist["name"].toString();
}
for (const QJsonValue value_image : array_images) {
for (const QJsonValueRef value_image : array_images) {
if (!value_image.isObject()) continue;
QJsonObject obj_image = value_image.toObject();
if (!obj_image.contains("url") || !obj_image.contains("width") || !obj_image.contains("height")) continue;

View File

@@ -212,10 +212,10 @@ void TidalCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
CoverProviderSearchResults results;
int i = 0;
for (const QJsonValue value_item : array_items) {
for (const QJsonValueRef value_item : array_items) {
if (!value_item.isObject()) {
Error("Invalid Json reply, items array item is not a object.", value_item);
Error("Invalid Json reply, items array item is not a object.");
continue;
}
QJsonObject obj_item = value_item.toObject();

View File

@@ -106,7 +106,7 @@ void AuddLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
}
LyricsSearchResults results;
for (const QJsonValue value : json_result) {
for (const QJsonValueRef value : json_result) {
if (!value.isObject()) {
qLog(Error) << "AudDLyrics: Invalid Json reply, result is not an object.";
qLog(Debug) << value;

View File

@@ -169,11 +169,11 @@ void AcoustidClient::RequestFinished(QNetworkReply *reply, const int request_id)
// List of <id, nb of sources> pairs
QList<IdSource> id_source_list;
for (const QJsonValue v : json_results) {
for (const QJsonValueRef v : json_results) {
QJsonObject r = v.toObject();
if (!r["recordings"].isUndefined()) {
QJsonArray json_recordings = r["recordings"].toArray();
for (const QJsonValue recording : json_recordings) {
for (const QJsonValueRef recording : json_recordings) {
QJsonObject o = recording.toObject();
if (!o["id"].isUndefined()) {
id_source_list << IdSource(o["id"].toString(), o["sources"].toInt());

View File

@@ -396,12 +396,12 @@ void QobuzRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re
}
int artists_received = 0;
for (const QJsonValue value_item : array_items) {
for (const QJsonValueRef value_item : array_items) {
++artists_received;
if (!value_item.isObject()) {
Error("Invalid Json reply, item not a object.", value_item);
Error("Invalid Json reply, item not a object.");
continue;
}
QJsonObject obj_item = value_item.toObject();
@@ -609,12 +609,12 @@ void QobuzRequest::AlbumsReceived(QNetworkReply *reply, const QString &artist_id
}
int albums_received = 0;
for (const QJsonValue value : array_items) {
for (const QJsonValueRef value : array_items) {
++albums_received;
if (!value.isObject()) {
Error("Invalid Json reply, item not a object.", value);
Error("Invalid Json reply, item not a object.");
continue;
}
QJsonObject obj_item = value.toObject();
@@ -907,10 +907,10 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const QString &artist_id_
//bool multidisc = false;
SongList songs;
int songs_received = 0;
for (const QJsonValue value_item : array_items) {
for (const QJsonValueRef value_item : array_items) {
if (!value_item.isObject()) {
Error("Invalid Json reply, track is not a object.", value_item);
Error("Invalid Json reply, track is not a object.");
continue;
}
QJsonObject obj_item = value_item.toObject();

View File

@@ -356,7 +356,7 @@ void LastFMImport::GetRecentTracksRequestFinished(QNetworkReply *reply, const in
QJsonArray array_track = json_obj["track"].toArray();
for (const QJsonValue value_track : array_track) {
for (const QJsonValueRef value_track : array_track) {
++lastplayed_received_;
@@ -518,7 +518,9 @@ void LastFMImport::GetTopTracksRequestFinished(QNetworkReply *reply, const int p
else {
QJsonArray array_track = json_obj["track"].toArray();
for (const QJsonValue value_track : array_track) {
for (QJsonArray::iterator it = array_track.begin() ; it != array_track.end() ; ++it) {
const QJsonValue &value_track = *it;
++playcount_received_;

View File

@@ -110,7 +110,7 @@ void ScrobblerCache::ReadCache() {
return;
}
for (const QJsonValue value : json_array) {
for (const QJsonValueRef value : json_array) {
if (!value.isObject()) {
qLog(Error) << "Scrobbler cache JSON tracks array value is not an object.";
qLog(Debug) << value;

View File

@@ -717,10 +717,10 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, QList<quint6
return;
}
for (const QJsonValue value : qAsConst(array_scrobble)) {
for (const QJsonValueRef value : array_scrobble) {
if (!value.isObject()) {
Error("Json scrobbles scrobble array value is not an object.", value);
Error("Json scrobbles scrobble array value is not an object.");
continue;
}
QJsonObject json_track = value.toObject();

View File

@@ -250,12 +250,12 @@ void SubsonicRequest::AlbumsReplyReceived(QNetworkReply *reply, const int offset
}
int albums_received = 0;
for (const QJsonValue value_album : array_albums) {
for (const QJsonValueRef value_album : array_albums) {
++albums_received;
if (!value_album.isObject()) {
Error("Invalid Json reply, album is not an object.", value_album);
Error("Invalid Json reply, album is not an object.");
continue;
}
QJsonObject obj_album = value_album.toObject();
@@ -439,10 +439,10 @@ void SubsonicRequest::AlbumSongsReplyReceived(QNetworkReply *reply, const QStrin
bool multidisc = false;
SongList songs;
int songs_received = 0;
for (const QJsonValue value_song : array_songs) {
for (const QJsonValueRef value_song : array_songs) {
if (!value_song.isObject()) {
Error("Invalid Json reply, track is not a object.", value_song);
Error("Invalid Json reply, track is not a object.");
continue;
}
QJsonObject obj_song = value_song.toObject();

View File

@@ -396,12 +396,12 @@ void TidalRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re
}
int artists_received = 0;
for (const QJsonValue value_item : array_items) {
for (const QJsonValueRef value_item : array_items) {
++artists_received;
if (!value_item.isObject()) {
Error("Invalid Json reply, item in array is not a object.", value_item);
Error("Invalid Json reply, item in array is not a object.");
continue;
}
QJsonObject obj_item = value_item.toObject();
@@ -574,12 +574,12 @@ void TidalRequest::AlbumsReceived(QNetworkReply *reply, const QString &artist_id
}
int albums_received = 0;
for (const QJsonValue value_item : array_items) {
for (const QJsonValueRef value_item : array_items) {
++albums_received;
if (!value_item.isObject()) {
Error("Invalid Json reply, item in array is not a object.", value_item);
Error("Invalid Json reply, item in array is not a object.");
continue;
}
QJsonObject obj_item = value_item.toObject();
@@ -861,10 +861,10 @@ void TidalRequest::SongsReceived(QNetworkReply *reply, const QString &artist_id,
bool multidisc = false;
SongList songs;
int songs_received = 0;
for (const QJsonValue value_item : json_items) {
for (const QJsonValueRef value_item : json_items) {
if (!value_item.isObject()) {
Error("Invalid Json reply, track is not a object.", value_item);
Error("Invalid Json reply, track is not a object.");
continue;
}
QJsonObject obj_item = value_item.toObject();

View File

@@ -270,7 +270,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
return;
}
QJsonArray json_array_urls = json_urls.toArray();
for (const QJsonValue value : json_array_urls) {
for (const QJsonValueRef value : json_array_urls) {
urls << QUrl(value.toString());
}
}