本文整理汇总了C++中KUrl::addQueryItem方法的典型用法代码示例。如果您正苦于以下问题:C++ KUrl::addQueryItem方法的具体用法?C++ KUrl::addQueryItem怎么用?C++ KUrl::addQueryItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KUrl
的用法示例。
在下文中一共展示了KUrl::addQueryItem方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void
CoverFetchInfoPayload::prepareUrls()
{
KUrl url;
CoverFetch::Metadata metadata;
switch( m_src )
{
default:
case CoverFetch::LastFm:
url.setScheme( "http" );
url.setHost( "ws.audioscrobbler.com" );
url.setPath( "/2.0/" );
url.addQueryItem( "api_key", Amarok::lastfmApiKey() );
url.addQueryItem( "album", sanitizeQuery( album()->name() ) );
if( album()->hasAlbumArtist() )
{
url.addQueryItem( "artist", sanitizeQuery( album()->albumArtist()->name() ) );
}
url.addQueryItem( "method", method() );
metadata[ "source" ] = "Last.fm";
metadata[ "method" ] = method();
break;
}
if( url.isValid() )
m_urls.insert( url, metadata );
}
示例2: findUrlForAccount
static KUrl findUrlForAccount( const KMail::ImapAccountBase * a ) {
assert( a );
const SieveConfig sieve = a->sieveConfig();
if ( !sieve.managesieveSupported() )
return KUrl();
if ( sieve.reuseConfig() ) {
// assemble Sieve url from the settings of the account:
KUrl u;
u.setProtocol( "sieve" );
u.setHost( a->host() );
u.setUser( a->login() );
u.setPass( a->passwd() );
u.setPort( sieve.port() );
u.addQueryItem( "x-mech", a->auth() == "*" ? "PLAIN" : a->auth() ); //translate IMAP LOGIN to PLAIN
if ( !a->useSSL() && !a->useTLS() )
u.addQueryItem( "x-allow-unencrypted", "true" );
u.setFileName( sieve.vacationFileName() );
return u;
} else {
KUrl u = sieve.alternateURL();
if ( u.protocol().toLower() == "sieve" && !a->useSSL() && !a->useTLS() && u.queryItem("x-allow-unencrypted").isEmpty() )
u.addQueryItem( "x-allow-unencrypted", "true" );
u.setFileName( sieve.vacationFileName() );
return u;
}
}
示例3: requestFriend
PersonListJob* Provider::requestFriend(const QString& id, int page, int pageSize)
{
KUrl url = createUrl( "friend/data/" + id );
url.addQueryItem("page", QString::number(page));
url.addQueryItem("pagesize", QString::number(pageSize));
kDebug() << "URL:" << url;
return doRequestPersonList( url );
}
示例4: xml
void
CoverFetchInfoPayload::prepareDiscogsUrls( const QByteArray &data )
{
QXmlStreamReader xml( QString::fromUtf8(data) );
while( !xml.atEnd() && !xml.hasError() )
{
xml.readNext();
if( xml.isStartElement() && xml.name() == "searchresults" )
{
while( !xml.atEnd() && !xml.hasError() )
{
xml.readNext();
const QStringRef &n = xml.name();
if( xml.isEndElement() && n == "searchresults" )
break;
if( !xml.isStartElement() )
continue;
if( n == "result" )
{
while( !xml.atEnd() && !xml.hasError() )
{
xml.readNext();
if( xml.isEndElement() && n == "result" )
break;
if( !xml.isStartElement() )
continue;
if( xml.name() == "uri" )
{
KUrl releaseUrl( xml.readElementText() );
QString releaseStr = releaseUrl.url( KUrl::RemoveTrailingSlash );
QString releaseId = releaseStr.split( '/' ).last();
KUrl url;
url.setScheme( "http" );
url.setHost( "www.discogs.com" );
url.setPath( "/release/" + releaseId );
url.addQueryItem( "api_key", Amarok::discogsApiKey() );
url.addQueryItem( "f", "xml" );
CoverFetch::Metadata metadata;
metadata[ "source" ] = "Discogs";
if( url.isValid() )
m_urls.insert( url, metadata );
}
else
xml.skipCurrentElement();
}
}
else
xml.skipCurrentElement();
}
}
}
}
示例5: requestPersonSearchByLocation
PersonListJob* Provider::requestPersonSearchByLocation(qreal latitude, qreal longitude, qreal distance, int page, int pageSize)
{
KUrl url = createUrl( "person/data" );
url.addQueryItem("latitude", QString::number(latitude));
url.addQueryItem("longitude", QString::number(longitude));
url.addQueryItem("distance", QString::number(distance));
url.addQueryItem("page", QString::number(page));
url.addQueryItem("pagesize", QString::number(pageSize));
qDebug() << "Location-based search:" << latitude << longitude << distance;
qDebug() << "URL:" << url;
return doRequestPersonList( url );
}
示例6: SLOT
void
ArtistWidget::fetchTopTrack()
{
// we genere the url for the demand on the lastFM Api
KUrl url;
url.setScheme( "http" );
url.setHost( "ws.audioscrobbler.com" );
url.setPath( "/2.0/" );
url.addQueryItem( "method", "artist.getTopTracks" );
url.addQueryItem( "api_key", Amarok::lastfmApiKey() );
url.addQueryItem( "artist", m_artist->name() );
The::networkAccessManager()->getData( url, this,
SLOT(parseTopTrack(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) );
}
示例7: SLOT
void
SimilarArtistsEngine::similarArtistsRequest( const QString &artistName )
{
// we generate the url for the demand on the lastFM Api
KUrl url;
url.setScheme( "http" );
url.setHost( "ws.audioscrobbler.com" );
url.setPath( "/2.0/" );
url.addQueryItem( "method", "artist.getSimilar" );
url.addQueryItem( "api_key", Amarok::lastfmApiKey() );
url.addQueryItem( "artist", artistName );
url.addQueryItem( "limit", QString::number( m_maxArtists ) );
The::networkAccessManager()->getData( url, this,
SLOT(parseSimilarArtists(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) );
}
示例8: buildUrl
KUrl LaconicaSearch::buildUrl(const SearchInfo &searchInfo,
ChoqokId sinceStatusId, uint count, uint page)
{
kDebug();
QString formattedQuery;
switch ( searchInfo.option ) {
case ToUser:
formattedQuery = searchInfo.query + "/replies/rss";
break;
case FromUser:
formattedQuery = searchInfo.query + "/rss";
break;
case ReferenceGroup:
formattedQuery = "group/" + searchInfo.query + "/rss";
break;
case ReferenceHashtag:
formattedQuery = searchInfo.query;
break;
default:
formattedQuery = searchInfo.query + "/rss";
break;
};
KUrl url;
TwitterApiAccount *theAccount = qobject_cast<TwitterApiAccount*>(searchInfo.account);
Q_ASSERT(theAccount);
if( searchInfo.option == ReferenceHashtag ) {
url = theAccount->apiUrl();
url.addPath("/search.atom");
url.addQueryItem("q", formattedQuery);
if( !sinceStatusId.isEmpty() )
url.addQueryItem( "since_id", sinceStatusId );
int cntStr = Choqok::BehaviorSettings::countOfPosts();
if( count && count <= 100 )
cntStr = count;
url.addQueryItem( "rpp", QString::number(cntStr) );
if( page > 1 )
url.addQueryItem( "page", QString::number( page ) );
} else {
url = theAccount->apiUrl().url(KUrl::AddTrailingSlash).remove("api/", Qt::CaseInsensitive);
url.addPath( formattedQuery );
}
return url;
}
示例9: imageUpload
bool ImgurTalker::imageUpload(const KUrl& filePath)
{
kDebug() << "Upload image" << filePath;
m_currentUrl = filePath;
MPForm form;
KUrl exportUrl = KUrl("http://api.imgur.com/2/upload.json");
exportUrl.addQueryItem("key", m_apiKey);
exportUrl.addQueryItem("name", filePath.fileName());
exportUrl.addQueryItem("title", filePath.fileName()); // this should be replaced with something the user submits
// exportUrl.addQueryItem("caption", ""); // this should be replaced with something the user submits
exportUrl.addQueryItem("type", "file");
form.addFile("image", filePath.path());
form.finish();
KIO::TransferJob* job = KIO::http_post(exportUrl, form.formData(), KIO::HideProgressInfo);
job->addMetaData("content-type", form.contentType());
job->addMetaData("content-length", QString("Content-Length: %1").arg(form.formData().length()));
job->addMetaData("UserAgent", m_userAgent);
connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
this, SLOT(slotData(KIO::Job*, const QByteArray&)));
connect(job, SIGNAL(result(KJob*)),
this, SLOT(slotResult(KJob*)));
m_state = IE_ADDPHOTO;
emit signalUploadStart(filePath);
emit signalBusy(true);
return true;
}
示例10: suggestionsUrl
KUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const
{
if (m_suggestionsUrlTemplate.isEmpty())
{
return KUrl();
}
KUrl retVal = KUrl::fromEncoded(parseTemplate(searchTerm, m_suggestionsUrlTemplate).toUtf8());
QList<Parameter>::const_iterator i;
for (i = m_suggestionsParameters.constBegin(); i != m_suggestionsParameters.constEnd(); ++i)
{
retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
}
return retVal;
}
示例11: debug
void
AmpacheAccountLogin::authenticate( const KUrl &requestUrl, QByteArray data, NetworkAccessManagerProxy::Error e )
{
if( !m_lastRequest )
return;
QCA::Initializer init;
DEBUG_BLOCK
Q_UNUSED( requestUrl );
QDomDocument doc;
doc.setContent( data );
if( !generalVerify( doc, e ) )
return;
// so lets figure out what we got here:
debug() << "Version reply: " << data;
int version = getVersion( doc );
KUrl url = getRequestUrl( "handshake" );
QString timestamp = QString::number( QDateTime::currentDateTime().toTime_t() );
QString passPhrase;
// We need to use different authentication strings depending on the version of ampache
if( version > 350000 )
{
debug() << "New Password Scheme " << version;
url.addQueryItem( "version", "350001" );
QCA::Hash sha256Hash( "sha256" );
sha256Hash.update( m_password.toUtf8() );
QString hashedPassword = QCA::arrayToHex( sha256Hash.final().toByteArray() );
QString rawHandshake = timestamp + hashedPassword;
sha256Hash.clear();
sha256Hash.update( rawHandshake.toUtf8() );
passPhrase = QCA::arrayToHex( sha256Hash.final().toByteArray() );
}
示例12: requestPersonSearchByName
PersonListJob* Provider::requestPersonSearchByName(const QString& name)
{
KUrl url = createUrl( "person/data");
url.addQueryItem("name", name);
return doRequestPersonList( url );
}
示例13: doRequest
void HTTPTracker::doRequest(WaitJob* wjob)
{
KUrl u = url;
if (!url.isValid())
{
requestPending();
QTimer::singleShot(500, this, SLOT(emitInvalidURLFailure()));
return;
}
Uint16 port = ServerInterface::getPort();
u.addQueryItem("peer_id", peer_id.toString());
u.addQueryItem("port", QString::number(port));
u.addQueryItem("uploaded", QString::number(bytesUploaded()));
u.addQueryItem("downloaded", QString::number(bytesDownloaded()));
if (event == "completed")
u.addQueryItem("left", "0"); // need to send 0 when we are completed
else
u.addQueryItem("left", QString::number(tds->bytesLeft()));
u.addQueryItem("compact", "1");
if (event != "stopped")
u.addQueryItem("numwant", "200");
else
u.addQueryItem("numwant", "0");
u.addQueryItem("key", QString::number(key));
QString cip = Tracker::getCustomIP();
if (cip.isNull())
cip = CurrentIPv6Address();
if (!cip.isEmpty())
u.addQueryItem("ip", cip);
if (event.isEmpty() && supports_partial_seed_extension && tds->isPartialSeed())
event = "paused";
if (!event.isEmpty())
u.addQueryItem("event", event);
QString epq = u.encodedPathAndQuery();
const SHA1Hash & info_hash = tds->infoHash();
epq += "&info_hash=" + info_hash.toURLString();
u.setEncodedPathAndQuery(epq);
if (active_job)
{
announce_queue.append(u);
Out(SYS_TRK | LOG_NOTICE) << "Announce ongoing, queueing announce" << endl;
}
else
{
doAnnounce(u);
// if there is a wait job, add this job to the waitjob
if (wjob)
wjob->addExitOperation(new ExitJobOperation(active_job));
}
}
示例14: if
void
PhotosEngine::update( bool force )
{
QString tmpYoutStr;
// prevent
Meta::TrackPtr currentTrack = The::engineController()->currentTrack();
if( !currentTrack || !currentTrack->artist() )
{
debug() << "invalid current track";
setData( "photos", Plasma::DataEngine::Data() );
return;
}
else if( !force && currentTrack->artist()->name() == m_artist )
{
debug() << "artist name unchanged";
setData( "photos", Plasma::DataEngine::Data() );
return;
}
else
{
unsubscribeFrom( m_currentTrack );
m_currentTrack = currentTrack;
subscribeTo( currentTrack );
if ( !currentTrack )
return;
// Save artist
m_artist = currentTrack->artist()->name();
removeAllData( "photos" );
// Show the information
if( !m_artist.isEmpty() )
{
setData( "photos", "message", "Fetching");
setData( "photos", "artist", m_artist );
}
else
{
removeAllData( "photos" );
return;
}
QStringList tags = m_keywords;
tags << m_artist;
tags.removeDuplicates();
// Query flickr, order by relevance, 10 max
// Flickr :http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=9c5a288116c34c17ecee37877397fe31&text=ARTIST&per_page=20
KUrl flickrUrl;
flickrUrl.setScheme( "http" );
flickrUrl.setHost( "api.flickr.com" );
flickrUrl.setPath( "/services/rest/" );
flickrUrl.addQueryItem( "method", "flickr.photos.search" );
flickrUrl.addQueryItem( "api_key", Amarok::flickrApiKey() );
flickrUrl.addQueryItem( "per_page", QString::number( m_nbPhotos ) );
flickrUrl.addQueryItem( "sort", "date-posted-desc" );
flickrUrl.addQueryItem( "media", "photos" );
flickrUrl.addQueryItem( "content_type", QString::number(1) );
flickrUrl.addQueryItem( "text", tags.join(" ") );
debug() << "Flickr url:" << flickrUrl;
m_flickrUrls << flickrUrl;
The::networkAccessManager()->getData( flickrUrl, this,
SLOT(resultFlickr(KUrl,QByteArray,NetworkAccessManagerProxy::Error)) );
}
}