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


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

本文整理汇总了C++中QUrl::isRelative方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::isRelative方法的具体用法?C++ QUrl::isRelative怎么用?C++ QUrl::isRelative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QUrl的用法示例。


在下文中一共展示了QUrl::isRelative方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setSource

/**
 * Supports only rendering of local files and resources that can be downloaded over
 * the http protocol. In the latter case the download gets started.
 */
void TextBrowser::setSource (const QUrl& url)
{
  bool relativeUrl = url.isRelative();
  if (!relativeUrl)
    d->source = url; // last set absolute url
  QString name = url.toString();
  if (url.scheme() == QLatin1String("http")) {
    // start the download but do not call setSource() of the base
    // class because we must wait until the data are available.
    // The slot done() is invoked automatically then. 
    d->http->setHost(url.host());
    d->http->get(url.path(), 0);
  } else if (d->source.scheme() == QLatin1String("http")) {
    // relative hyperlink in previously downloaded a HTML page 
    d->source = d->source.resolved(url);
    d->http->get(url.path(), 0);
  } else {
    QUrl resolved = url;
#if defined (Q_OS_WIN)
    if (url.scheme() == QLatin1String("file") && !url.isRelative()) {
      QString auth = url.authority();
      QString path = url.path();
      //If we click on a hyperlink with a reference to an absolute file name
      //then we get a string that cannot be used to open the file. So we try 
      //to reproduce the original url.
      if (!auth.isEmpty() && !path.isEmpty()) {
        QString fileName = auth + QLatin1Char(':') + path;
        resolved = QUrl::fromLocalFile(fileName);
      }
    }
#endif
    QTextBrowser::setSource(resolved);
  }
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:38,代码来源:HelpView.cpp

示例2: evaluateSingleton

Item DocumentURIFN::evaluateSingleton(const DynamicContext::Ptr &context) const
{
    const Item node(m_operands.first()->evaluateSingleton(context));

    if(node)
    {
        const QUrl documentURI(node.asNode().documentUri());

        if(documentURI.isValid())
        {
            if(documentURI.isEmpty())
                return Item();
            else
            {
                Q_ASSERT_X(!documentURI.isRelative(), Q_FUNC_INFO,
                           "The document URI must be absolute.");
                return toItem(AnyURI::fromValue(documentURI));
            }
        }
        else
            return Item();
    }
    else
        return Item();
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:25,代码来源:qaccessorfns.cpp

示例3: isValidLocalPath

bool Utils::isValidLocalPath(const QString &value)
{
	QUrl		url;
	
	url.setUrl(value);
	return (url.isValid() && (url.isRelative() || url.scheme().toLower() == "file") );
}
开发者ID:jetcodes,项目名称:JetMind,代码行数:7,代码来源:CUtils.cpp

示例4: addRss

void RSSWidget::addRss()
{
    if (!m_view) {
        return;
    }
    if (QPushButton* button = qobject_cast<QPushButton*>(sender())) {
        QUrl url = button->property("rss-url").toUrl();

        if (url.isRelative()) {
            url = m_view->page()->mainFrame()->baseUrl().resolved(url);
        }

        if (!url.isValid()) {
            return;
        }

        QString title = button->property("rss-title").toString();
        if (title.isEmpty()) {
            title = m_view->url().host();
        }

        RSSNotification* notif = new RSSNotification(title, url, m_view);
        m_view->addNotification(notif);
        close();
    }
}
开发者ID:DmitriK,项目名称:qupzilla,代码行数:26,代码来源:rsswidget.cpp

示例5: loadResource

QVariant HelpBrowser::loadResource(int type, const QUrl &name){



      QTextBrowser::loadResource(type, name);

//      if (name.scheme() == "qthelp")
//          return QVariant(m_helpEngine->fileData(name));
//      else
//          return QTextBrowser::loadResource(type, name);


    return   m_helpEngine->fileData(name);




     QByteArray ba;
    if (type < 10 && m_helpEngine) {
        QUrl url(name);
        if (name.isRelative())
            url = source().resolved(url);
        ba = m_helpEngine->fileData(url);
    }
    return ba;
}
开发者ID:luigialberti,项目名称:dolomites,代码行数:26,代码来源:helpbrowser.cpp

示例6: loadUrl

/*!
    Load the QDeclarativeComponent from the provided \a url.

    Ensure that the URL provided is full and correct, in particular, use
    \l QUrl::fromLocalFile() when loading a file from the local filesystem.
*/
void QDeclarativeComponent::loadUrl(const QUrl &url)
{
    Q_D(QDeclarativeComponent);

    d->clear();

    if (url.isRelative() && !url.isEmpty())
        d->url = d->engine->baseUrl().resolved(url);
    else
        d->url = url;

    if (url.isEmpty()) {
        QDeclarativeError error;
        error.setDescription(tr("Invalid empty URL"));
        d->state.errors << error;
        return;
    }

    QDeclarativeCompositeTypeData *data =
        QDeclarativeEnginePrivate::get(d->engine)->typeManager.get(d->url);

    if (data->status == QDeclarativeCompositeTypeData::Waiting
            || data->status == QDeclarativeCompositeTypeData::WaitingResources)
    {
        d->typeData = data;
        d->typeData->addWaiter(d);
        d->progress = data->progress;
    } else {
        d->fromTypeData(data);
        d->progress = 1.0;
    }

    emit statusChanged(status());
    emit progressChanged(d->progress);
}
开发者ID:,项目名称:,代码行数:41,代码来源:

示例7: isRelative

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

示例8: 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

示例9: copyResource

QString VWebUtils::copyResource(const QUrl &p_url, const QString &p_folder) const
{
    Q_ASSERT(!p_url.isRelative());

    QDir dir(p_folder);
    if (!dir.exists()) {
        VUtils::makePath(p_folder);
    }

    QString file = p_url.isLocalFile() ? p_url.toLocalFile() : p_url.toString();
    QString fileName = VUtils::fileNameFromPath(file);
    fileName = VUtils::getFileNameWithSequence(p_folder, fileName, true);
    QString targetFile = dir.absoluteFilePath(fileName);

    bool succ = false;
    if (p_url.scheme() == "https" || p_url.scheme() == "http") {
        // Download it.
        QByteArray data = VDownloader::downloadSync(p_url);
        if (!data.isEmpty()) {
            succ = VUtils::writeFileToDisk(targetFile, data);
        }
    } else if (QFileInfo::exists(file)) {
        // Do a copy.
        succ = VUtils::copyFile(file, targetFile, false);
    }

    return succ ? targetFile : QString();
}
开发者ID:getwindow,项目名称:vnote,代码行数:28,代码来源:vwebutils.cpp

示例10: resolvedUrl

QUrl QQmlContextData::resolvedUrl(const QUrl &src)
{
    QQmlContextData *ctxt = this;

    QUrl resolved;
    if (src.isRelative() && !src.isEmpty()) {
        if (ctxt) {
            while(ctxt) {
                if (ctxt->url().isValid())
                    break;
                else
                    ctxt = ctxt->parent;
            }

            if (ctxt)
                resolved = ctxt->url().resolved(src);
            else if (engine)
                resolved = engine->baseUrl().resolved(src);
        }
    } else {
        resolved = src;
    }

    if (resolved.isEmpty()) //relative but no ctxt
        return resolved;

    if (engine && engine->urlInterceptor())
        resolved = engine->urlInterceptor()->intercept(resolved, QQmlAbstractUrlInterceptor::UrlString);
    return resolved;
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例11: loadInternal

void OffscreenSurface::loadInternal(const QUrl& qmlSource,
                                    bool createNewContext,
                                    QQuickItem* parent,
                                    const QmlContextObjectCallback& callback) {
    if (QThread::currentThread() != thread()) {
        qFatal("Called load on a non-surface thread");
    }
    // Synchronous loading may take a while; restart the deadlock timer
    QMetaObject::invokeMethod(qApp, "updateHeartbeat", Qt::DirectConnection);

    if (!getRootItem()) {
        _sharedObject->create(this);
    }

    QUrl finalQmlSource = qmlSource;
    if ((qmlSource.isRelative() && !qmlSource.isEmpty()) || qmlSource.scheme() == QLatin1String("file")) {
        finalQmlSource = getSurfaceContext()->resolvedUrl(qmlSource);
    }

    if (!getRootItem()) {
        _sharedObject->setObjectName(finalQmlSource.toString());
    }

    auto targetContext = contextForUrl(finalQmlSource, parent, createNewContext);
    auto qmlComponent = new QQmlComponent(getSurfaceContext()->engine(), finalQmlSource, QQmlComponent::PreferSynchronous);
    if (qmlComponent->isLoading()) {
        connect(qmlComponent, &QQmlComponent::statusChanged, this,
                [=](QQmlComponent::Status) { finishQmlLoad(qmlComponent, targetContext, parent, callback); });
        return;
    }

    finishQmlLoad(qmlComponent, targetContext, parent, callback);
}
开发者ID:binaryking,项目名称:hifi,代码行数:33,代码来源:OffscreenSurface.cpp

示例12: loadUrl

/*!
    Load the QDeclarativeComponent from the provided \a url.

    Ensure that the URL provided is full and correct, in particular, use
    \l QUrl::fromLocalFile() when loading a file from the local filesystem.
*/
void QDeclarativeComponent::loadUrl(const QUrl &url)
{
    Q_D(QDeclarativeComponent);

    d->clear();

    if ((url.isRelative() && !url.isEmpty())
    || url.scheme() == QLatin1String("file")) // Workaround QTBUG-11929
        d->url = d->engine->baseUrl().resolved(url);
    else
        d->url = url;

    if (url.isEmpty()) {
        QDeclarativeError error;
        error.setDescription(tr("Invalid empty URL"));
        d->state.errors << error;
        return;
    }

    QDeclarativeTypeData *data = QDeclarativeEnginePrivate::get(d->engine)->typeLoader.get(d->url);

    if (data->isCompleteOrError()) {
        d->fromTypeData(data);
        d->progress = 1.0;
    } else {
        d->typeData = data;
        d->typeData->registerCallback(d);
        d->progress = data->progress();
    }

    emit statusChanged(status());
    emit progressChanged(d->progress);
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:39,代码来源:qdeclarativecomponent.cpp

示例13: fromLocalFile

static inline QUrl ensureAbsoluteUrl(const QUrl &url)
{
    if (!url.isRelative())
        return url;

    return QUrl::fromLocalFile(QFileInfo(url.toLocalFile()).absoluteFilePath());
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:7,代码来源:qwebframe.cpp

示例14: announceUnparsedText

ItemType::Ptr ResourceLoader::announceUnparsedText(const QUrl &uri)
{
    Q_ASSERT(uri.isValid());
    Q_ASSERT(!uri.isRelative());
    Q_UNUSED(uri); /* Needed when compiling in release mode. */
    return ItemType::Ptr();
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:7,代码来源:qresourceloader.cpp

示例15: announceDocument

SequenceType::Ptr ResourceLoader::announceDocument(const QUrl &uri, const Usage)
{
    Q_ASSERT(uri.isValid());
    Q_ASSERT(!uri.isRelative());
    Q_UNUSED(uri); /* Needed when compiling in release mode. */
    return SequenceType::Ptr();
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:7,代码来源:qresourceloader.cpp


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