本文整理汇总了C++中QNetworkReply::property方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkReply::property方法的具体用法?C++ QNetworkReply::property怎么用?C++ QNetworkReply::property使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkReply
的用法示例。
在下文中一共展示了QNetworkReply::property方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: backdropFinished
/**
* @brief Called when backdrops are loaded
*/
void VideoBuster::backdropFinished()
{
QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
Movie *movie = reply->property("storage").value<Storage*>()->movie();
QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
reply->deleteLater();
if (!movie)
return;
if (reply->error() == QNetworkReply::NoError ) {
QString msg = reply->readAll();
QRegExp rx("href=\"https://gfx.videobuster.de/archive/resized/([^\"]*)\"(.*)([^<]*)<img (.*) src=\"https://gfx.videobuster.de/archive/resized/c110/([^\"]*)\"");
rx.setMinimal(true);
int pos = 0;
while ((pos = rx.indexIn(msg, pos)) != -1) {
pos += rx.matchedLength();
if (rx.cap(2).contains("titledtl_cover_pictures")) {
continue;
}
Poster p;
p.thumbUrl = QUrl(QString("https://gfx.videobuster.de/archive/resized/w700/%1").arg(rx.cap(5)));
p.originalUrl = QUrl(QString("https://gfx.videobuster.de/archive/resized/%1").arg(rx.cap(1)));
movie->addBackdrop(p);
}
} else {
qWarning() << "Network Error" << reply->errorString();
}
movie->controller()->scraperLoadDone();
}
示例2: parseFolderDo
void QgsArcGisRestCatalogProvider::parseFolderDo()
{
QNetworkReply* reply = qobject_cast<QNetworkReply*>( QObject::sender() );
reply->deleteLater();
QString path = reply->property( "path" ).toString();
QStringList catTitles = reply->property( "catTitles" ).toStringList();
if ( reply->error() == QNetworkReply::NoError )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QJson::Parser parser;
QVariantMap folderData = parser.parse( reply->readAll() ).toMap();
#else
QVariantMap folderData = QJsonDocument::fromJson( reply->readAll() ).object().toVariantMap();
#endif
QString catName = QFileInfo( path ).baseName();
if ( !catName.isEmpty() )
{
catTitles.append( catName );
}
foreach ( const QVariant& folderName, folderData["folders"].toList() )
{
parseFolder( path + "/" + folderName.toString(), catTitles );
}
foreach ( const QVariant& serviceData, folderData["services"].toList() )
{
parseService( QString( "/" ) + serviceData.toMap()["name"].toString(), catTitles );
}
}
示例3: onLoadFinished
void IMDB::onLoadFinished()
{
QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
reply->deleteLater();
Movie *movie = reply->property("storage").value<Storage*>()->movie();
QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
if (!movie)
return;
if (reply->error() == QNetworkReply::NoError ) {
QString msg = QString::fromUtf8(reply->readAll());
parseAndAssignInfos(msg, movie, infos);
QString posterUrl = parsePosters(msg);
if (infos.contains(MovieScraperInfos::Poster) && !posterUrl.isEmpty()) {
QNetworkReply *reply = qnam()->get(QNetworkRequest(posterUrl));
reply->setProperty("storage", Storage::toVariant(reply, movie));
reply->setProperty("infosToLoad", Storage::toVariant(reply, infos));
connect(reply, SIGNAL(finished()), this, SLOT(onPosterLoadFinished()));
} else {
movie->controller()->scraperLoadDone(this);
}
} else {
qWarning() << "Network Error (load)" << reply->errorString();
}
}
示例4: onActorsFinished
/**
* @brief Called when the tv show actors are downloaded
* Starts download of banners
* @see TheTvDb::parseAndAssignActors
* @see TheTvDb::onBannersFinished
*/
void TheTvDb::onActorsFinished()
{
QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
reply->deleteLater();
TvShow *show = reply->property("storage").value<Storage*>()->show();
TvShowUpdateType updateType = static_cast<TvShowUpdateType>(reply->property("updateType").toInt());
QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
if (!show)
return;
if (reply->error() == QNetworkReply::NoError ) {
QString msg = QString::fromUtf8(reply->readAll());
if (show->infosToLoad().contains(TvShowScraperInfos::Actors) &&
(updateType == UpdateShow || updateType == UpdateShowAndAllEpisodes || updateType == UpdateShowAndNewEpisodes))
parseAndAssignActors(msg, show);
} else {
qWarning() << "Network Error" << reply->errorString();
}
QString mirror = m_xmlMirrors.at(qrand()%m_xmlMirrors.count());
QUrl url(QString("%1/api/%2/series/%3/banners.xml").arg(mirror).arg(m_apiKey).arg(show->tvdbId()));
reply = qnam()->get(QNetworkRequest(url));
reply->setProperty("storage", Storage::toVariant(reply, show));
reply->setProperty("updateType", updateType);
reply->setProperty("infosToLoad", Storage::toVariant(reply, infos));
connect(reply, SIGNAL(finished()), this, SLOT(onBannersFinished()));
}
示例5: onEpisodeLoadFinished
/**
* @brief Called when the episode infos are downloaded
* @see TheTvDb::parseAndAssignSingleEpisodeInfos
*/
void TheTvDb::onEpisodeLoadFinished()
{
QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
reply->deleteLater();
TvShowEpisode *episode = reply->property("storage").value<Storage*>()->episode();
if (!episode)
return;
if (reply->error() == QNetworkReply::NoError ) {
QString msg = QString::fromUtf8(reply->readAll());
QDomDocument domDoc;
domDoc.setContent(msg);
for (int i=0, n=domDoc.elementsByTagName("Episode").count() ; i<n ; ++i) {
QDomElement elem = domDoc.elementsByTagName("Episode").at(i).toElement();
if (!elem.elementsByTagName("SeasonNumber").isEmpty() && !elem.elementsByTagName("EpisodeNumber").isEmpty()) {
int seasonNumber = elem.elementsByTagName("SeasonNumber").at(0).toElement().text().toInt();
int episodeNumber = elem.elementsByTagName("EpisodeNumber").at(0).toElement().text().toInt();
if (episode->season() == seasonNumber && episode->episode() == episodeNumber) {
episode->clear(episode->infosToLoad());
parseAndAssignSingleEpisodeInfos(elem, episode, infos);
}
}
}
} else {
qWarning() << "Network Error" << reply->errorString();
}
episode->scraperLoadDone();
}
示例6: info
void
MusixMatchPlugin::trackSearchSlot()
{
tDebug() << Q_FUNC_INFO;
QNetworkReply* oldReply = qobject_cast<QNetworkReply*>( sender() );
if ( !oldReply )
return; //timeout will handle it
oldReply->deleteLater();
QDomDocument doc;
doc.setContent(oldReply->readAll());
qDebug() << Q_FUNC_INFO << doc.toString();
QDomNodeList domNodeList = doc.elementsByTagName("track_id");
if ( domNodeList.isEmpty() )
{
emit info( oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
return;
}
QString track_id = domNodeList.at(0).toElement().text();
QString requestString( "http://api.musixmatch.com/ws/1.1/track.lyrics.get?track_id=%1&format=xml&apikey=%2" );
QUrl url( requestString );
TomahawkUtils::urlAddQueryItem( url, "apikey", m_apiKey );
TomahawkUtils::urlAddQueryItem( url, "track_id", track_id );
QNetworkReply* newReply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( trackLyricsSlot() ) );
}
示例7: info
void
MusicBrainzPlugin::albumSearchSlot()
{
QNetworkReply* oldReply = qobject_cast<QNetworkReply*>( sender() );
if ( !oldReply )
return; //timeout will handle it
QDomDocument doc;
doc.setContent( oldReply->readAll() );
QDomNodeList domNodeList = doc.elementsByTagName( "artist" );
if ( domNodeList.isEmpty() )
{
emit info( oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
return;
}
QString artist_id = domNodeList.at( 0 ).toElement().attribute( "id" );
QString requestString( "http://musicbrainz.org/ws/2/release?status=official&type=album|ep" );
QUrl url( requestString );
url.addQueryItem( "artist", artist_id );
QNetworkReply* newReply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( tracksSearchSlot() ) );
}
示例8: backdropFinished
/**
* @brief Called when backdrop scraping has finished
* Starts the next backdrop download or tells the movie that scraping is done
*/
void Cinefacts::backdropFinished()
{
QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
reply->deleteLater();
Movie *movie = reply->property("storage").value<Storage*>()->movie();
QStringList backdrops = reply->property("backdrops").toStringList();
QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
if (!movie)
return;
if (reply->error() == QNetworkReply::NoError) {
QString msg = QString::fromUtf8(reply->readAll());
QRegExp rx("<a href=\"([^\"]*)\" target=\"_blank\">Bild in Originalgr..e</a>");
rx.setMinimal(true);
if (rx.indexIn(msg) != -1) {
Poster p;
p.thumbUrl = rx.cap(1);
p.originalUrl = rx.cap(1);
movie->addBackdrop(p);
}
if (!backdrops.isEmpty()) {
reply = qnam()->get(QNetworkRequest(QUrl(QString("http://www.cinefacts.de%1").arg(backdrops.takeFirst()))));
reply->setProperty("storage", Storage::toVariant(reply, movie));
reply->setProperty("backdrops", backdrops);
reply->setProperty("infosToLoad", Storage::toVariant(reply, infos));
connect(reply, SIGNAL(finished()), this, SLOT(backdropFinished()));
return;
}
}
movie->controller()->scraperLoadDone(this);
}
示例9: onArtistRelsFinished
void UniversalMusicScraper::onArtistRelsFinished()
{
QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());
Artist *artist = reply->property("storage").value<Storage*>()->artist();
QList<int> infos = reply->property("infosToLoad").value<Storage*>()->infosToLoad();
reply->deleteLater();
if (!artist)
return;
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 302 ||
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 301) {
qDebug() << "Got redirect" << reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
reply = qnam()->get(QNetworkRequest(reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl()));
reply->setProperty("storage", Storage::toVariant(reply, artist));
reply->setProperty("infosToLoad", Storage::toVariant(reply, infos));
connect(reply, SIGNAL(finished()), this, SLOT(onArtistRelsFinished()));
return;
}
QString discogsUrl;
if (reply->error() == QNetworkReply::NoError) {
QString msg = QString::fromUtf8(reply->readAll());
QDomDocument domDoc;
domDoc.setContent(msg);
for (int i=0, n=domDoc.elementsByTagName("relation").count() ; i<n ; ++i) {
QDomElement elem = domDoc.elementsByTagName("relation").at(i).toElement();
if (elem.attribute("type") == "allmusic" && elem.elementsByTagName("target").count() > 0) {
QString url = elem.elementsByTagName("target").at(0).toElement().text();
QRegExp rx("allmusic\\.com/artist/(.*)$");
if (rx.indexIn(url) != -1)
artist->setAllMusicId(rx.cap(1));
}
if (elem.attribute("type") == "discogs" && elem.elementsByTagName("target").count() > 0)
discogsUrl = elem.elementsByTagName("target").at(0).toElement().text();
}
}
if (!m_artistDownloads.contains(artist))
m_artistDownloads.insert(artist, QList<DownloadElement>());
m_artistDownloads[artist].clear();
appendDownloadElement(artist, "theaudiodb", "tadb_data", QUrl(QString("http://www.theaudiodb.com/api/v1/json/%1/artist-mb.php?i=%2").arg(m_tadbApiKey).arg(artist->mbId())));
appendDownloadElement(artist, "theaudiodb", "tadb_discography", QUrl(QString("http://www.theaudiodb.com/api/v1/json/%1/discography-mb.php?s=%2").arg(m_tadbApiKey).arg(artist->mbId())));
if (!artist->allMusicId().isEmpty()) {
appendDownloadElement(artist, "allmusic", "am_data", QUrl(QString("http://www.allmusic.com/artist/%1").arg(artist->allMusicId())));
appendDownloadElement(artist, "allmusic", "am_biography", QUrl(QString("http://www.allmusic.com/artist/%1/biography").arg(artist->allMusicId())));
}
if (!discogsUrl.isEmpty())
appendDownloadElement(artist, "discogs", "discogs_data", QUrl(discogsUrl + "?type=Releases&subtype=Albums"));
foreach (DownloadElement elem, m_artistDownloads[artist]) {
QNetworkRequest request(elem.url);
request.setRawHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10; rv:33.0) Gecko/20100101 Firefox/33.0");
QNetworkReply *reply = qnam()->get(request);
new NetworkReplyWatcher(this, reply);
reply->setProperty("storage", Storage::toVariant(reply, artist));
reply->setProperty("infosToLoad", Storage::toVariant(reply, infos));
connect(reply, SIGNAL(finished()), this, SLOT(onArtistLoadFinished()));
}
示例10: linkClickedFinished
void SidebarPrivate::linkClickedFinished()
{
QNetworkReply * reply = static_cast< QNetworkReply * >(sender());
QString target = reply->property("__target").toString();
QVariant redirectsVariant = reply->property("__redirects");
int redirects = redirectsVariant.isNull() ? 20 : redirectsVariant.toInt();
// Redirect?
QUrl redirectedUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
if (redirectedUrl.isValid())
{
if (redirectedUrl.isRelative())
{
QUrl oldUrl = reply->url();
redirectedUrl.setScheme(oldUrl.scheme());
redirectedUrl.setAuthority(oldUrl.authority());
}
if (redirects > 0)
{
QNetworkRequest request = reply->request();
request.setUrl(redirectedUrl);
QNetworkReply * reply = networkAccessManager()->get(request);
reply->setProperty("__target", target);
connect(reply, SIGNAL(finished()), this, SLOT(linkClickedFinished()));
}
else
{
// TOO MANY REDIRECTS
}
reply->deleteLater();
return;
}
// Check headers... if PDF then launch a new window, otherwise give it to the OS
QString contentType(reply->header(QNetworkRequest::ContentTypeHeader).toString());
if (contentType.contains("application/pdf")) {
emit urlRequested(reply->request().url(), "tab");
} else {
QUrl href(reply->request().url());
if (href.isValid()) {
if (href.scheme() == "http" || href.scheme() == "https") {
if (target == "sidebar") {
webView->setUrl(href);
slideLayout->push("web");
return;
}
}
QDesktopServices::openUrl(href);
}
// FIXME error
}
reply->deleteLater();
}
示例11: info
void
MusicBrainzPlugin::gotReleaseGroupsSlot()
{
QNetworkReply* oldReply = qobject_cast<QNetworkReply*>( sender() );
if ( !oldReply )
return; //timeout will handle it
QDomDocument doc;
doc.setContent( oldReply->readAll() );
QDomNodeList releaseGroupsNL = doc.elementsByTagName( "release-group" );
if ( releaseGroupsNL.isEmpty() )
{
emit info( oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
tDebug() << Q_FUNC_INFO << doc.toString();
return;
}
Tomahawk::InfoSystem::InfoRequestData requestData = oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
switch ( requestData.type )
{
case InfoArtistReleases:
{
QString popularId = releaseGroupsNL.at(0).firstChildElement( "artist-credit" ).firstChildElement( "name-credit" ).firstChildElement( "artist" ).attribute( "id" );
QStringList albums;
for ( int i = 0; i < releaseGroupsNL.count(); i++ )
{
QString groupTitle = releaseGroupsNL.at(i).firstChildElement("title").text();
QString a = releaseGroupsNL.at(i).firstChildElement( "artist-credit" ).firstChildElement( "name-credit" ).firstChildElement( "artist" ).firstChildElement( "name" ).text();
QString id = releaseGroupsNL.at(i).firstChildElement( "artist-credit" ).firstChildElement( "name-credit" ).firstChildElement( "artist" ).attribute( "id" );
if ( !albums.contains( groupTitle ) && id == popularId && a.normalized( QString::NormalizationForm_KC ) == hash["artist"].normalized( QString::NormalizationForm_KC ) )
{
albums << groupTitle;
tDebug() << Q_FUNC_INFO << groupTitle;
}
}
QVariantMap returnedData;
returnedData["albums"] = albums;
emit info( requestData, returnedData );
Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>();
Tomahawk::InfoSystem::InfoStringHash criteria;
criteria["artist"] = origData["artist"];
emit updateCache( criteria, 0, requestData.type, returnedData );
break;
}
default:
{
Q_ASSERT( false );
break;
}
}
}
示例12: tokenReady
void ImgurUploader::tokenReady()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
if (!reply)
return;
const QVariantMap data = JSON::parse(reply->readAll()).toMap();
if (reply->error() == QNetworkReply::NoError && !m_queue.isEmpty()) {
QVariantMap map;
QVariantList a;
a.append(m_clientId);
a.append(m_clientSecret);
a.append(data.value(LS("refresh_token")));
a.append(data.value(LS("access_token")));
map.insert("a", a);
while (!m_queue.isEmpty())
upload(m_net, m_queue.dequeue(), map);
}
QVariantMap map;
map.insert(LS("type"), LS("token"));
map.insert(LS("reply"), data);
emit finished(reply->property("id").toByteArray(), LS("imgur"), map);
reply->deleteLater();
}
示例13: retrieveCallerInfoFinished
void WebSocketManager::retrieveCallerInfoFinished()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
QByteArray data = reply->readAll();
QString callerNumber = reply->property("caller_number").toString();
reply->deleteLater();
QJsonParseError error;
QJsonDocument document = QJsonDocument::fromJson(data, &error);
if (error.error != QJsonParseError::NoError)
return;
QString contactPerson = document.object().value("contact_person").toString();
QString loginName = document.object().value("login_name").toString();
QString callingNumber = document.object().value("calling_number").toString();
QString companyName = document.object().value("company_name").toString();
double balance = document.object().value("cur_balance").toDouble();
ContactInfo *ci = new ContactInfo();
ci->setContactPerson(contactPerson);
ci->setLogin(loginName);
ci->setCallingNumber(callingNumber);
ci->setCompanyName(companyName);
ci->setBalance(balance);
m_contactsHash.insert(callerNumber, ci);
emit channelCreated(ci);
}
示例14: packageFetched
void AppDownloader::packageFetched()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
reply->deleteLater();
QString file = reply->property("file").toString();
QFile f(m_storagePath + file);
if (!f.open(QFile::WriteOnly | QFile::Truncate)) {
qWarning() << "Error opening file for writing";
return;
}
f.write(reply->readAll());
f.flush();
f.close();
QString appid = file.split("/").first();
if (!ZipHelper::unpackArchive(m_storagePath+file, m_storagePath + appid)) {
qWarning() << "Error unpacking App zip file";
return;
}
emit downloadFinished(appid);
}
示例15: errorHandler
void TwitterDataTypeSyncAdaptor::errorHandler(QNetworkReply::NetworkError err)
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
QByteArray replyData = reply->readAll();
int accountId = reply->property("accountId").toInt();
SOCIALD_LOG_ERROR(SocialNetworkSyncAdaptor::dataTypeName(m_dataType) <<
"request with account" << accountId <<
"experienced error:" << err <<
"HTTP:" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
// set "isError" on the reply so that adapters know to ignore the result in the finished() handler
reply->setProperty("isError", QVariant::fromValue<bool>(true));
// Note: not all errors are "unrecoverable" errors, so we don't change the status here.
bool ok = false;
QJsonObject parsed = parseJsonObjectReplyData(replyData, &ok);
if (ok && parsed.contains(QLatin1String("errors"))) {
QJsonArray dataList = parsed.value(QLatin1String("errors")).toArray();
// API v1.1 returns only one element in the array, but looks like these
// are constantly updated: https://dev.twitter.com/docs/error-codes-responses
foreach (QJsonValue data, dataList) {
QJsonObject dataMap = data.toObject();
if (dataMap.value("code").toDouble() == 32 || dataMap.value("code").toDouble() == 89) {
Accounts::Account *account = Accounts::Account::fromId(m_accountManager, accountId, this);
if (account) {
setCredentialsNeedUpdate(account);
}
}
}