Add Favorites support to SoundCloud (#5345)
This commit is contained in:
parent
1dfd71ea7f
commit
7ef095d0cb
@ -137,6 +137,10 @@ void SoundCloudService::EnsureItemsCreated() {
|
|||||||
InternetModel::Role_PlayBehaviour);
|
InternetModel::Role_PlayBehaviour);
|
||||||
root_->appendRow(user_tracks_);
|
root_->appendRow(user_tracks_);
|
||||||
|
|
||||||
|
|
||||||
|
user_favorites_ = new QStandardItem(tr("Favorites"));
|
||||||
|
root_->appendRow(user_favorites_);
|
||||||
|
|
||||||
RetrieveUserData(); // at least, try to (this will do nothing if user isn't
|
RetrieveUserData(); // at least, try to (this will do nothing if user isn't
|
||||||
// logged)
|
// logged)
|
||||||
}
|
}
|
||||||
@ -214,6 +218,7 @@ void SoundCloudService::RetrieveUserData() {
|
|||||||
RetrieveUserActivities();
|
RetrieveUserActivities();
|
||||||
RetrieveUserTracks();
|
RetrieveUserTracks();
|
||||||
RetrieveUserPlaylists();
|
RetrieveUserPlaylists();
|
||||||
|
RetrieveUserFavorites();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundCloudService::RetrieveUserTracks() {
|
void SoundCloudService::RetrieveUserTracks() {
|
||||||
@ -261,6 +266,14 @@ void SoundCloudService::RetrieveUserPlaylists() {
|
|||||||
SLOT(UserPlaylistsRetrieved(QNetworkReply*)), reply);
|
SLOT(UserPlaylistsRetrieved(QNetworkReply*)), reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoundCloudService::RetrieveUserFavorites() {
|
||||||
|
QList<Param> parameters;
|
||||||
|
parameters << Param("oauth_token", access_token_);
|
||||||
|
QNetworkReply* reply = CreateRequest("me/favorites", parameters);
|
||||||
|
NewClosure(reply, SIGNAL(finished()), this,
|
||||||
|
SLOT(UserFavoritesRetrieved(QNetworkReply*)), reply);
|
||||||
|
}
|
||||||
|
|
||||||
void SoundCloudService::UserPlaylistsRetrieved(QNetworkReply* reply) {
|
void SoundCloudService::UserPlaylistsRetrieved(QNetworkReply* reply) {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
@ -277,6 +290,17 @@ void SoundCloudService::UserPlaylistsRetrieved(QNetworkReply* reply) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoundCloudService::UserFavoritesRetrieved(QNetworkReply* reply) {
|
||||||
|
reply->deleteLater();
|
||||||
|
|
||||||
|
SongList songs = ExtractSongs(ExtractResult(reply));
|
||||||
|
// Fill results list
|
||||||
|
for (const Song& song : songs) {
|
||||||
|
QStandardItem* child = CreateSongItem(song);
|
||||||
|
user_favorites_->appendRow(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SoundCloudService::Search(const QString& text, bool now) {
|
void SoundCloudService::Search(const QString& text, bool now) {
|
||||||
pending_search_ = text;
|
pending_search_ = text;
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ class SoundCloudService : public InternetService {
|
|||||||
void UserTracksRetrieved(QNetworkReply* reply);
|
void UserTracksRetrieved(QNetworkReply* reply);
|
||||||
void UserActivitiesRetrieved(QNetworkReply* reply);
|
void UserActivitiesRetrieved(QNetworkReply* reply);
|
||||||
void UserPlaylistsRetrieved(QNetworkReply* reply);
|
void UserPlaylistsRetrieved(QNetworkReply* reply);
|
||||||
|
void UserFavoritesRetrieved(QNetworkReply* reply);
|
||||||
void PlaylistRetrieved(QNetworkReply* reply, int request_id);
|
void PlaylistRetrieved(QNetworkReply* reply, int request_id);
|
||||||
void Search(const QString& text, bool now = false);
|
void Search(const QString& text, bool now = false);
|
||||||
void DoSearch();
|
void DoSearch();
|
||||||
@ -91,6 +92,7 @@ class SoundCloudService : public InternetService {
|
|||||||
void RetrieveUserTracks();
|
void RetrieveUserTracks();
|
||||||
void RetrieveUserActivities();
|
void RetrieveUserActivities();
|
||||||
void RetrieveUserPlaylists();
|
void RetrieveUserPlaylists();
|
||||||
|
void RetrieveUserFavorites();
|
||||||
void RetrievePlaylist(int playlist_id, QStandardItem* playlist_item);
|
void RetrievePlaylist(int playlist_id, QStandardItem* playlist_item);
|
||||||
void ClearSearchResults();
|
void ClearSearchResults();
|
||||||
void EnsureItemsCreated();
|
void EnsureItemsCreated();
|
||||||
@ -112,6 +114,7 @@ class SoundCloudService : public InternetService {
|
|||||||
QStandardItem* user_tracks_;
|
QStandardItem* user_tracks_;
|
||||||
QStandardItem* user_playlists_;
|
QStandardItem* user_playlists_;
|
||||||
QStandardItem* user_activities_;
|
QStandardItem* user_activities_;
|
||||||
|
QStandardItem* user_favorites_;
|
||||||
|
|
||||||
NetworkAccessManager* network_;
|
NetworkAccessManager* network_;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user