Rename enums

This commit is contained in:
Jonas Kvinge
2024-08-05 17:53:07 +02:00
parent ff6e93fc15
commit 1c4d3aebad
12 changed files with 72 additions and 72 deletions

View File

@@ -49,9 +49,9 @@ class SpotifyBaseRequest : public QObject {
enum class Type {
None,
Artists,
Albums,
Songs,
FavouriteArtists,
FavouriteAlbums,
FavouriteSongs,
SearchArtists,
SearchAlbums,
SearchSongs,

View File

@@ -129,13 +129,13 @@ void SpotifyRequest::Process() {
}
switch (type_) {
case Type::Artists:
case Type::FavouriteArtists:
GetArtists();
break;
case Type::Albums:
case Type::FavouriteAlbums:
GetAlbums();
break;
case Type::Songs:
case Type::FavouriteSongs:
GetSongs();
break;
case Type::SearchArtists:
@@ -243,7 +243,7 @@ void SpotifyRequest::FlushArtistsRequests() {
parameters << Param(QStringLiteral("offset"), QString::number(request.offset));
}
QNetworkReply *reply = nullptr;
if (type_ == Type::Artists) {
if (type_ == Type::FavouriteArtists) {
reply = CreateRequest(QStringLiteral("me/following"), parameters);
}
if (type_ == Type::SearchArtists) {
@@ -297,7 +297,7 @@ void SpotifyRequest::FlushAlbumsRequests() {
if (request.limit > 0) parameters << Param(QStringLiteral("limit"), QString::number(request.limit));
if (request.offset > 0) parameters << Param(QStringLiteral("offset"), QString::number(request.offset));
QNetworkReply *reply = nullptr;
if (type_ == Type::Albums) {
if (type_ == Type::FavouriteAlbums) {
reply = CreateRequest(QStringLiteral("me/albums"), parameters);
}
if (type_ == Type::SearchAlbums) {
@@ -352,7 +352,7 @@ void SpotifyRequest::FlushSongsRequests() {
parameters << Param(QStringLiteral("offset"), QString::number(request.offset));
}
QNetworkReply *reply = nullptr;
if (type_ == Type::Songs) {
if (type_ == Type::FavouriteSongs) {
reply = CreateRequest(QStringLiteral("me/tracks"), parameters);
}
if (type_ == Type::SearchSongs) {
@@ -539,7 +539,7 @@ void SpotifyRequest::ArtistsFinishCheck(const int limit, const int offset, const
if ((limit == 0 || limit > artists_received) && artists_received_ < artists_total_) {
int offset_next = offset + artists_received;
if (offset_next > 0 && offset_next < artists_total_) {
if (type_ == Type::Artists) AddArtistsRequest(offset_next);
if (type_ == Type::FavouriteArtists) AddArtistsRequest(offset_next);
else if (type_ == Type::SearchArtists) AddArtistsSearchRequest(offset_next);
}
}
@@ -655,7 +655,7 @@ void SpotifyRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_a
int offset = json_obj[QLatin1String("offset")].toInt();
int albums_total = json_obj[QLatin1String("total")].toInt();
if (type_ == Type::Albums || type_ == Type::SearchAlbums) {
if (type_ == Type::FavouriteAlbums || type_ == Type::SearchAlbums) {
albums_total_ = albums_total;
}
@@ -672,7 +672,7 @@ void SpotifyRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_a
}
QJsonArray array_items = value_items.toArray();
if (array_items.isEmpty()) {
if ((type_ == Type::Albums || type_ == Type::SearchAlbums || (type_ == Type::SearchSongs && fetchalbums_)) && offset_requested == 0) {
if ((type_ == Type::FavouriteAlbums || type_ == Type::SearchAlbums || (type_ == Type::SearchSongs && fetchalbums_)) && offset_requested == 0) {
no_results_ = true;
}
AlbumsFinishCheck(artist_artist);
@@ -799,7 +799,7 @@ void SpotifyRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_a
}
if (type_ == Type::Albums || type_ == Type::SearchAlbums) {
if (type_ == Type::FavouriteAlbums || type_ == Type::SearchAlbums) {
albums_received_ += albums_received;
emit UpdateProgress(query_id_, GetProgress(albums_received_, albums_total_));
}
@@ -816,13 +816,13 @@ void SpotifyRequest::AlbumsFinishCheck(const Artist &artist, const int limit, co
int offset_next = offset + albums_received;
if (offset_next > 0 && offset_next < albums_total) {
switch (type_) {
case Type::Albums:
case Type::FavouriteAlbums:
AddAlbumsRequest(offset_next);
break;
case Type::SearchAlbums:
AddAlbumsSearchRequest(offset_next);
break;
case Type::Artists:
case Type::FavouriteArtists:
case Type::SearchArtists:
AddArtistAlbumsRequest(artist, offset_next);
break;
@@ -954,7 +954,7 @@ void SpotifyRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, c
int offset = json_obj[QLatin1String("offset")].toInt();
int songs_total = json_obj[QLatin1String("total")].toInt();
if (type_ == Type::Songs || type_ == Type::SearchSongs) {
if (type_ == Type::FavouriteSongs || type_ == Type::SearchSongs) {
songs_total_ = songs_total;
}
@@ -972,7 +972,7 @@ void SpotifyRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, c
QJsonArray array_items = json_value.toArray();
if (array_items.isEmpty()) {
if ((type_ == Type::Songs || type_ == Type::SearchSongs) && offset_requested == 0) {
if ((type_ == Type::FavouriteSongs || type_ == Type::SearchSongs) && offset_requested == 0) {
no_results_ = true;
}
SongsFinishCheck(artist, album, limit_requested, offset_requested, songs_total, 0);
@@ -1014,7 +1014,7 @@ void SpotifyRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, c
songs_.insert(song.song_id(), song);
}
if (type_ == Type::Songs || type_ == Type::SearchSongs) {
if (type_ == Type::FavouriteSongs || type_ == Type::SearchSongs) {
songs_received_ += songs_received;
emit UpdateProgress(query_id_, GetProgress(songs_received_, songs_total_));
}
@@ -1031,7 +1031,7 @@ void SpotifyRequest::SongsFinishCheck(const Artist &artist, const Album &album,
int offset_next = offset + songs_received;
if (offset_next > 0 && offset_next < songs_total) {
switch (type_) {
case Type::Songs:
case Type::FavouriteSongs:
AddSongsRequest(offset_next);
break;
case Type::SearchSongs:
@@ -1041,9 +1041,9 @@ void SpotifyRequest::SongsFinishCheck(const Artist &artist, const Album &album,
break;
}
// fallthrough
case Type::Artists:
case Type::FavouriteArtists:
case Type::SearchArtists:
case Type::Albums:
case Type::FavouriteAlbums:
case Type::SearchAlbums:
AddAlbumSongsRequest(artist, album, offset_next);
break;

View File

@@ -117,7 +117,7 @@ class SpotifyRequest : public SpotifyBaseRequest {
private:
void StartRequests();
bool IsQuery() const { return (type_ == Type::Artists || type_ == Type::Albums || type_ == Type::Songs); }
bool IsQuery() const { return (type_ == Type::FavouriteArtists || type_ == Type::FavouriteAlbums || type_ == Type::FavouriteSongs); }
bool IsSearch() const { return (type_ == Type::SearchArtists || type_ == Type::SearchAlbums || type_ == Type::SearchSongs); }
void GetArtists();

View File

@@ -519,7 +519,7 @@ void SpotifyService::GetArtists() {
}
ResetArtistsRequest();
artists_request_.reset(new SpotifyRequest(this, app_, network_, SpotifyBaseRequest::Type::Artists, this), [](SpotifyRequest *request) { request->deleteLater(); });
artists_request_.reset(new SpotifyRequest(this, app_, network_, SpotifyBaseRequest::Type::FavouriteArtists, this), [](SpotifyRequest *request) { request->deleteLater(); });
QObject::connect(&*artists_request_, &SpotifyRequest::Results, this, &SpotifyService::ArtistsResultsReceived);
QObject::connect(&*artists_request_, &SpotifyRequest::UpdateStatus, this, &SpotifyService::ArtistsUpdateStatusReceived);
QObject::connect(&*artists_request_, &SpotifyRequest::ProgressSetMaximum, this, &SpotifyService::ArtistsProgressSetMaximumReceived);
@@ -571,7 +571,7 @@ void SpotifyService::GetAlbums() {
}
ResetAlbumsRequest();
albums_request_.reset(new SpotifyRequest(this, app_, network_, SpotifyBaseRequest::Type::Albums, this), [](SpotifyRequest *request) { request->deleteLater(); });
albums_request_.reset(new SpotifyRequest(this, app_, network_, SpotifyBaseRequest::Type::FavouriteAlbums, this), [](SpotifyRequest *request) { request->deleteLater(); });
QObject::connect(&*albums_request_, &SpotifyRequest::Results, this, &SpotifyService::AlbumsResultsReceived);
QObject::connect(&*albums_request_, &SpotifyRequest::UpdateStatus, this, &SpotifyService::AlbumsUpdateStatusReceived);
QObject::connect(&*albums_request_, &SpotifyRequest::ProgressSetMaximum, this, &SpotifyService::AlbumsProgressSetMaximumReceived);
@@ -623,7 +623,7 @@ void SpotifyService::GetSongs() {
}
ResetSongsRequest();
songs_request_.reset(new SpotifyRequest(this, app_, network_, SpotifyBaseRequest::Type::Songs, this), [](SpotifyRequest *request) { request->deleteLater(); });
songs_request_.reset(new SpotifyRequest(this, app_, network_, SpotifyBaseRequest::Type::FavouriteSongs, this), [](SpotifyRequest *request) { request->deleteLater(); });
QObject::connect(&*songs_request_, &SpotifyRequest::Results, this, &SpotifyService::SongsResultsReceived);
QObject::connect(&*songs_request_, &SpotifyRequest::UpdateStatus, this, &SpotifyService::SongsUpdateStatusReceived);
QObject::connect(&*songs_request_, &SpotifyRequest::ProgressSetMaximum, this, &SpotifyService::SongsProgressSetMaximumReceived);