Add missing const
This commit is contained in:
@@ -47,8 +47,8 @@ TidalBaseRequest::TidalBaseRequest(TidalService *service, SharedPtr<NetworkAcces
|
||||
|
||||
QNetworkReply *TidalBaseRequest::CreateRequest(const QString &ressource_name, const ParamList ¶ms_provided) {
|
||||
|
||||
ParamList params = ParamList() << params_provided
|
||||
<< Param(QStringLiteral("countryCode"), country_code());
|
||||
const ParamList params = ParamList() << params_provided
|
||||
<< Param(QStringLiteral("countryCode"), country_code());
|
||||
|
||||
QUrlQuery url_query;
|
||||
for (const Param ¶m : params) {
|
||||
|
||||
@@ -134,8 +134,8 @@ void TidalFavoriteRequest::AddFavorites(const FavoriteType type, const SongList
|
||||
|
||||
void TidalFavoriteRequest::AddFavoritesRequest(const FavoriteType type, const QStringList &id_list, const SongList &songs) {
|
||||
|
||||
ParamList params = ParamList() << Param(QStringLiteral("countryCode"), country_code())
|
||||
<< Param(FavoriteMethod(type), id_list.join(QLatin1Char(',')));
|
||||
const ParamList params = ParamList() << Param(QStringLiteral("countryCode"), country_code())
|
||||
<< Param(FavoriteMethod(type), id_list.join(QLatin1Char(',')));
|
||||
|
||||
QUrlQuery url_query;
|
||||
for (const Param ¶m : params) {
|
||||
@@ -204,7 +204,7 @@ void TidalFavoriteRequest::RemoveSongs(const SongList &songs) {
|
||||
|
||||
void TidalFavoriteRequest::RemoveSongs(const SongMap &songs) {
|
||||
|
||||
SongList songs_list = songs.values();
|
||||
const SongList songs_list = songs.values();
|
||||
for (const Song &song : songs_list) {
|
||||
RemoveFavoritesRequest(FavoriteType::Songs, song.song_id(), SongList() << song);
|
||||
}
|
||||
@@ -235,7 +235,7 @@ void TidalFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi
|
||||
}
|
||||
}
|
||||
|
||||
QStringList ids = songs_map.uniqueKeys();
|
||||
const QStringList ids = songs_map.uniqueKeys();
|
||||
for (const QString &id : ids) {
|
||||
RemoveFavoritesRequest(type, id, songs_map.values(id));
|
||||
}
|
||||
@@ -244,7 +244,7 @@ void TidalFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi
|
||||
|
||||
void TidalFavoriteRequest::RemoveFavoritesRequest(const FavoriteType type, const QString &id, const SongList &songs) {
|
||||
|
||||
ParamList params = ParamList() << Param(QStringLiteral("countryCode"), country_code());
|
||||
const ParamList params = ParamList() << Param(QStringLiteral("countryCode"), country_code());
|
||||
|
||||
QUrlQuery url_query;
|
||||
for (const Param ¶m : params) {
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QByteArray>
|
||||
@@ -470,14 +472,14 @@ void TidalRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonArray array_items = value_items.toArray();
|
||||
const QJsonArray array_items = value_items.toArray();
|
||||
if (array_items.isEmpty()) { // Empty array means no results
|
||||
ArtistsFinishCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
int artists_received = 0;
|
||||
for (const QJsonValueRef value_item : array_items) {
|
||||
for (const QJsonValue &value_item : array_items) {
|
||||
|
||||
++artists_received;
|
||||
|
||||
@@ -540,7 +542,7 @@ void TidalRequest::ArtistsFinishCheck(const int limit, const int offset, const i
|
||||
if (artists_requests_queue_.isEmpty() && artists_requests_active_ <= 0) { // Artist query is finished, get all albums for all artists.
|
||||
|
||||
// Get artist albums
|
||||
QList<ArtistAlbumsRequest> requests = artist_albums_requests_pending_.values();
|
||||
const QList<ArtistAlbumsRequest> requests = artist_albums_requests_pending_.values();
|
||||
for (const ArtistAlbumsRequest &request : requests) {
|
||||
AddArtistAlbumsRequest(request.artist);
|
||||
}
|
||||
@@ -652,14 +654,14 @@ void TidalRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_req
|
||||
AlbumsFinishCheck(artist_requested);
|
||||
return;
|
||||
}
|
||||
QJsonArray array_items = value_items.toArray();
|
||||
const QJsonArray array_items = value_items.toArray();
|
||||
if (array_items.isEmpty()) {
|
||||
AlbumsFinishCheck(artist_requested);
|
||||
return;
|
||||
}
|
||||
|
||||
int albums_received = 0;
|
||||
for (const QJsonValueRef value_item : array_items) {
|
||||
for (const QJsonValue &value_item : array_items) {
|
||||
|
||||
++albums_received;
|
||||
|
||||
@@ -930,7 +932,7 @@ void TidalRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, con
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonArray array_items = json_value.toArray();
|
||||
const QJsonArray array_items = json_value.toArray();
|
||||
if (array_items.isEmpty()) {
|
||||
SongsFinishCheck(artist, album, limit_requested, offset_requested, songs_total, 0);
|
||||
return;
|
||||
@@ -940,7 +942,7 @@ void TidalRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, con
|
||||
bool multidisc = false;
|
||||
SongList songs;
|
||||
int songs_received = 0;
|
||||
for (const QJsonValueRef value_item : array_items) {
|
||||
for (const QJsonValue &value_item : array_items) {
|
||||
|
||||
if (!value_item.isObject()) {
|
||||
Error(QStringLiteral("Invalid Json reply, track is not a object."));
|
||||
@@ -966,7 +968,7 @@ void TidalRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, con
|
||||
songs << song;
|
||||
}
|
||||
|
||||
for (Song song : songs) {
|
||||
for (Song song : std::as_const(songs)) {
|
||||
if (compilation) song.set_compilation_detected(true);
|
||||
if (!multidisc) song.set_disc(0);
|
||||
songs_.insert(song.song_id(), song);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <utility>
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
||||
@@ -379,7 +380,7 @@ void TidalService::RequestAccessToken(const QString &code) {
|
||||
}
|
||||
|
||||
QUrlQuery url_query;
|
||||
for (const Param ¶m : params) {
|
||||
for (const Param ¶m : std::as_const(params)) {
|
||||
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
|
||||
}
|
||||
|
||||
@@ -1006,7 +1007,7 @@ void TidalService::LoginError(const QString &error, const QVariant &debug) {
|
||||
if (!error.isEmpty()) login_errors_ << error;
|
||||
|
||||
QString error_html;
|
||||
for (const QString &e : login_errors_) {
|
||||
for (const QString &e : std::as_const(login_errors_)) {
|
||||
qLog(Error) << "Tidal:" << e;
|
||||
error_html += e + QLatin1String("<br />");
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
|
||||
QString mimetype = json_obj[QLatin1String("mimeType")].toString();
|
||||
QMimeDatabase mimedb;
|
||||
QStringList suffixes = mimedb.mimeTypeForName(mimetype).suffixes();
|
||||
const QStringList suffixes = mimedb.mimeTypeForName(mimetype).suffixes();
|
||||
for (const QString &suffix : suffixes) {
|
||||
filetype = Song::FiletypeByExtension(suffix);
|
||||
if (filetype != Song::FileType::Unknown) break;
|
||||
@@ -253,9 +253,9 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
QJsonArray json_array_urls = json_urls.toArray();
|
||||
const QJsonArray json_array_urls = json_urls.toArray();
|
||||
urls.reserve(json_array_urls.count());
|
||||
for (const QJsonValueRef value : json_array_urls) {
|
||||
for (const QJsonValue &value : json_array_urls) {
|
||||
urls << QUrl(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user