当前位置: 首页>>代码示例>>C++>>正文


C++ QUrl::resolved方法代码示例

本文整理汇总了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;
}
开发者ID:Ableton,项目名称:aqt-stylesheets,代码行数:34,代码来源:UrlUtils.cpp

示例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);
    }
开发者ID:lionhearting,项目名称:arora,代码行数:28,代码来源:webpage.cpp

示例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());
}
开发者ID:PauloMendes89,项目名称:BlackBerry10-Samples,代码行数:7,代码来源:WebImageView.cpp

示例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();

	}
开发者ID:dridk,项目名称:BlackBerry10-Samples,代码行数:30,代码来源:WebImageView.cpp

示例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();
}
开发者ID:wision,项目名称:phantomjs,代码行数:7,代码来源:phantom.cpp

示例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));
}
开发者ID:flyfire,项目名称:WizQTClient,代码行数:29,代码来源:wizhtmlcollector.cpp

示例7: resolved

QUrl QUrlProto::resolved(const QUrl &relative) const
{
  QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
  if (item)
    return item->resolved(relative);
  return QUrl();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例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);
            }
        }
    }
开发者ID:JBTecnologia,项目名称:ReleaseBuilder,代码行数:26,代码来源:webfileutils.cpp

示例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()));
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例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));
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:7,代码来源:TestRunnerQt.cpp

示例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;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:8,代码来源:QtlUrl.cpp

示例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;
}
开发者ID:achellies,项目名称:WinCEWebKit,代码行数:8,代码来源:XSLTProcessorQt.cpp

示例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;
  }
}
开发者ID:BrummbQ,项目名称:Clementine,代码行数:8,代码来源:song.cpp

示例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);
    }
开发者ID:kcomkar,项目名称:webkit,代码行数:10,代码来源:EventSenderQt.cpp

示例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;
    }
开发者ID:gberryproject,项目名称:gberry,代码行数:55,代码来源:downloadstreaminvocationimpl.cpp


注:本文中的QUrl::resolved方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。