Rename QueryType to Type
This commit is contained in:
@@ -48,7 +48,7 @@ class TidalBaseRequest : public QObject {
|
||||
public:
|
||||
explicit TidalBaseRequest(TidalService *service, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
|
||||
enum class QueryType {
|
||||
enum class Type {
|
||||
None,
|
||||
Artists,
|
||||
Albums,
|
||||
|
||||
@@ -58,7 +58,7 @@ constexpr int kMaxConcurrentAlbumCoverRequests = 1;
|
||||
constexpr int kFlushRequestsDelay = 200;
|
||||
} // namespace
|
||||
|
||||
TidalRequest::TidalRequest(TidalService *service, TidalUrlHandler *url_handler, Application *app, SharedPtr<NetworkAccessManager> network, QueryType query_type, QObject *parent)
|
||||
TidalRequest::TidalRequest(TidalService *service, TidalUrlHandler *url_handler, Application *app, SharedPtr<NetworkAccessManager> network, Type query_type, QObject *parent)
|
||||
: TidalBaseRequest(service, network, parent),
|
||||
service_(service),
|
||||
url_handler_(url_handler),
|
||||
@@ -148,22 +148,22 @@ void TidalRequest::Process() {
|
||||
}
|
||||
|
||||
switch (query_type_) {
|
||||
case QueryType::Artists:
|
||||
case Type::Artists:
|
||||
GetArtists();
|
||||
break;
|
||||
case QueryType::Albums:
|
||||
case Type::Albums:
|
||||
GetAlbums();
|
||||
break;
|
||||
case QueryType::Songs:
|
||||
case Type::Songs:
|
||||
GetSongs();
|
||||
break;
|
||||
case QueryType::SearchArtists:
|
||||
case Type::SearchArtists:
|
||||
ArtistsSearch();
|
||||
break;
|
||||
case QueryType::SearchAlbums:
|
||||
case Type::SearchAlbums:
|
||||
AlbumsSearch();
|
||||
break;
|
||||
case QueryType::SearchSongs:
|
||||
case Type::SearchSongs:
|
||||
SongsSearch();
|
||||
break;
|
||||
default:
|
||||
@@ -250,14 +250,14 @@ void TidalRequest::FlushArtistsRequests() {
|
||||
Request request = artists_requests_queue_.dequeue();
|
||||
|
||||
ParamList parameters;
|
||||
if (query_type_ == QueryType::SearchArtists) parameters << Param(QStringLiteral("query"), search_text_);
|
||||
if (query_type_ == Type::SearchArtists) parameters << Param(QStringLiteral("query"), search_text_);
|
||||
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 (query_type_ == QueryType::Artists) {
|
||||
if (query_type_ == Type::Artists) {
|
||||
reply = CreateRequest(QStringLiteral("users/%1/favorites/artists").arg(service_->user_id()), parameters);
|
||||
}
|
||||
if (query_type_ == QueryType::SearchArtists) {
|
||||
if (query_type_ == Type::SearchArtists) {
|
||||
reply = CreateRequest(QStringLiteral("search/artists"), parameters);
|
||||
}
|
||||
if (!reply) continue;
|
||||
@@ -298,14 +298,14 @@ void TidalRequest::FlushAlbumsRequests() {
|
||||
Request request = albums_requests_queue_.dequeue();
|
||||
|
||||
ParamList parameters;
|
||||
if (query_type_ == QueryType::SearchAlbums) parameters << Param(QStringLiteral("query"), search_text_);
|
||||
if (query_type_ == Type::SearchAlbums) parameters << Param(QStringLiteral("query"), search_text_);
|
||||
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 (query_type_ == QueryType::Albums) {
|
||||
if (query_type_ == Type::Albums) {
|
||||
reply = CreateRequest(QStringLiteral("users/%1/favorites/albums").arg(service_->user_id()), parameters);
|
||||
}
|
||||
if (query_type_ == QueryType::SearchAlbums) {
|
||||
if (query_type_ == Type::SearchAlbums) {
|
||||
reply = CreateRequest(QStringLiteral("search/albums"), parameters);
|
||||
}
|
||||
if (!reply) continue;
|
||||
@@ -346,14 +346,14 @@ void TidalRequest::FlushSongsRequests() {
|
||||
Request request = songs_requests_queue_.dequeue();
|
||||
|
||||
ParamList parameters;
|
||||
if (query_type_ == QueryType::SearchSongs) parameters << Param(QStringLiteral("query"), search_text_);
|
||||
if (query_type_ == Type::SearchSongs) parameters << Param(QStringLiteral("query"), search_text_);
|
||||
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 (query_type_ == QueryType::Songs) {
|
||||
if (query_type_ == Type::Songs) {
|
||||
reply = CreateRequest(QStringLiteral("users/%1/favorites/tracks").arg(service_->user_id()), parameters);
|
||||
}
|
||||
if (query_type_ == QueryType::SearchSongs) {
|
||||
if (query_type_ == Type::SearchSongs) {
|
||||
reply = CreateRequest(QStringLiteral("search/tracks"), parameters);
|
||||
}
|
||||
if (!reply) continue;
|
||||
@@ -532,8 +532,8 @@ void TidalRequest::ArtistsFinishCheck(const int limit, const int offset, const i
|
||||
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 (query_type_ == QueryType::Artists) AddArtistsRequest(offset_next);
|
||||
else if (query_type_ == QueryType::SearchArtists) AddArtistsSearchRequest(offset_next);
|
||||
if (query_type_ == Type::Artists) AddArtistsRequest(offset_next);
|
||||
else if (query_type_ == Type::SearchArtists) AddArtistsSearchRequest(offset_next);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -766,7 +766,7 @@ void TidalRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_req
|
||||
|
||||
}
|
||||
|
||||
if (query_type_ == QueryType::Albums || query_type_ == QueryType::SearchAlbums) {
|
||||
if (query_type_ == Type::Albums || query_type_ == Type::SearchAlbums) {
|
||||
albums_received_ += albums_received;
|
||||
emit UpdateProgress(query_id_, GetProgress(albums_received_, albums_total_));
|
||||
}
|
||||
@@ -783,14 +783,14 @@ void TidalRequest::AlbumsFinishCheck(const Artist &artist, const int limit, cons
|
||||
int offset_next = offset + albums_received;
|
||||
if (offset_next > 0 && offset_next < albums_total) {
|
||||
switch (query_type_) {
|
||||
case QueryType::Albums:
|
||||
case Type::Albums:
|
||||
AddAlbumsRequest(offset_next);
|
||||
break;
|
||||
case QueryType::SearchAlbums:
|
||||
case Type::SearchAlbums:
|
||||
AddAlbumsSearchRequest(offset_next);
|
||||
break;
|
||||
case QueryType::Artists:
|
||||
case QueryType::SearchArtists:
|
||||
case Type::Artists:
|
||||
case Type::SearchArtists:
|
||||
AddArtistAlbumsRequest(artist, offset_next);
|
||||
break;
|
||||
default:
|
||||
@@ -832,7 +832,7 @@ void TidalRequest::SongsReplyReceived(QNetworkReply *reply, const int limit_requ
|
||||
|
||||
--songs_requests_active_;
|
||||
++songs_requests_received_;
|
||||
if (query_type_ == QueryType::SearchSongs && fetchalbums_) {
|
||||
if (query_type_ == Type::SearchSongs && fetchalbums_) {
|
||||
AlbumsReceived(reply, Artist(), limit_requested, offset_requested, offset_requested == 0);
|
||||
}
|
||||
else {
|
||||
@@ -972,7 +972,7 @@ void TidalRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, con
|
||||
songs_.insert(song.song_id(), song);
|
||||
}
|
||||
|
||||
if (query_type_ == QueryType::Songs || query_type_ == QueryType::SearchSongs) {
|
||||
if (query_type_ == Type::Songs || query_type_ == Type::SearchSongs) {
|
||||
songs_received_ += songs_received;
|
||||
emit UpdateProgress(query_id_, GetProgress(songs_received_, songs_total_));
|
||||
}
|
||||
@@ -989,20 +989,20 @@ void TidalRequest::SongsFinishCheck(const Artist &artist, const Album &album, co
|
||||
int offset_next = offset + songs_received;
|
||||
if (offset_next > 0 && offset_next < songs_total) {
|
||||
switch (query_type_) {
|
||||
case QueryType::Songs:
|
||||
case Type::Songs:
|
||||
AddSongsRequest(offset_next);
|
||||
break;
|
||||
case QueryType::SearchSongs:
|
||||
case Type::SearchSongs:
|
||||
// If artist_id and album_id isn't zero it means that it's a songs search where we fetch all albums too. So fallthrough.
|
||||
if (artist.artist_id.isEmpty() && album.album_id.isEmpty()) {
|
||||
AddSongsSearchRequest(offset_next);
|
||||
break;
|
||||
}
|
||||
[[fallthrough]];
|
||||
case QueryType::Artists:
|
||||
case QueryType::SearchArtists:
|
||||
case QueryType::Albums:
|
||||
case QueryType::SearchAlbums:
|
||||
case Type::Artists:
|
||||
case Type::SearchArtists:
|
||||
case Type::Albums:
|
||||
case Type::SearchAlbums:
|
||||
AddAlbumSongsRequest(artist, album, offset_next);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -53,7 +53,7 @@ class TidalRequest : public TidalBaseRequest {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TidalRequest(TidalService *service, TidalUrlHandler *url_handler, Application *app, SharedPtr<NetworkAccessManager> network, QueryType query_type, QObject *parent);
|
||||
explicit TidalRequest(TidalService *service, TidalUrlHandler *url_handler, Application *app, SharedPtr<NetworkAccessManager> network, Type query_type, QObject *parent);
|
||||
~TidalRequest() override;
|
||||
|
||||
void ReloadSettings();
|
||||
@@ -124,8 +124,8 @@ class TidalRequest : public TidalBaseRequest {
|
||||
void LoginComplete(const bool success, const QString &error = QString());
|
||||
|
||||
private:
|
||||
bool IsQuery() { return (query_type_ == QueryType::Artists || query_type_ == QueryType::Albums || query_type_ == QueryType::Songs); }
|
||||
bool IsSearch() { return (query_type_ == QueryType::SearchArtists || query_type_ == QueryType::SearchAlbums || query_type_ == QueryType::SearchSongs); }
|
||||
bool IsQuery() const { return (query_type_ == Type::Artists || query_type_ == Type::Albums || query_type_ == Type::Songs); }
|
||||
bool IsSearch() const { return (query_type_ == Type::SearchArtists || query_type_ == Type::SearchAlbums || query_type_ == Type::SearchSongs); }
|
||||
|
||||
void StartRequests();
|
||||
void FlushRequests();
|
||||
@@ -178,7 +178,7 @@ class TidalRequest : public TidalBaseRequest {
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
QTimer *timer_flush_requests_;
|
||||
|
||||
const QueryType query_type_;
|
||||
const Type query_type_;
|
||||
const bool fetchalbums_;
|
||||
const QString coversize_;
|
||||
|
||||
|
||||
@@ -732,7 +732,7 @@ void TidalService::GetArtists() {
|
||||
}
|
||||
|
||||
ResetArtistsRequest();
|
||||
artists_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::QueryType::Artists, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
artists_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::Type::Artists, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
QObject::connect(&*artists_request_, &TidalRequest::RequestLogin, this, &TidalService::SendLogin);
|
||||
QObject::connect(&*artists_request_, &TidalRequest::Results, this, &TidalService::ArtistsResultsReceived);
|
||||
QObject::connect(&*artists_request_, &TidalRequest::UpdateStatus, this, &TidalService::ArtistsUpdateStatusReceived);
|
||||
@@ -787,7 +787,7 @@ void TidalService::GetAlbums() {
|
||||
}
|
||||
|
||||
ResetAlbumsRequest();
|
||||
albums_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::QueryType::Albums, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
albums_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::Type::Albums, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
QObject::connect(&*albums_request_, &TidalRequest::RequestLogin, this, &TidalService::SendLogin);
|
||||
QObject::connect(&*albums_request_, &TidalRequest::Results, this, &TidalService::AlbumsResultsReceived);
|
||||
QObject::connect(&*albums_request_, &TidalRequest::UpdateStatus, this, &TidalService::AlbumsUpdateStatusReceived);
|
||||
@@ -842,7 +842,7 @@ void TidalService::GetSongs() {
|
||||
}
|
||||
|
||||
ResetSongsRequest();
|
||||
songs_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::QueryType::Songs, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
songs_request_.reset(new TidalRequest(this, url_handler_, app_, network_, TidalBaseRequest::Type::Songs, this), [](TidalRequest *request) { request->deleteLater(); });
|
||||
QObject::connect(&*songs_request_, &TidalRequest::RequestLogin, this, &TidalService::SendLogin);
|
||||
QObject::connect(&*songs_request_, &TidalRequest::Results, this, &TidalService::SongsResultsReceived);
|
||||
QObject::connect(&*songs_request_, &TidalRequest::UpdateStatus, this, &TidalService::SongsUpdateStatusReceived);
|
||||
@@ -916,17 +916,17 @@ void TidalService::CancelSearch() {
|
||||
|
||||
void TidalService::SendSearch() {
|
||||
|
||||
TidalBaseRequest::QueryType query_type = TidalBaseRequest::QueryType::None;
|
||||
TidalBaseRequest::Type query_type = TidalBaseRequest::Type::None;
|
||||
|
||||
switch (pending_search_type_) {
|
||||
case StreamingSearchView::SearchType::Artists:
|
||||
query_type = TidalBaseRequest::QueryType::SearchArtists;
|
||||
query_type = TidalBaseRequest::Type::SearchArtists;
|
||||
break;
|
||||
case StreamingSearchView::SearchType::Albums:
|
||||
query_type = TidalBaseRequest::QueryType::SearchAlbums;
|
||||
query_type = TidalBaseRequest::Type::SearchAlbums;
|
||||
break;
|
||||
case StreamingSearchView::SearchType::Songs:
|
||||
query_type = TidalBaseRequest::QueryType::SearchSongs;
|
||||
query_type = TidalBaseRequest::Type::SearchSongs;
|
||||
break;
|
||||
default:
|
||||
//Error("Invalid search type.");
|
||||
|
||||
Reference in New Issue
Block a user