本文整理汇总了C++中QUrl::setEncodedUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::setEncodedUrl方法的具体用法?C++ QUrl::setEncodedUrl怎么用?C++ QUrl::setEncodedUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::setEncodedUrl方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: encode
Song & MagnatuneService::fixPath(Song &s) const
{
s.type=Song::OnlineSvrTrack;
if (MB_None!=membership) {
QUrl url;
#if QT_VERSION < 0x050000
url.setEncodedUrl(s.file.toLocal8Bit());
#else
url=QUrl(s.file);
#endif
url.setScheme("http");
url.setHost(MB_Streaming==membership ? constStreamingHostname : constDownloadHostname);
url.setUserName(username);
url.setPassword(password);
// And remove the commercial
QString path = url.path();
path.insert(path.lastIndexOf('.'), "_nospeech");
url.setPath(path);
s.file=url.toString();
// TODO: Magnatune downloads!
// if (MB_Download==membership) {
// s.genre=downloadTypeStr(download);
// }
}
s.setIsFromOnlineService(name());
return encode(s);
}
示例2:
QUrl
SeriesAction::replaceModifiers(QUrl url, QtTvDB::Show *show,
int season, QtTvDB::Episode *episode) const
{
/*
* %S current show name (MyShow)
* %E current episode name (Pilot)
* %n current season number (1)
* %e current episode number (1)
* %b formated episode number (E01)
* %m formated season number (S01)
*/
QString str = url.toString();
if (show) {
str.replace("%S", QUrl::toPercentEncoding(show->name()));
}
if (season >= 0) {
str.replace("%n", QUrl::toPercentEncoding(QString("%1").arg(season)));
str.replace("%m", QUrl::toPercentEncoding(QString("S%1").arg(season, 2, 10, QLatin1Char('0'))));
}
if (episode) {
str.replace("%E", QUrl::toPercentEncoding(episode->name()));
str.replace("%e", QUrl::toPercentEncoding(QString("%1").arg(episode->episode())));
str.replace("%b", QUrl::toPercentEncoding(QString("E%1").arg(episode->episode(), 2, 10, QLatin1Char('0'))));
}
QUrl ret;
ret.setEncodedUrl(str.toUtf8());
return ret;
}
示例3: download
void CFileDownload::download(const QString& strUrl, const QString& strFolder, bool bOverWrite, bool bAutoRemoveFile)
{
m_strFolder = strFolder;
m_strUrl = strUrl;
m_bOverWrite = bOverWrite;
m_bAutoRemoveFile = bAutoRemoveFile;
QUrl url;
url.setEncodedUrl(m_strUrl.toAscii());
if (!url.isValid())
{
emit finishedDownloadAttachmentItem(m_pAttachmentItem, tr("Error: Bad file URL"));
return;
}
if(m_pAttachmentItem)
m_pAttachmentItem->setProcessState(STATE_PS_UPLOADING);
QNetworkRequest request(url);
request.setRawHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)");
// request.setRawHeader("User-Agent", "Wget");
// request.setRawHeader("Accept", "*/*");
// request.setRawHeader("Connection", "Keep-Alive");
// request.setRawHeader("Keep-Alive", "300");
m_pNetworkReply = m_pNetworkMgr->get(request);
connect(m_pNetworkReply, SIGNAL(metaDataChanged()), this, SLOT(onMetaDataChanged()));
connect(m_pNetworkReply, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
connect(m_pNetworkReply, SIGNAL(uploadProgress(qint64, qint64)), this, SIGNAL(uploadProgress(qint64, qint64)));
connect(m_pNetworkReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(onDownloadProgress(qint64,qint64)));
connect(m_pNetworkReply, SIGNAL(finished()), this, SLOT(onFinished()));
}
示例4: setEncodedUrl
int Url::setEncodedUrl ( lua_State * L )// ( const QByteArray & encodedUrl )
{
QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 );
//QByteArray* encodedUrl = ValueInstaller2<QByteArray>::check( L, 2 );
if( Util::isNil( L, 3 ))
{
lhs->setEncodedUrl( Util::toStr( L, 2 ) );
}
else
{
Enums enums(L);
QUrl::ParsingMode f=(QUrl::ParsingMode)enums.ParsingMode( 3 );
lhs->setEncodedUrl( Util::toStr( L, 2 ), f );
}
return 0;
}
示例5: onParseContent
void UBOEmbedParser::onParseContent(QString url)
{
QUrl qurl;
qurl.setEncodedUrl(url.toAscii());
QNetworkRequest req;
req.setUrl(qurl);
if(NULL != mpNam) {
mpNam->get(req);
}
}
示例6: on_clientLoginDone
void CWizGroupAttributeForm::on_clientLoginDone()
{
QString strExt = QString("token=%1&kb_guid=%2").arg(WizGlobal()->token()).arg(m_strKbGUID);
QByteArray bytes = QUrl::toPercentEncoding(strExt);
QString strUrl = WizApiGetUrl("wiz", WIZ_CLIENT_VERSION, "view_group", bytes);
// use raw url
QUrl url;
url.setEncodedUrl(strUrl.toAscii());
m_web->load(url);
}
示例7: start
/*
void VDomKit::start()
{
connect(m_page, SIGNAL(loadFinished(bool)), this, SLOT(load()));
}
*/
const QByteArray& VDomKit::dump(const QByteArray &url) {
QUrl qurl;
qurl.setEncodedUrl(url, QUrl::StrictMode);
//qDebug() << qurl << endl;
if (qurl.isValid()) {
#ifdef ENABLE_TIMER
QTime t;
t.start();
#endif
m_page->mainFrame()->load(qurl);
VDomKitLoop loop;
QObject::connect(m_page, SIGNAL(loadFinished(bool)), &loop,
SLOT(quitWithRes(bool)));
QTimer timer;
QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
if (m_timeout > 0) {
QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
timer.setSingleShot(true);
timer.start(m_timeout);
}
loop.exec();
if (!timeoutSpy.isEmpty()) {
fprintf(stderr, "Page loading timeout (exceeded %d ms): %s\n",
m_timeout, url.data());
m_page->blockSignals(true);
m_page->triggerAction(QWebPage::Stop);
m_page->blockSignals(false);
//return NullString;
} else if (!loop.getRes()) {
fprintf(stderr, "Failed to load page: %s\n", url.data());
return NullString;
}
#ifdef ENABLE_TIMER
qDebug("loading elapsed: %d ms", t.elapsed());
t.restart();
#endif
const QByteArray& retval = m_webvdom->dump();
#ifdef ENABLE_TIMER
qDebug("dumping elapsed: %d ms", t.elapsed());
#endif
return retval;
} else {
示例8: ReadTrack
Song MagnatuneService::ReadTrack(QXmlStreamReader& reader) {
Song song;
while (!reader.atEnd()) {
reader.readNext();
if (reader.tokenType() == QXmlStreamReader::EndElement) break;
if (reader.tokenType() == QXmlStreamReader::StartElement) {
QStringRef name = reader.name();
QString value = ReadElementText(reader);
if (name == "artist") song.set_artist(value);
if (name == "albumname") song.set_album(value);
if (name == "trackname") song.set_title(value);
if (name == "tracknum") song.set_track(value.toInt());
if (name == "year") song.set_year(value.toInt());
if (name == "magnatunegenres") song.set_genre(value.section(',', 0, 0));
if (name == "seconds")
song.set_length_nanosec(value.toInt() * kNsecPerSec);
if (name == "cover_small") song.set_art_automatic(value);
if (name == "albumsku") song.set_comment(value);
if (name == "url") {
QUrl url;
// Magnatune's URLs are already encoded
url.setEncodedUrl(value.toLocal8Bit());
url.setScheme("magnatune");
song.set_url(url);
}
}
}
song.set_valid(true);
song.set_filetype(Song::Type_Stream);
// We need to set these to satisfy the database constraints
song.set_directory_id(0);
song.set_mtime(0);
song.set_ctime(0);
song.set_filesize(0);
return song;
}
示例9: doRequest
QNetworkReply* QCouch::doRequest(Method method, QString _url, const QByteArray bytes){
QUrl url = QUrl();
url.setEncodedUrl(QString(host + _url).toUtf8());
url.setPort(port);
QTimer timeout;
QEventLoop loop;
timeout.setSingleShot(true);
QNetworkRequest request;
request.setUrl(url);
QNetworkReply *reply;
switch (method) {
case GET:
reply = manager->get(request);
break;
case PUT:
reply = manager->put(request, bytes);
break;
case DELETE:
reply = manager->deleteResource(request);
break;
default:
reply = manager->get(request);
break;
}
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
QObject::connect(&timeout, SIGNAL(timeout()), &loop, SLOT(quit()));
timeout.start(5000);
loop.exec();
if ( timeout.isActive() ) {
return reply;
} else {
throw new TimeoutException;
}
}
示例10: createOAuthUrl
QUrl Oauth::createOAuthUrl( const QUrl url, const QString oAuthConsumerKey, const QString sharedSecret, const QString verb , const QString tokenSecret )
{
const QString current = QString::number(QDateTime::currentDateTime().toUTC().toTime_t());
const QString nonce = Nonce();
QList<QPair<QString, QString> > inputParams = url.queryItems();
inputParams.append(QPair<QString,QString>(QString::fromLatin1(OAUTH_CONSUMER_KEY),oAuthConsumerKey));
inputParams.append(QPair<QString,QString>(QString::fromLatin1(OAUTH_SIGNATURE_METHOD),NETFLIX_SIGNATURE_METHOD));
inputParams.append(QPair<QString,QString>(QString::fromLatin1(OAUTH_TIMESTAMP),current));
inputParams.append(QPair<QString,QString>(QString::fromLatin1(OAUTH_NONCE),nonce));
inputParams.append(QPair<QString,QString>(QString::fromLatin1(OAUTH_VERSION),NETFLIX_OAUTH_VERSION));
qSort(inputParams.begin(),inputParams.end(),comparer);
qDebug() << inputParams;
QByteArray host = url.toEncoded(QUrl::RemoveQuery);
QUrl returnUrl;
returnUrl.setEncodedUrl(host);
const int length = inputParams.size();
for( int i=0; i<length ; i++)
{
returnUrl.addQueryItem(inputParams.at(i).first,inputParams.at(i).second);
}
QString oAuthParams = returnUrl.encodedQuery();
QString requestString = QString("%1&%2&%3").arg(verb, host.toPercentEncoding(), Escape(oAuthParams));
qDebug() << requestString;
QByteArray signature = HmacSha1(sharedSecret,requestString, tokenSecret);
qDebug() << signature;
returnUrl.addEncodedQueryItem(OAUTH_SIGNATURE,signature);
return returnUrl;
}
示例11: FixupUrl
QUrl LastFMService::FixupUrl(const QUrl& url) {
QUrl ret;
ret.setEncodedUrl(url.toEncoded().replace(
"USERNAME", QUrl::toPercentEncoding(lastfm::ws::Username)));
return ret;
}
示例12: openUrl
bool WulforUtil::openUrl(const QString &url){
if (url.startsWith("http://") || url.startsWith("www.") || url.startsWith(("ftp://")) || url.startsWith("https://")){
if (!SETTING(MIME_HANDLER).empty())
QProcess::startDetached(_q(SETTING(MIME_HANDLER)), QStringList(url));
else
QDesktopServices::openUrl(QUrl::fromEncoded(url.toAscii()));
}
else if (url.startsWith("adc://") || url.startsWith("adcs://")){
MainWindow::getInstance()->newHubFrame(url, "UTF-8");
}
else if (url.startsWith("dchub://")){
MainWindow::getInstance()->newHubFrame(url, WSGET(WS_DEFAULT_LOCALE));
}
else if (url.startsWith("magnet:") && url.contains("urn:tree:tiger")){
QString magnet = url;
Magnet *m = new Magnet(MainWindow::getInstance());
m->setLink(magnet);
if (WIGET(WI_DEF_MAGNET_ACTION) == 0) {
m->exec();
}
m->deleteLater();
}
else if (url.startsWith("magnet:")){
QString magnet = url;
QUrl u;
if (!magnet.contains("+"))
u.setEncodedUrl(magnet.toAscii());
else {
QString _l = magnet;
_l.replace("+", "%20");
u.setEncodedUrl(_l.toAscii());
}
if (u.hasQueryItem("kt")){
QString keywords = u.queryItemValue("kt");
QString hub = u.hasQueryItem("xs")? u.queryItemValue("xs") : "";
if (!(hub.startsWith("dchub://", Qt::CaseInsensitive) ||
hub.startsWith("adc://", Qt::CaseInsensitive) ||
hub.startsWith("adcs://", Qt::CaseInsensitive)) && !hub.isEmpty())
hub.prepend("dchub://");
if (keywords.isEmpty())
return false;
if (!hub.isEmpty())
WulforUtil::openUrl(hub);
SearchFrame *sfr = ArenaWidgetFactory().create<SearchFrame>();
sfr->fastSearch(keywords, false);
}
else {
if (!SETTING(MIME_HANDLER).empty())
QProcess::startDetached(_q(SETTING(MIME_HANDLER)), QStringList(url));
else
QDesktopServices::openUrl(QUrl::fromEncoded(url.toAscii()));
}
}
else
return false;
return true;
}
示例13: setEncodedUrl
void QUrlProto::setEncodedUrl(const QByteArray &encodedUrl, QUrl::ParsingMode parsingMode)
{
QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
if (item)
item->setEncodedUrl(encodedUrl, parsingMode);
}