diff --git a/src/internet/groovesharkservice.cpp b/src/internet/groovesharkservice.cpp index 0c5fe603d..a634c9fdd 100644 --- a/src/internet/groovesharkservice.cpp +++ b/src/internet/groovesharkservice.cpp @@ -665,7 +665,7 @@ void GroovesharkService::RefreshPlaylist(int playlist_id, const QString& playlis parameters << Param("playlistID", playlist_id); QNetworkReply* reply = CreateRequest("getPlaylistSongs", parameters, true); connect(reply, SIGNAL(finished()), SLOT(PlaylistSongsRetrieved())); - + // Keep in mind correspondance between reply object and playlist pending_retrieve_playlists_.insert(reply, PlaylistInfo(playlist_id, playlist_name)); } diff --git a/src/internet/spotifyservice.cpp b/src/internet/spotifyservice.cpp index 67b34af71..b31eef0f0 100644 --- a/src/internet/spotifyservice.cpp +++ b/src/internet/spotifyservice.cpp @@ -109,7 +109,7 @@ void SpotifyService::LazyPopulate(QStandardItem* item) { server_->LoadStarred(); break; - case Type_UserPlaylist: + case InternetModel::Type_UserPlaylist: EnsureServerCreated(); server_->LoadUserPlaylist(item->data(Role_UserPlaylistIndex).toInt()); break; @@ -336,12 +336,16 @@ void SpotifyService::PlaylistsUpdated(const spotify_pb::Playlists& response) { const spotify_pb::Playlists::Playlist& msg = response.playlist(i); QStandardItem* item = new QStandardItem(QStringFromStdString(msg.name())); - item->setData(Type_UserPlaylist, InternetModel::Role_Type); + item->setData(InternetModel::Type_UserPlaylist, InternetModel::Role_Type); item->setData(true, InternetModel::Role_CanLazyLoad); item->setData(msg.index(), Role_UserPlaylistIndex); + item->setData(InternetModel::PlayBehaviour_SingleItem, InternetModel::Role_PlayBehaviour); root_->appendRow(item); playlists_ << item; + + // Preload the playlist items so that drag & drop works immediately. + LazyPopulate(item); } } @@ -392,6 +396,7 @@ void SpotifyService::UserPlaylistLoaded(const spotify_pb::LoadPlaylistResponse& } void SpotifyService::FillPlaylist(QStandardItem* item, const spotify_pb::LoadPlaylistResponse& response) { + qLog(Debug) << "Filling playlist:" << item->text(); if (item->hasChildren()) item->removeRows(0, item->rowCount()); @@ -464,9 +469,8 @@ void SpotifyService::SyncPlaylist() { QStandardItem* item = playlist_sync_action_->data().value(); Q_ASSERT(item); - Type type = static_cast(item->data(InternetModel::Role_Type).toInt()); - switch (type) { - case Type_UserPlaylist: { + switch (item->data(InternetModel::Role_Type).toInt()) { + case InternetModel::Type_UserPlaylist: { int index = item->data(Role_UserPlaylistIndex).toInt(); server_->SyncUserPlaylist(index); playlist_sync_ids_[index] = @@ -550,10 +554,10 @@ void SpotifyService::ShowContextMenu(const QModelIndex& index, const QPoint& glo EnsureMenuCreated(); QStandardItem* item = model()->itemFromIndex(index); if (item) { - Type type = static_cast(item->data(InternetModel::Role_Type).toInt()); + int type = item->data(InternetModel::Role_Type).toInt(); if (type == Type_InboxPlaylist || type == Type_StarredPlaylist || - type == Type_UserPlaylist) { + type == InternetModel::Type_UserPlaylist) { playlist_sync_action_->setData(qVariantFromValue(item)); playlist_context_menu_->popup(global_pos); return; diff --git a/src/internet/spotifyservice.h b/src/internet/spotifyservice.h index ec49e45ed..d287beeec 100644 --- a/src/internet/spotifyservice.h +++ b/src/internet/spotifyservice.h @@ -26,7 +26,6 @@ public: Type_SearchResults = InternetModel::TypeCount, Type_StarredPlaylist, Type_InboxPlaylist, - Type_UserPlaylist, Type_Track, };