void Spotify::compileNewListOfPlaylists() { sp_playlistcontainer * pc = sp_session_playlistcontainer(sp); int numPlaylists = sp_playlistcontainer_num_playlists(pc); QStringList names; for (int idx = 0; idx < numPlaylists; ++idx) { sp_playlist *pl = sp_playlistcontainer_playlist(pc, idx); names << QString::fromLocal8Bit(sp_playlist_name(pl)); } emit playlistsUpdated(names); }
void Collection::gotPlaylists(QNetworkReply* reply) { QString playlistsList = reply->readAll(); QRegExp playlistMatcher("\\[(\\d+),\"(\\w+)\"\\]"); int pos = 0; Playlist *playlist; while ((pos = playlistMatcher.indexIn(playlistsList, pos)) != -1) { playlist = new Playlist; playlist->id = playlistMatcher.cap(1).toInt(); playlist->name = playlistMatcher.cap(2); m_playlists.append(playlist); pos += playlistMatcher.matchedLength(); } emit playlistsUpdated(); reply->manager()->deleteLater(); reply->deleteLater(); }