bool PlaylistHandler::createPlaylist(std::string name) { checkInit(); QDomNode node = root.firstChild(); while (!node.isNull()) { QDomElement element = node.toElement(); if (!element.isNull()) { if (element.tagName() == "Playlist") { if (element.attribute("name").toStdString() == name) { return false; } } } node = node.nextSibling(); } QDomElement thisPlaylist = doc.createElement("Playlist"); thisPlaylist.setAttribute("name", QString::fromStdString(name)); boost::uuids::uuid uuidobj = boost::uuids::random_generator()(); std::stringstream ss; ss << uuidobj; QString uuid = QString::fromStdString(ss.str()); thisPlaylist.setAttribute("id", uuid); root.appendChild(thisPlaylist); save(); emit playlistsChanged(getPlaylists()); return true; }
void PlaylistMenuUserInterface::onActivate() { Parent::onActivate(); mMenuTitle = "CHOOSE PLAYLIST"; // Replace with a getLevelCount() method on Game? ClientGame *game = getGame(); Vector<string> playlists = getPlaylists(); clearMenuItems(); // Any items to select from? if(playlists.size() > 0) { char c[2]; c[1] = 0; // null termination for(S32 i = 0; i < playlists.size(); i++) { if(playlists[i] == "") // Skip blanks, but there should be none continue; string playlistName = playlists[i]; c[0] = playlistName[0]; addMenuItem(new MenuItem(i, playlistName, processPlaylistSelectionCallback, "", InputCodeManager::stringToInputCode(c))); } sortMenuItems(); } addMenuItem(new MenuItem(playlists.size(), NO_PLAYLIST, processPlaylistSelectionCallback, "", InputCodeManager::stringToInputCode("N"))); }
void SpotifyIO::onTextMessageReceived(const QString &message) { QVariantMap json = QJsonDocument::fromJson(message.toUtf8()).toVariant().toMap(); if (json.contains("message")) { qDebug() << message; QStringList args = json["message"].toStringList(); if (args[0] == "do_work") { QScriptEngine engine; QScriptValue replyFunction = engine.newFunction(reply); engine.globalObject().setProperty("reply", replyFunction); QScriptValue value = engine.evaluate(args[1]); sendCommand("sp/work_done", QVariantList() << value.toString()); } else if (args[0] == "ping_flash2") { QString ping = args[1]; //QString pong = _constructPong(ping); //sendCommand("sp/pong_flash2", QVariantList() << pong); ping = ping.split(" ").join("-"); QUrl url; url.setScheme("http"); url.setHost("ping-pong.spotify.nodestuff.net"); url.setPath("/" + ping); QNetworkRequest req(url); req.setHeader(QNetworkRequest::UserAgentHeader, userAgent); QObject::connect(nam->get(req), SIGNAL(finished()), this, SLOT(onPongReply())); } else if (args[0] == "login_complete") { sendCommand("sp/log", QVariantList() << 41 << 1 << 0 << 0 << 0 << 0); sendCommand("sp/user_info", QVariantList(), this, COMMANDCALLBACK(onUserInfo)); getPlaylists(username, this, COMMANDCALLBACK(onMyPlaylists)); _state = LoggedInState; Q_EMIT stateChanged(); heartbeat->start(); } else { qWarning() << args[0] << "NOT IMPLEMENTED!"; } } else if (json.contains("id")) { int id = json["id"].toInt(); if (callbacks.contains(id)) { //qDebug() << "have callback for" << id << callbacks[id]; QMetaObject::invokeMethod(receivers.take(id), callbacks.take(id), Q_ARG(QVariant, json["result"])); } else { qDebug() << message; } } }
void MusicCollection::displayPlaylists() { std::cout << "\nPLaylists\n-----------------------------\n"; MusicPlaylistIterator ip = getPlaylists(); while( ip.hasNext() ) { MusicPlaylist *playlist = ip.next().value(); std::cout << playlist->getName() << std::endl; MusicTrackIterator it = playlist->getTracks(); while( it.hasNext() ) { MusicTrack *track = it.next(); std::cout << "\t-" << track->getTitle() << "(" << track->getArtist() << ")" << std::endl; } } }
void PlaylistHandler::renamePlaylist(std::string oldName, std::string newName) { checkInit(); QDomNode node = root.firstChild(); QDomElement renameElement; while (!node.isNull()) { QDomElement element = node.toElement(); if (!element.isNull() && element.tagName() == "Playlist" && element.attribute("name").toStdString() == oldName) { renameElement = element; } node = node.nextSibling(); } renameElement.setAttribute("name", QString::fromStdString(newName)); save(); emit playlistsChanged(getPlaylists()); }
void PlaylistHandler::removePlaylist(std::string playlistName) { checkInit(); QDomNode node = root.firstChild(); QDomNode removalNode; while (!node.isNull()) { QDomElement element = node.toElement(); if (!element.isNull() && element.tagName() == "Playlist" && element.attribute("name").toStdString() == playlistName) { removalNode = node; } node = node.nextSibling(); } root.removeChild(removalNode); save(); emit playlistsChanged(getPlaylists()); }
void VimeoPlaylistDialog::showEvent(QShowEvent *e) { Dialog::showEvent(e); getPlaylists(); }
void DailymotionPlaylistDialog::showEvent(QShowEvent *e) { Dialog::showEvent(e); getPlaylists(); }