void XMLElementSommet::update() { //On réaffecte l'ID : setAttribute(QString("id"),sommet->getNom()); //De même avec la forme : QDomElement ancienDomForme=firstChildElement("Forme"); QDomElement newDomForme=createElement(QString("Forme")); newDomForme.setNodeValue(sommet->getForme()); if(ancienDomForme.isNull()) domSommet->appendChild(newDomForme); else replaceChild(newDomForme, ancienDomForme); //Si c'est coloré, on s'en occupe : if(colore){ SommetColore* sommetColore=(SommetColore*) sommet; QDomElement ancienDomCouleur=firstChildElement("Couleur"); QDomElement newDomCouleur=createElement(QString("Couleur")); newDomForme.setNodeValue(QString(sommetColore->getCouleur())); if(ancienDomCouleur.isNull()) domSommet->appendChild(newDomCouleur); else replaceChild(newDomCouleur, ancienDomCouleur); } }
bool Prototype::readXml(const QString &i_fileName) { QFile file(i_fileName); if (!file.open(QIODevice::ReadOnly)) { return false; } QDomDocument document; if (!document.setContent(file.readAll())) { return false; } auto commonElement = document.documentElement().firstChildElement("Common"); auto backgroundFileName = commonElement.firstChildElement("Background").text(); backgroundImage = QImage(backgroundFileName); firstSlide = commonElement.firstChildElement("FirstSlide").text(); auto slidesElement = document.documentElement().firstChildElement("Slides"); if (slidesElement.isNull()) { return false; } slides.clear(); for (auto slideElement = slidesElement.firstChildElement("Slide"); !slideElement.isNull(); slideElement = slideElement.nextSiblingElement("Slide")) { Slide slide; if (!slide.readXml(slideElement)) { return false; } slides[slide.name] = slide; } return true; }
void RecEventsFetcher::handleLocationReceived () { auto reply = qobject_cast<QNetworkReply*> (sender ()); if (!reply) return; reply->deleteLater (); const auto& data = reply->readAll (); QDomDocument doc; if (!doc.setContent (data)) { qWarning () << Q_FUNC_INFO << "error parsing reply" << data; handleLocationError (); return; } auto geoElem = doc.documentElement (); const auto& lon = geoElem.firstChildElement ("Longitude").text (); const auto& lat = geoElem.firstChildElement ("Latitude").text (); qDebug () << Q_FUNC_INFO << "fetched data:" << lon << lat; QMap<QString, QString> params; params ["latitude"] = lat; params ["longitude"] = lon; RequestEvents (params); }
void RecentReleasesFetcher::handleReplyFinished () { auto reply = qobject_cast<QNetworkReply*> (sender ()); reply->deleteLater (); const auto& data = reply->readAll (); qDebug () << data; QDomDocument doc; if (!doc.setContent (data)) { qWarning () << Q_FUNC_INFO << "error parsing reply"; return; } const auto& docElem = doc.documentElement (); if (docElem.attribute ("status") != "ok") { qWarning () << Q_FUNC_INFO << "reply is not ok:" << docElem.attribute ("status"); return; } QList<Media::AlbumRelease> releases; static auto months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; const auto monthsBegin = months.begin (); const auto monthsEnd = months.end (); auto album = docElem.firstChildElement ("albums").firstChildElement ("album"); while (!album.isNull ()) { const auto& strs = album.attribute ("releasedate").split (' ', QString::SkipEmptyParts); const int day = strs.value (1).toInt (); const int month = std::distance (monthsBegin, std::find (monthsBegin, monthsEnd, strs.value (2))) + 1; const int year = strs.value (3).toInt (); const QUrl& thumb = GetImage (album, "large"); const QUrl& full = GetImage (album, "extralarge"); Media::AlbumRelease release = { album.firstChildElement ("name").text (), album.firstChildElement ("artist").firstChildElement ("name").text (), QDateTime (QDate (year, month, day)), thumb, full, QUrl (album.firstChildElement ("url").text ()) }; releases << release; album = album.nextSiblingElement ("album"); } emit gotRecentReleases (releases); }
void PendingDisco::handleReleaseLookupFinished () { auto reply = qobject_cast<QNetworkReply*> (sender ()); reply->deleteLater (); std::shared_ptr<void> decrementGuard (nullptr, [this] (void*) { DecrementPending (); }); const auto& data = reply->readAll (); QDomDocument doc; if (!doc.setContent (data)) { qWarning () << Q_FUNC_INFO << "unable to parse" << data; } const auto& releaseElem = doc.documentElement ().firstChildElement ("release"); const auto& id = releaseElem.attribute ("id"); auto pos = std::find_if (Releases_.begin (), Releases_.end (), [id] (decltype (Releases_.at (0)) release) { return release.ID_ == id; }); if (pos == Releases_.end ()) { qWarning () << Q_FUNC_INFO << "release" << id << "not found"; return; } auto& release = *pos; auto mediumElem = releaseElem.firstChildElement ("medium-list").firstChildElement ("medium"); while (!mediumElem.isNull ()) { auto trackElem = mediumElem.firstChildElement ("track-list").firstChildElement ("track"); QList<Media::ReleaseTrackInfo> tracks; while (!trackElem.isNull ()) { const int num = trackElem.firstChildElement ("number").text ().toInt (); const auto& recElem = trackElem.firstChildElement ("recording"); const auto& title = recElem.firstChildElement ("title").text (); const int length = recElem.firstChildElement ("length").text ().toInt () / 1000; tracks.push_back ({ num, title, length }); trackElem = trackElem.nextSiblingElement ("track"); } release.TrackInfos_ << tracks; mediumElem = mediumElem.nextSiblingElement ("medium"); } }
void PendingRecommendedArtists::handleReplyFinished () { auto reply = qobject_cast<QNetworkReply*> (sender ()); reply->deleteLater (); QDomDocument doc; if (!doc.setContent (reply->readAll ())) { qWarning () << Q_FUNC_INFO << "unable to parse reply"; emit error (); return; } auto artistElem = doc.documentElement () .firstChildElement ("recommendations") .firstChildElement ("artist"); auto elemGuard = [&artistElem] (void*) { artistElem = artistElem.nextSiblingElement ("artist"); }; while (!artistElem.isNull ()) { std::shared_ptr<void> guard (static_cast<void*> (0), elemGuard); const auto& name = artistElem.firstChildElement ("name").text (); if (name.isEmpty ()) continue; QStringList similarTo; auto similarElem = artistElem.firstChildElement ("context").firstChildElement ("artist"); while (!similarElem.isNull ()) { similarTo << similarElem.firstChildElement ("name").text (); similarElem = similarElem.nextSiblingElement ("artist"); } ++InfosWaiting_; QMap<QString, QString> params; params ["artist"] = name; AddLanguageParam (params); auto infoReply = Request ("artist.getInfo", NAM_, params); infoReply->setProperty ("SimilarTo", similarTo); connect (infoReply, SIGNAL (finished ()), this, SLOT (handleInfoReplyFinished ())); connect (infoReply, SIGNAL (error (QNetworkReply::NetworkError)), this, SLOT (handleInfoReplyError ())); } }
void HypedTracksFetcher::handleFinished () { auto reply = qobject_cast<QNetworkReply*> (sender ()); deleteLater (); const auto& data = reply->readAll (); QDomDocument doc; if (!doc.setContent (data)) { qWarning () << Q_FUNC_INFO << "error parsing reply" << data; return; } QList<Media::HypedTrackInfo> tracks; auto trackElem = doc .documentElement () .firstChildElement ("tracks") .firstChildElement ("track"); while (!trackElem.isNull ()) { auto getText = [&trackElem] (const QString& name) { return trackElem.firstChildElement (name).text (); }; const auto& artistElem = trackElem.firstChildElement ("artist"); tracks << Media::HypedTrackInfo { getText ("name"), getText ("url"), getText ("percentagechange").toInt (), getText ("playcount").toInt (), getText ("listeners").toInt (), getText ("duration").toInt (), GetImage (trackElem, "medium"), GetImage (trackElem, "extralarge"), artistElem.firstChildElement ("name").text (), artistElem.firstChildElement ("url").text () }; trackElem = trackElem.nextSiblingElement ("track"); } emit gotHypedTracks (tracks, Type_); }
QStringList Read (const QString& path) { QFile file (path); if (!file.open (QIODevice::ReadOnly)) { qWarning () << Q_FUNC_INFO << "unable to open" << path << file.errorString (); return QStringList (); } QDomDocument doc; if (!doc.setContent (file.readAll ())) { qWarning () << Q_FUNC_INFO << "unable to parse" << path; return QStringList (); } QStringList result; auto track = doc.documentElement () .firstChildElement ("trackList") .firstChildElement ("track"); while (!track.isNull ()) { const auto& loc = track.firstChildElement ("location").text (); if (!loc.isEmpty ()) result << loc; track = track.nextSiblingElement ("track"); } return result; }
void FinalPage::handleReplyFinished () { auto reply = qobject_cast<QNetworkReply*> (sender ()); reply->deleteLater (); QString text; QDomDocument doc; if (!doc.setContent (reply->readAll ())) { text = tr ("I'm very sorry to say that, but seems like " "we're unable to handle your report at the time :("); Ui_.Status_->setText (text); return; } auto root = doc.documentElement (); const auto& id = root.firstChildElement ("id").text (); text = tr ("Report has been sent successfully. Thanks for your time!"); if (!id.isEmpty ()) { text += "<br />"; text += (tr ("Your issue number is %1. You can view it here:") + " <a href='http://dev.leechcraft.org/issues/%1'>#%1</a>").arg (id); } Ui_.Status_->setText (text); }
void CurrenciesManager::gotRateReply () { auto reply = qobject_cast<QNetworkReply*> (sender ()); reply->deleteLater (); const auto& data = reply->readAll (); QDomDocument doc; if (!doc.setContent (data)) { qWarning () << Q_FUNC_INFO << "unable to parse" << data; return; } const auto& now = QDateTime::currentDateTime (); bool changed = false; auto rateElem = doc.documentElement () .firstChildElement ("results") .firstChildElement ("rate"); while (!rateElem.isNull ()) { std::shared_ptr<void> guard (nullptr, [&rateElem] (void*) { rateElem = rateElem.nextSiblingElement ("rate"); }); const auto& toValue = rateElem.attribute ("id").mid (3); if (toValue.size () != 3) { qWarning () << "incorrect `to` value" << toValue; continue; } const auto newRate = rateElem.firstChildElement ("Rate").text ().toDouble (); if (std::fabs (newRate - RatesFromUSD_ [toValue]) > std::numeric_limits<double>::epsilon ()) { RatesFromUSD_ [toValue] = newRate; changed = true; } Rate rate { 0, toValue, now, newRate }; Core::Instance ().GetStorage ()->AddRate (rate); } LastFetch_ = QDateTime::currentDateTime (); QSettings settings (QCoreApplication::organizationName (), QCoreApplication::applicationName () + "_Poleemery"); settings.beginGroup ("Currencies"); settings.setValue ("LastFetch", LastFetch_); if (changed) { emit currenciesUpdated (); for (auto i = RatesFromUSD_.constBegin (); i != RatesFromUSD_.constEnd (); ++i) settings.setValue (i.key (), *i); } settings.endGroup (); }
void LoaderXml::root() { auto doc = requireElement(xml,"document"); builder.beginDocument(); id(doc); document_ = builder.currentDocument(); /// \todo file format version document_->setImageSize(QSize( doc.attribute("width","32").toInt(), doc.attribute("height","32").toInt() )); metadata(doc.firstChildElement("metadata")); animations(doc.firstChildElement("animations")); formats(doc.firstChildElement("formats")); layers(doc); builder.endDocument(); }
void TaskList::findOrCreateElement() { auto root = m_dataSource.document().documentElement(); if (!root.isNull()) { m_element = root.firstChildElement(g_elementName); if (m_element.isNull()) { m_element = m_dataSource.document().createElement(g_elementName); root.appendChild(m_element); } } }
DescParser::DescParser () { QFile file { ":/azoth/mucommands/resources/data/descriptions.xml" }; if (!file.open (QIODevice::ReadOnly)) { qWarning () << Q_FUNC_INFO << "unable to open descriptions file" << file.errorString (); return; } QDomDocument doc; QString msg; int line = 0; int column = 0; if (!doc.setContent (&file, &msg, &line, &column)) { qWarning () << Q_FUNC_INFO << "cannot parse descriptions file" << msg << line << column; return; } auto cmdElem = doc.documentElement ().firstChildElement ("command"); while (!cmdElem.isNull ()) { const auto& name = cmdElem.attribute ("name"); const auto& descr = cmdElem.firstChildElement ("desc").text (); const auto& help = cmdElem.firstChildElement ("help").text (); const auto& descrTr = qApp->translate ("descriptions", descr.toUtf8 ().constData ()); Cmd2Desc_ [name] = Desc { descrTr, help }; cmdElem = cmdElem.nextSiblingElement ("command"); } }
QString FbScheme::type() const { if (isNull()) return QString(); QString result = attribute("type"); if (!result.isEmpty()) return result; FbScheme child = firstChildElement("xs:complexType").firstChildElement(); while (!child.isNull()) { QString tag = child.tagName(); if (tag == "xs:complexContent" || tag == "xs:simpleContent") { return child.firstChildElement("xs:extension").attribute("base"); } child = child.nextSiblingElement(); } return QString(); }
ConcreteSiteDesc::ConcreteSiteDesc (const QDomElement& elem) : Name_ (elem.attribute ("name")) , Charset_ (elem.attribute ("charset", "utf-8")) , URLTemplate_ (elem.attribute ("url")) { auto urlFormat = elem.firstChildElement ("urlFormat"); while (!urlFormat.isNull ()) { const auto& replace = urlFormat.attribute ("replace"); const auto& with = urlFormat.attribute ("with"); for (const auto c : replace) Replacements_ [c] = with; urlFormat = urlFormat.nextSiblingElement ("urlFormat"); } auto fillMatchers = [&elem] (const QString& name, MatcherBase::Mode mode) -> QList<MatcherBase_ptr> { QList<MatcherBase_ptr> result; auto extract = elem.firstChildElement (name); while (!extract.isNull ()) { auto item = extract.firstChildElement ("item"); while (!item.isNull ()) { result << MatcherBase::MakeMatcher (mode, item); item = item.nextSiblingElement ("item"); } extract = extract.nextSiblingElement (name); } result.removeAll (MatcherBase_ptr ()); return result; }; Matchers_ += fillMatchers ("extract", MatcherBase::Mode::Return); Matchers_ += fillMatchers ("exclude", MatcherBase::Mode::Exclude); auto invalidElem = elem.firstChildElement ("invalidIndicator"); while (!invalidElem.isNull ()) { InvalidIndicators_ << invalidElem.attribute ("value"); invalidElem = invalidElem.nextSiblingElement ("invalidIndicator"); } }
static JingleRtpReason elementToReason(const QDomElement &e) { if(e.tagName() != "reason") return JingleRtpReason(); QDomElement condElement = firstChildElement(e); if(condElement.isNull()) return JingleRtpReason(); int x = elementNameToCondition(condElement.tagName()); if(x == -1) return JingleRtpReason(); JingleRtpReason out; out.condition = (JingleRtpReason::Condition)x; QDomElement text = e.firstChildElement("text"); if(!text.isNull()) out.text = tagContent(text); return out; }
FbScheme FbScheme::item(const QString &name) const { FbScheme child = firstChildElement(); while (!child.isNull()) { switch (toKeyword(child.tagName())) { case XsElement: { if (child.attribute("name") == name) return child; } break; case XsChoice: case XsComplexType: case XsSequence: { FbScheme result = child.item(name); if (!result.isNull()) return result; } break; default: ; } child = child.nextSiblingElement(); } return FbScheme(); }
void Plugin::handleReply () { auto reply = qobject_cast<QNetworkReply*> (sender ()); reply->deleteLater (); if (!Reply2Model_.contains (reply)) { qWarning () << Q_FUNC_INFO << "stall reply detected"; return; } const auto& data = reply->readAll (); auto model = Reply2Model_.take (reply); Model2Reply_.remove (model); QDomDocument doc; if (!doc.setContent (data)) { qWarning () << Q_FUNC_INFO << "unable to read reply"; return; } auto iURLCompleter = qobject_cast<IURLCompletionModel*> (model); auto suggestion = doc.documentElement ().firstChildElement ("CompleteSuggestion"); auto pos = 5; while (!suggestion.isNull ()) { const auto& str = suggestion.firstChildElement ("suggestion").attribute ("data"); iURLCompleter->AddItem (str, str, pos++); suggestion = suggestion.nextSiblingElement ("CompleteSuggestion"); } }
PsiPlusImportPage::PsiPlusImportPage (QWidget *parent) : Common::IMImportPage (parent) { auto tfd = [] (const QDomElement& account, const QString& field) { return account.firstChildElement (field).text (); }; auto adapter = Common::XMLIMAccount::ConfigAdapter { AccountsModel_, QStringList (".config") << "Psi+" << "profiles", "accounts.xml", [] (const QDomElement&) { return "xmpp"; }, [=] (const QDomElement& acc) { return tfd (acc, "name"); }, [=] (const QDomElement& acc) { return tfd (acc, "enabled") == "true"; }, [=] (const QDomElement& acc) { return tfd (acc, "jid"); }, [=] (const QDomElement& acc, QVariantMap& accountData) { accountData ["Port"] = tfd (acc, "port").toInt (); accountData ["Host"] = tfd (acc, "use-host") == "true" ? tfd (acc, "host") : QString (); QStringList jids; auto rosterItem = acc.firstChildElement ("roster-cache").firstChildElement (); while (!rosterItem.isNull ()) { const QString& jid = rosterItem.firstChildElement ("jid").text (); if (!jid.isEmpty ()) jids << jid; rosterItem = rosterItem.nextSiblingElement (); } accountData ["Contacts"] = jids; } }; XIA_.reset (new Common::XMLIMAccount (adapter)); }
void PendingDisco::handleLookupFinished () { auto reply = qobject_cast<QNetworkReply*> (sender ()); reply->deleteLater (); const auto& data = reply->readAll (); QDomDocument doc; if (!doc.setContent (data)) { qWarning () << Q_FUNC_INFO << "unable to parse" << data; emit error (tr ("Unable to parse MusicBrainz reply.")); deleteLater (); } QMap<QString, QMap<QString, Media::ReleaseInfo>> infos; auto releaseElem = doc .documentElement () .firstChildElement ("artist") .firstChildElement ("release-list") .firstChildElement ("release"); while (!releaseElem.isNull ()) { std::shared_ptr<void> guard (nullptr, [&releaseElem] (void*) { releaseElem = releaseElem.nextSiblingElement ("release"); }); auto elemText = [&releaseElem] (const QString& sub) { return releaseElem.firstChildElement (sub).text (); }; if (elemText ("status") != "Official") continue; const auto& dateStr = elemText ("date"); const int dashPos = dateStr.indexOf ('-'); const int date = (dashPos > 0 ? dateStr.left (dashPos) : dateStr).toInt (); if (date < 1000) continue; const auto& title = elemText ("title"); if (!ReleaseName_.isEmpty () && title.toLower () != ReleaseName_) continue; infos [title] [elemText ("country")] = { releaseElem.attribute ("id"), title, date, Media::ReleaseInfo::Type::Standard, QList<QList<Media::ReleaseTrackInfo>> () }; } for (const auto& key : infos.keys ()) { const auto& countries = infos [key]; const auto& release = countries.contains ("US") ? countries ["US"] : countries.values ().first (); Releases_ << release; ++PendingReleases_; const auto urlStr = "http://musicbrainz.org/ws/2/release/" + release.ID_ + "?inc=recordings"; Queue_->Schedule ([this, urlStr] () -> void { auto reply = NAM_->get (QNetworkRequest (QUrl (urlStr))); connect (reply, SIGNAL (finished ()), this, SLOT (handleReleaseLookupFinished ())); connect (reply, SIGNAL (error (QNetworkReply::NetworkError)), this, SLOT (handleReleaseLookupError ())); }, this); } std::sort (Releases_.begin (), Releases_.end (), [] (decltype (Releases_.at (0)) left, decltype (Releases_.at (0)) right) { return left.Year_ < right.Year_; }); }
void VkAccount::handleGotPhotos () { auto reply = qobject_cast<QNetworkReply*> (sender ()); reply->deleteLater (); const auto& data = reply->readAll (); QDomDocument doc; if (!doc.setContent (data)) { qWarning () << Q_FUNC_INFO << "cannot parse reply" << data; return; } bool finishReached = false; auto photoElem = doc .documentElement () .firstChildElement ("photo"); while (!photoElem.isNull ()) { auto mkItem = [&photoElem] () -> QStandardItem* { const auto& idText = photoElem.firstChildElement ("pid").text (); auto item = new QStandardItem (idText); item->setData (ItemType::Image, CollectionRole::Type); item->setData (idText, CollectionRole::ID); item->setData (QString (), CollectionRole::Name); const auto& sizesElem = photoElem.firstChildElement ("sizes"); auto getType = [&sizesElem] (const QString& type) -> QPair<QUrl, QSize> { auto sizeElem = sizesElem.firstChildElement ("size"); while (!sizeElem.isNull ()) { if (sizeElem.firstChildElement ("type").text () != type) { sizeElem = sizeElem.nextSiblingElement ("size"); continue; } const auto& src = sizeElem.firstChildElement ("src").text (); const auto width = sizeElem.firstChildElement ("width").text ().toInt (); const auto height = sizeElem.firstChildElement ("height").text ().toInt (); return { src, { width, height } }; } return {}; }; const auto& small = getType ("m"); const auto& mid = getType ("x"); auto orig = getType ("w"); QStringList sizeCandidates { "z", "y", "x", "r" }; while (orig.second.width () <= 0) { if (sizeCandidates.isEmpty ()) return nullptr; orig = getType (sizeCandidates.takeFirst ()); } item->setData (small.first, CollectionRole::SmallThumb); item->setData (small.second, CollectionRole::SmallThumbSize); item->setData (mid.first, CollectionRole::MediumThumb); item->setData (mid.second, CollectionRole::MediumThumbSize); item->setData (orig.first, CollectionRole::Original); item->setData (orig.second, CollectionRole::OriginalSize); return item; }; auto allItem = mkItem (); if (!allItem) { finishReached = true; break; } AllPhotosItem_->appendRow (allItem); const auto aid = photoElem.firstChildElement ("aid").text ().toInt (); if (Albums_.contains (aid)) Albums_ [aid]->appendRow (mkItem ()); photoElem = photoElem.nextSiblingElement ("photo"); } if (finishReached) return; const auto count = doc.documentElement ().firstChildElement ("count").text ().toInt (); if (count == AllPhotosItem_->rowCount ()) return; const auto offset = AllPhotosItem_->rowCount (); CallQueue_.append ([this, offset] (const QString& authKey) -> void { QUrl photosUrl ("https://api.vk.com/method/photos.getAll.xml"); photosUrl.addQueryItem ("access_token", authKey); photosUrl.addQueryItem ("count", "100"); photosUrl.addQueryItem ("offset", QString::number (offset)); photosUrl.addQueryItem ("photo_sizes", "1"); RequestQueue_->Schedule ([this, photosUrl] { connect (Proxy_->GetNetworkAccessManager ()->get (QNetworkRequest (photosUrl)), SIGNAL (finished ()), this, SLOT (handleGotPhotos ())); }, this); }); AuthMgr_->GetAuthKey (); }
void RecEventsFetcher::handleFinished () { auto reply = qobject_cast<QNetworkReply*> (sender ()); if (!reply) return; reply->deleteLater (); deleteLater (); const auto& data = reply->readAll (); QDomDocument doc; if (!doc.setContent (data)) { qWarning () << Q_FUNC_INFO << "error parsing reply"; return; } Media::EventInfos_t result; auto eventElem = doc .documentElement () .firstChildElement ("events") .firstChildElement ("event"); while (!eventElem.isNull ()) { auto artistsElem = eventElem.firstChildElement ("artists"); auto venueElem = eventElem.firstChildElement ("venue"); auto locationElem = venueElem.firstChildElement ("location"); auto pointElem = locationElem.firstChildElement ("point"); Media::EventInfo info = { eventElem.firstChildElement ("id").text ().toInt (), eventElem.firstChildElement ("title").text (), QString (), QLocale ("en_US").toDateTime (eventElem.firstChildElement ("startDate").text (), "ddd, dd MMM yyyy hh:mm:ss"), eventElem.firstChildElement ("url").text (), GetImage (eventElem, "medium"), GetImage (eventElem, "extralarge"), GetElemsList (artistsElem, "artist"), artistsElem.firstChildElement ("headliner").text (), GetElemsList (eventElem.firstChildElement ("tags"), "tag"), eventElem.firstChildElement ("attendance").text ().toInt (), venueElem.firstChildElement ("name").text (), pointElem.firstChildElement ("lat").text ().toDouble (), pointElem.firstChildElement ("long").text ().toDouble (), locationElem.firstChildElement ("city").text (), locationElem.firstChildElement ("street").text (), true, Type_ == Type::Attending ? Media::EventAttendType::Surely : Media::EventAttendType::None }; result << info; eventElem = eventElem.nextSiblingElement ("event"); } emit gotRecommendedEvents (result); }
void HypedArtistsFetcher::handleFinished () { auto reply = qobject_cast<QNetworkReply*> (sender ()); reply->deleteLater (); const auto& data = reply->readAll (); QDomDocument doc; if (!doc.setContent (data)) { qWarning () << Q_FUNC_INFO << "error parsing reply" << data; return; } auto artistElem = doc .documentElement () .firstChildElement ("artists") .firstChildElement ("artist"); while (!artistElem.isNull ()) { auto getText = [&artistElem] (const QString& name) { return artistElem.firstChildElement (name).text (); }; const auto& name = getText ("name"); Infos_ << Media::HypedArtistInfo { Media::ArtistInfo { name, QString (), QString (), GetImage (artistElem, "medium"), GetImage (artistElem, "extralarge"), getText ("url"), Media::TagInfos_t () }, getText ("percentagechange").toInt (), getText ("playcount").toInt (), getText ("listeners").toInt () }; auto pendingBio = new PendingArtistBio (name, NAM_, this); connect (pendingBio, SIGNAL (ready ()), this, SLOT (pendingBioReady ())); connect (pendingBio, SIGNAL (error ()), this, SLOT (pendingBioError ())); artistElem = artistElem.nextSiblingElement ("artist"); } InfoCount_ = Infos_.size (); if (!InfoCount_) deleteLater (); }