void SomaFMService::RefreshStreamsFinished(QNetworkReply* reply, int task_id) { app_->task_manager()->SetTaskFinished(task_id); reply->deleteLater(); if (reply->error() != QNetworkReply::NoError) { // TODO: Error handling qLog(Error) << reply->errorString(); return; } StreamList list; QXmlStreamReader reader(reply); while (!reader.atEnd()) { reader.readNext(); if (reader.tokenType() == QXmlStreamReader::StartElement && reader.name() == "channel") { ReadChannel(reader, &list); } } streams_.Update(list); // Only update the item's children if it's already been populated if (!root_->data(InternetModel::Role_CanLazyLoad).toBool()) PopulateStreams(); emit StreamsChanged(); }
SavedRadioSearchProvider::SavedRadioSearchProvider(SavedRadio* service, Application* app, QObject* parent) : SimpleSearchProvider(app, parent), service_(service) { Init(tr("Your radio streams"), "savedradio", IconLoader::Load("document-open-remote"), MimeDataContainsUrlsOnly); set_max_suggestion_count(3); connect(service_, SIGNAL(StreamsChanged()), SLOT(MaybeRecreateItems())); RecreateItems(); }
void SavedRadio::SaveStreams() { QSettings s; s.beginGroup(kSettingsGroup); int count = streams_.size(); s.beginWriteArray("streams", count); for (int i = 0; i < count; ++i) { s.setArrayIndex(i); s.setValue("url", streams_[i].url_); s.setValue("name", streams_[i].name_); } s.endArray(); emit StreamsChanged(); }
void DigitallyImportedServiceBase::RefreshStreamsFinished(QNetworkReply* reply, int task_id) { app_->task_manager()->SetTaskFinished(task_id); reply->deleteLater(); // Parse the list and sort by name DigitallyImportedClient::ChannelList channels = api_client_->ParseChannelList(reply); qSort(channels); saved_channels_.Update(channels); // Only update the item's children if it's already been populated if (!root_->data(InternetModel::Role_CanLazyLoad).toBool()) PopulateStreams(); emit StreamsChanged(); }
IntergalacticFMSearchProvider::IntergalacticFMSearchProvider( IntergalacticFMServiceBase* service, Application* app, QObject* parent) : SimpleSearchProvider(app, parent), service_(service) { Init(service->name(), service->url_scheme(), service->icon(), CanGiveSuggestions); set_result_limit(3); set_max_suggestion_count(3); icon_ = ScaleAndPad( service->icon().pixmap(service->icon().availableSizes()[0]).toImage()); connect(service, SIGNAL(StreamsChanged()), SLOT(MaybeRecreateItems())); // Load the stream list on startup only if it doesn't involve going to update // info from the server. if (!service_->IsStreamListStale()) RecreateItems(); }
DigitallyImportedSearchProvider::DigitallyImportedSearchProvider( DigitallyImportedServiceBase* service, QObject* parent) : SimpleSearchProvider(parent), service_(service) { Init(service_->name(), service->api_service_name(), service_->icon(), ArtIsInSongMetadata | CanGiveSuggestions | CanShowConfig); set_safe_words(QStringList() << "sky.fm" << "skyfm" << "di.fm" << "difm" << "digitallyimported"); connect(service_, SIGNAL(StreamsChanged()), SLOT(MaybeRecreateItems())); // Load the channel list on startup only if it doesn't involve going to update // info from the server. if (!service_->IsChannelListStale()) RecreateItems(); }