本文整理汇总了C++中QUrl::resolved方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::resolved方法的具体用法?C++ QUrl::resolved怎么用?C++ QUrl::resolved使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::resolved方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: searchForResourceSearchPath
QUrl searchForResourceSearchPath(const QUrl& baseUrl,
const QUrl& url,
const QStringList& searchPath)
{
if (url.isRelative()) {
if (!baseUrl.isLocalFile()) {
return baseUrl.resolved(url);
}
auto path = url.path();
if (!path.startsWith("/")) {
auto resolvedUrl = baseUrl.resolved(url);
if (QFile::exists(resolvedUrl.toLocalFile())) {
return resolvedUrl;
}
} else if (!path.contains("/../")) {
auto pathRelPart = path.split(QRegularExpression("^/+"))[1];
for (const auto& str : searchPath) {
auto dir = QDir(str);
auto absPath = QDir::cleanPath(dir.absoluteFilePath(pathRelPart));
if (QFile::exists(absPath)) {
return QUrl::fromLocalFile(absPath);
}
}
return QUrl();
} else {
return QUrl();
}
}
return url;
}
示例2: defined
QList<WebPageLinkedResource> WebPage::linkedResources(const QString &relation)
{
QList<WebPageLinkedResource> resources;
#if QT_VERSION >= 0x040600 || defined(WEBKIT_TRUNK)
QUrl baseUrl = mainFrame()->baseUrl();
QList<QWebElement> linkElements = mainFrame()->findAllElements(QLatin1String("html > head > link"));
foreach (const QWebElement &linkElement, linkElements) {
QString rel = linkElement.attribute(QLatin1String("rel"));
QString href = linkElement.attribute(QLatin1String("href"));
QString type = linkElement.attribute(QLatin1String("type"));
QString title = linkElement.attribute(QLatin1String("title"));
if (href.isEmpty() || type.isEmpty())
continue;
if (!relation.isEmpty() && rel != relation)
continue;
WebPageLinkedResource resource;
resource.rel = rel;
resource.type = type;
resource.href = baseUrl.resolved(QUrl::fromEncoded(href.toUtf8()));
resource.title = title;
resources.append(resource);
}
示例3: setURLToRedirectedUrl
void WebImageView::setURLToRedirectedUrl(QNetworkReply *reply) {
QUrl redirectionUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
QUrl baseUrl = reply->url();
QUrl resolvedUrl = baseUrl.resolved(redirectionUrl);
setUrl(resolvedUrl.toString());
}
示例4: imageLoaded
void WebImageView::imageLoaded() {
// Get reply
QNetworkReply * reply = qobject_cast<QNetworkReply*>(sender());
if (reply->error() == QNetworkReply::NoError){
QUrl baseUrl = reply->url();
QUrl redirection = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
// if redirection exists... Set the new Url
if(redirection.isEmpty()){
// Process reply
QByteArray imageData = reply->readAll();
// Set image from data
setImage( Image(imageData) );
}
else{
QUrl resolveUrl = baseUrl.resolved(redirection);
setUrl(resolveUrl.toString());
return;
}
}
// Memory management
reply->deleteLater();
}
示例5: resolveRelativeUrl
QString Phantom::resolveRelativeUrl(QString url, QString base)
{
QUrl u = QUrl::fromEncoded(url.toLatin1());
QUrl b = QUrl::fromEncoded(base.toLatin1());
return b.resolved(u).toEncoded();
}
示例6: ProcessTagValue
void CWizHtmlCollector::ProcessTagValue(CWizHtmlTag *pTag,
const QString& strAttributeName,
WIZHTMLFILEDATA::HtmlFileType eType)
{
QString strValue = pTag->getValueFromName(strAttributeName);
if (strValue.isEmpty())
return;
QUrl url(strValue);
if (url.isRelative()) {
QUrl urlBase = m_url;
url = urlBase.resolved(url);
}
QString strFileName;
if (!m_files.Lookup(url.toString(), strFileName)) {
strFileName = url.toLocalFile();
if (!strFileName.isEmpty() && !PathFileExists(strFileName)) {
strFileName.clear();
}
if (strFileName.isEmpty())
return;
m_files.Add(url.toString(), strFileName, eType, false);
}
pTag->setValueToName(strAttributeName, ToResourceFileName(strFileName));
}
示例7: resolved
QUrl QUrlProto::resolved(const QUrl &relative) const
{
QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
if (item)
return item->resolved(relative);
return QUrl();
}
示例8: relativeUrl
QList<webFileUtils::webFile> webFileUtils::getWebFiles(QUrl url)
{
QList<webFileUtils::webFile> list;
QWebPage *webPage = new QWebPage(this);
QEventLoop loop;
connect(webPage->mainFrame(), SIGNAL(loadFinished(bool)), &loop, SLOT(quit()));
webPage->mainFrame()->load(url);
loop.exec();
QUrl baseUrl = webPage->mainFrame()->baseUrl();
QWebElementCollection collection = webPage->mainFrame()->findAllElements("a");
foreach (QWebElement element, collection)
{
QString href = element.attribute("href");
if (!href.isEmpty())
{
QUrl relativeUrl(href);
QUrl absoluteUrl = baseUrl.resolved(relativeUrl);
if(element.toPlainText().contains("exe") | element.toPlainText().contains("tar.xz") | element.toPlainText().contains("zip")) {
webFile file;
file.name = element.toPlainText();
file.url = absoluteUrl;
list.append(file);
}
}
}
示例9: queueLoad
void TestRunner::queueLoad(const QString& url, const QString& target)
{
//qDebug() << ">>>queueLoad" << url << target;
QUrl mainResourceUrl = m_drt->webPage()->mainFrame()->url();
QString absoluteUrl = mainResourceUrl.resolved(QUrl(url)).toEncoded();
WorkQueue::shared()->queue(new LoadItem(absoluteUrl, target, m_drt->webPage()));
}
示例10: queueLoad
void TestRunner::queueLoad(JSStringRef url, JSStringRef target)
{
DumpRenderTree* drt = DumpRenderTree::instance();
QUrl mainResourceUrl = drt->webPage()->mainFrame()->url();
QString absoluteUrl = mainResourceUrl.resolved(QUrl(JSStringCopyQString(url))).toEncoded();
WorkQueue::shared()->queue(new LoadItem(JSStringCreateWithQString(absoluteUrl).get(), target));
}
示例11: resolved
int Url::resolved ( lua_State * L )// ( const QUrl & relative ) const : QUrl
{
QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 );
QUrl* relative = ValueInstaller2<QUrl>::check( L, 2 );
QUrl* res = ValueInstaller2<QUrl>::create( L );
*res = lhs->resolved( *relative );
return 1;
}
示例12: resolve
QUrl XSLTUriResolver::resolve(const QUrl& relative, const QUrl& baseURI) const
{
QUrl url = baseURI.resolved(relative);
if (!m_document->frame() || !m_document->securityOrigin()->canRequest(url))
return QUrl();
return url;
}
示例13: set_url
void Song::set_url(const QUrl& v) {
if (Application::kIsPortable) {
QUrl base = QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + "/");
d->url_ = base.resolved(v);
} else {
d->url_ = v;
}
}
示例14: beginDragWithFiles
// Simulates a mouse down event for drag without sending an actual mouse down event.
void EventSender::beginDragWithFiles(const QStringList& files)
{
m_currentDragData.clear();
QList<QUrl> fileUrls;
QUrl baseUrl = m_page->mainFrame()->baseUrl();
foreach (const QString& file, files) {
QUrl resolvedUrl = baseUrl.resolved(file);
fileUrls.append(resolvedUrl);
}
示例15: onQNetworkReplyFinished
void onQNetworkReplyFinished() {
// either error or all data has been read
DEBUG("httpFinished()");
QVariant redirectionTarget = qreply->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (!redirectionTarget.isNull())
{
QUrl newUrl = url.resolved(redirectionTarget.toUrl());
DEBUG("Handled redirect to: " << newUrl.toString());
qreply->deleteLater();
qreply = nullptr;
doOperation(newUrl);
return;
}
else if (qreply->error())
{
WARN("HTTP ERROR: " << qreply->errorString());
result << InvocationErrors::INVOCATION_FAILED;
QVariant statusCode = qreply->attribute( QNetworkRequest::HttpStatusCodeAttribute );
if (statusCode.isValid()) {
httpStatus = HTTPInvocationDefinition::resolveHttpStatus(statusCode.toInt());
} else {
httpStatus = HTTPInvocationDefinition::UNDEFINED;
result << Result::reasonFromDesc("Http response code is not valid");
}
invocationStatus = Invocation::ERROR;
// get possible return data (detailed error info)
// responseErrorData = qreply->readAll();
result << InvocationErrors::CONNECTION_FAILED
<< Result::Meta("qnetworkreply_error_string", qreply->errorString());
QNetworkReply::NetworkError err = qreply->error();
result << NetworkErrorReasons::from(err, qreply->errorString());
//result << Result::reasonFromCode("QNETWORKREPLY_ERROR", qreply->errorString());
emit q->finishedError(q);
}
else
{
// we have all data
// (TODO: is it so that readRead() is invoked before?)
if (outputFile.isOpen())
outputFile.close();
invocationStatus = Invocation::FINISHED;
emit q->finishedOK(q);
}
qreply->deleteLater();
qreply = nullptr;
}