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


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

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


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

示例1: if

QT_BEGIN_NAMESPACE

QNetworkAccessBackend *
QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op,
        const QNetworkRequest &request) const
{
    // is it an operation we know of?
    switch (op) {
    case QNetworkAccessManager::GetOperation:
    case QNetworkAccessManager::PutOperation:
        break;

    default:
        // no, we can't handle this operation
        return 0;
    }

    QUrl url = request.url();
    if (url.scheme() == QLatin1String("qrc") || !url.toLocalFile().isEmpty())
        return new QNetworkAccessFileBackend;
    else if (!url.isEmpty() && url.authority().isEmpty()) {
        // check if QFile could, in theory, open this URL
        QFileInfo fi(url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery));
        if (fi.exists() || (op == QNetworkAccessManager::PutOperation && fi.dir().exists()))
            return new QNetworkAccessFileBackend;
    }

    return 0;
}
开发者ID:venkatarajasekhar,项目名称:ECE497,代码行数:29,代码来源:qnetworkaccessfilebackend.cpp

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

示例3: authority

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

示例4: getRedirect

QString MybbFeedRequest::getRedirect(const QNetworkReply *reply) {
    QString redirect = QString::fromUtf8(reply->rawHeader("Location"));

    if ((!redirect.isEmpty()) && (!redirect.startsWith("http"))) {
        const QUrl url = reply->url();
        
        if (redirect.startsWith("/")) {
            redirect.prepend(url.scheme() + "://" + url.authority());
        }
        else {
            redirect.prepend(url.scheme() + "://" + url.authority() + "/");
        }
    }
    
    return redirect;
}
开发者ID:marxoft,项目名称:cutenews,代码行数:16,代码来源:mybbfeedrequest.cpp

示例5: handleUrl

bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
    if (lookupUrl.scheme() == HIFI_URL_SCHEME) {

        qCDebug(networking) << "Trying to go to URL" << lookupUrl.toString();

        DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::LookupAddress);

        // there are 4 possible lookup strings

        // 1. global place name (name of domain or place) - example: sanfrancisco
        // 2. user name (prepended with @) - example: @philip
        // 3. location string (posX,posY,posZ/eulerX,eulerY,eulerZ)
        // 4. domain network address (IP or dns resolvable hostname)

        // use our regex'ed helpers to figure out what we're supposed to do with this
        if (!handleUsername(lookupUrl.authority())) {
            // we're assuming this is either a network address or global place name
            // check if it is a network address first
            bool hostChanged;
            if (handleNetworkAddress(lookupUrl.host()
                                      + (lookupUrl.port() == -1 ? "" : ":" + QString::number(lookupUrl.port())), trigger, hostChanged)) {

                // If the host changed then we have already saved to history
                if (hostChanged) {
                    trigger = Internal;
                }

                // if we were not passed a path, use the index path
                auto path = lookupUrl.path();
                if (path.isEmpty()) {
                    path = INDEX_PATH;
                }

                // we may have a path that defines a relative viewpoint - if so we should jump to that now
                handlePath(path, trigger);
            } else if (handleDomainID(lookupUrl.host())){
                // no place name - this is probably a domain ID
                // try to look up the domain ID on the metaverse API
                attemptDomainIDLookup(lookupUrl.host(), lookupUrl.path(), trigger);
            } else {
                // wasn't an address - lookup the place name
                // we may have a path that defines a relative viewpoint - pass that through the lookup so we can go to it after
                attemptPlaceNameLookup(lookupUrl.host(), lookupUrl.path(), trigger);
            }
        }

        return true;

    } else if (lookupUrl.toString().startsWith('/')) {
        qCDebug(networking) << "Going to relative path" << lookupUrl.path();

        // if this is a relative path then handle it as a relative viewpoint
        handlePath(lookupUrl.path(), trigger, true);
        emit lookupResultsFinished();
        return true;
    }

    return false;
}
开发者ID:PhilipRosedale,项目名称:hifi,代码行数:59,代码来源:AddressManager.cpp

示例6: linkClickedFinished

void SidebarPrivate::linkClickedFinished()
{
    QNetworkReply * reply = static_cast< QNetworkReply * >(sender());

    QString target = reply->property("__target").toString();
    QVariant redirectsVariant = reply->property("__redirects");
    int redirects = redirectsVariant.isNull() ? 20 : redirectsVariant.toInt();

    // Redirect?
    QUrl redirectedUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
    if (redirectedUrl.isValid())
    {
        if (redirectedUrl.isRelative())
        {
            QUrl oldUrl = reply->url();
            redirectedUrl.setScheme(oldUrl.scheme());
            redirectedUrl.setAuthority(oldUrl.authority());
        }
        if (redirects > 0)
        {
            QNetworkRequest request = reply->request();
            request.setUrl(redirectedUrl);
            QNetworkReply * reply = networkAccessManager()->get(request);
            reply->setProperty("__target", target);
            connect(reply, SIGNAL(finished()), this, SLOT(linkClickedFinished()));
        }
        else
        {
            // TOO MANY REDIRECTS
        }
        reply->deleteLater();
        return;
    }

    // Check headers... if PDF then launch a new window, otherwise give it to the OS
    QString contentType(reply->header(QNetworkRequest::ContentTypeHeader).toString());
    if (contentType.contains("application/pdf")) {
        emit urlRequested(reply->request().url(), "tab");
    } else {
        QUrl href(reply->request().url());
        if (href.isValid()) {
            if (href.scheme() == "http" || href.scheme() == "https") {
                if (target == "sidebar") {
                    webView->setUrl(href);
                    slideLayout->push("web");
                    return;
                }
            }

            QDesktopServices::openUrl(href);
        }
        // FIXME error
    }

    reply->deleteLater();
}
开发者ID:project-renard-survey,项目名称:utopia-documents-mirror,代码行数:56,代码来源:sidebar.cpp

示例7: setBaseUrl

void Shotgun::setBaseUrl(const QUrl url)
{
    if (m_baseUrl != url) {
        m_baseUrl = url;
        m_config.apiUrl.setScheme(url.scheme());
        m_config.apiUrl.setHost(url.host());
        m_config.apiUrl.setPath(url.path() + "/" + m_config.apiVer + "/json");

        m_config.authorization = QString("Basic " + url.authority()).toUtf8().toBase64();
        emit baseUrlChanged(m_baseUrl);
    }
}
开发者ID:mjmvisser,项目名称:pug,代码行数:12,代码来源:shotgun.cpp

示例8: init

bool Folder::init()
{
    Account *account = AccountManager::instance()->account();
    if (!account) {
        // Normaly this should not happen, but it could be that there is something
        // wrong with the config and it is better not to crash.
        qWarning() << "WRN: No account  configured, can't sync";
        return false;
    }

    // We need to reconstruct the url because the path need to be fully decoded, as csync will  re-encode the path:
    //  Remember that csync will just append the filename to the path and pass it to the vio plugin.
    //  csync_owncloud will then re-encode everything.
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    QUrl url = remoteUrl();
    QString url_string = url.scheme() + QLatin1String("://") + url.authority(QUrl::EncodeDelimiters) + url.path(QUrl::FullyDecoded);
#else
    // Qt4 was broken anyway as it did not encode the '#' as it should have done  (it was actually a provlem when parsing the path from QUrl::setPath
    QString url_string = remoteUrl().toString();
#endif
    url_string = Utility::toCSyncScheme(url_string);

    QString localpath = path();

    if( csync_create( &_csync_ctx, localpath.toUtf8().data(), url_string.toUtf8().data() ) < 0 ) {
        qDebug() << "Unable to create csync-context!";
        slotSyncError(tr("Unable to create csync-context"));
        _csync_ctx = 0;
    } else {
        csync_set_log_callback( csyncLogCatcher );
        csync_set_log_level( 11 );

        if (Account *account = AccountManager::instance()->account()) {
            account->credentials()->syncContextPreInit(_csync_ctx);
        } else {
            qDebug() << Q_FUNC_INFO << "No default Account object, huh?";
        }

        if( csync_init( _csync_ctx ) < 0 ) {
            qDebug() << "Could not initialize csync!" << csync_get_status(_csync_ctx) << csync_get_status_string(_csync_ctx);
            QString errStr = SyncEngine::csyncErrorToString(CSYNC_STATUS(csync_get_status(_csync_ctx)));
            const char *errMsg = csync_get_status_string(_csync_ctx);
            if( errMsg ) {
                errStr += QLatin1String("<br/>");
                errStr += QString::fromUtf8(errMsg);
            }
            slotSyncError(errStr);
            csync_destroy(_csync_ctx);
            _csync_ctx = 0;
        }
    }
    return _csync_ctx;
}
开发者ID:roeslpa,项目名称:ocClientWinLnx,代码行数:53,代码来源:folder.cpp

示例9: findDevice

void DeviceFinder::findDevice(const QUrl &descriptionDocumentURL)
{
    if (m_searching) {
        qDebug() << "DeviceFinder: already searching";

        return;
    }

    m_baseURL.clear();
    m_baseURL.setScheme(descriptionDocumentURL.scheme());
    m_baseURL.setAuthority(descriptionDocumentURL.authority());
    m_networkAccess.get(QNetworkRequest(descriptionDocumentURL));
}
开发者ID:flimberger,项目名称:igdmon,代码行数:13,代码来源:DeviceFinder.cpp

示例10: downloadFiles

void Downloader::downloadFiles() {
	this->statusLabelText = "";
	this->downloadFailures = 0;
	this->downloadSuccesses = 0;
	this->downloadAborts = 0;

	for (unsigned int i = 0; i < urlLineEditVector.size(); ++i) {
		QUrl url = QUrl(urlLineEditVector.at(i)->text());
		QString fullUrlString = url.scheme() + "://" + url.authority()
				+ url.path();

		DEBUG("url : " << fullUrlString.toStdString().c_str());
		DEBUG("savePaths->at(" << i << ") : "	<< savePaths->at(i).toStdString().c_str());

		if (!this->silent) {
			DEBUG(QObject::tr("Downloading %1").arg(fullUrlString).toStdString().c_str());
			DEBUG(QObject::tr("Saving to %1").arg(this->savePaths->at(i)).toStdString().c_str());
		}

		this->httpClients.at(i) = new HttpWindow(this, url, this->savePaths->at(i));
		this->httpClients.at(i)->exec();

		if (this->httpClients.at(i)->downloadSuccessful()) {
			this->downloadSuccesses++;
			DEBUG(tr("Download of %1 succeded.").arg(QFileInfo(this->savePaths->at(i)).fileName()).toStdString());
			if (!this->silent) {
				//LOG(INFO, tr("Scaricato %1").arg(QFileInfo(this->savePaths->at(i)).fileName()));
			}

		} else if(this->httpClients.at(i)->aborted()) {
			this->downloadAborts++;
			DEBUG(tr("Download of %1 aborted.").arg(QFileInfo(this->savePaths->at(i)).fileName()).toStdString());
			LOG(WARN, tr("Scaricamento di %1 interrotto.").arg(QFileInfo(this->savePaths->at(i)).fileName()));
		} else {
			this->downloadFailures++;
			DEBUG(tr("Download of %1 failed.").arg(QFileInfo(this->savePaths->at(i)).fileName()).toStdString());
			LOG(ERR, tr("Scaricamento di %1 fallito.").arg(QFileInfo(this->savePaths->at(i)).fileName()));
		}

		DEBUG(tr("Download successes : %1").arg(my::toQString<unsigned int>(this->downloadSuccesses)).toStdString().c_str());
		DEBUG(tr("Download failures : %1").arg(my::toQString<unsigned int>(this->downloadFailures)).toStdString().c_str());

		if (this->downloadSuccesses == this->savePaths->size()) {
			this->close();
		} else {
			/*
			 * TODO
			 */
		}
	}
}
开发者ID:wdastru,项目名称:FantaCalcGui,代码行数:51,代码来源:Downloader.cpp

示例11: QProgressDialog

HttpWindow::HttpWindow(QWidget *parent, QUrl _url, QString _savePath) :
		QDialog(parent) {

	this->setFont(THE_REPO->fontVariableWidthSmall);
	this->fullUrlString = _url.scheme() + "://" + _url.authority()
	+ _url.path();
	this->downloadSuccess = false;
	this->uploadFlag = false;
	this->savePath = _savePath;
	progressDialog = new QProgressDialog(this);

	connect(&qnam,
			SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
			this,
			SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));

	connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload()));

	this->downloadFile();
}
开发者ID:,项目名称:,代码行数:20,代码来源:

示例12: init

bool Folder::init()
{
    // We need to reconstruct the url because the path needs to be fully decoded, as csync will re-encode the path:
    //  Remember that csync will just append the filename to the path and pass it to the vio plugin.
    //  csync_owncloud will then re-encode everything.
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    QUrl url = remoteUrl();
    QString url_string = url.scheme() + QLatin1String("://") + url.authority(QUrl::EncodeDelimiters) + url.path(QUrl::FullyDecoded);
#else
    // Qt4 was broken anyway as it did not encode the '#' as it should have done  (it was actually a problem when parsing the path from QUrl::setPath
    QString url_string = remoteUrl().toString();
#endif
    url_string = Utility::toCSyncScheme(url_string);

    QString localpath = path();

    if( csync_create( &_csync_ctx, localpath.toUtf8().data(), url_string.toUtf8().data() ) < 0 ) {
        qDebug() << "Unable to create csync-context!";
        slotSyncError(tr("Unable to create csync-context"));
        _csync_ctx = 0;
    } else {
        csync_set_log_callback( csyncLogCatcher );
        csync_set_log_level( Logger::instance()->isNoop() ? 0 : 11 );

        Q_ASSERT( _accountState );

        if( csync_init( _csync_ctx ) < 0 ) {
            qDebug() << "Could not initialize csync!" << csync_get_status(_csync_ctx) << csync_get_status_string(_csync_ctx);
            QString errStr = SyncEngine::csyncErrorToString(CSYNC_STATUS(csync_get_status(_csync_ctx)));
            const char *errMsg = csync_get_status_string(_csync_ctx);
            if( errMsg ) {
                errStr += QLatin1String("<br/>");
                errStr += QString::fromUtf8(errMsg);
            }
            slotSyncError(errStr);
            csync_destroy(_csync_ctx);
            _csync_ctx = 0;
        }
    }
    return _csync_ctx;
}
开发者ID:stonerl,项目名称:client,代码行数:41,代码来源:folder.cpp

示例13: handleUrl

bool AddressManager::handleUrl(const QUrl& lookupUrl) {
    if (lookupUrl.scheme() == HIFI_URL_SCHEME) {
        
        qDebug() << "Trying to go to URL" << lookupUrl.toString();
        
        // there are 4 possible lookup strings
        
        // 1. global place name (name of domain or place) - example: sanfrancisco
        // 2. user name (prepended with @) - example: @philip
        // 3. location string (posX,posY,posZ/eulerX,eulerY,eulerZ)
        // 4. domain network address (IP or dns resolvable hostname)
        
        // use our regex'ed helpers to figure out what we're supposed to do with this
        if (!handleUsername(lookupUrl.authority())) {
            // we're assuming this is either a network address or global place name
            // check if it is a network address first
            if (handleNetworkAddress(lookupUrl.host()
                                      + (lookupUrl.port() == -1 ? "" : ":" + QString::number(lookupUrl.port())))) {
                // we may have a path that defines a relative viewpoint - if so we should jump to that now
                handleRelativeViewpoint(lookupUrl.path());
            } else {
                // wasn't an address - lookup the place name
                // we may have a path that defines a relative viewpoint - pass that through the lookup so we can go to it after
                attemptPlaceNameLookup(lookupUrl.host(), lookupUrl.path());
                
            }
        }
        
        return true;
    } else if (lookupUrl.toString().startsWith('/')) {
        qDebug() << "Going to relative path" << lookupUrl.path();
        
        // if this is a relative path then handle it as a relative viewpoint
        handleRelativeViewpoint(lookupUrl.path());
        emit lookupResultsFinished();
    }
    
    return false;
}
开发者ID:gfcprogramer,项目名称:hifi,代码行数:39,代码来源:AddressManager.cpp

示例14: fi

QT_BEGIN_NAMESPACE

QNetworkAccessBackend *
QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op,
                                         const QNetworkRequest &request) const
{
    // is it an operation we know of?
    switch (op) {
    case QNetworkAccessManager::GetOperation:
    case QNetworkAccessManager::PutOperation:
        break;

    default:
        // no, we can't handle this operation
        return 0;
    }

    QUrl url = request.url();
    if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0 || url.isLocalFile()) {
        return new QNetworkAccessFileBackend;
    } else if (!url.isEmpty() && url.authority().isEmpty()) {
        // check if QFile could, in theory, open this URL via the file engines
        // it has to be in the format:
        //    prefix:path/to/file
        // or prefix:/path/to/file
        //
        // this construct here must match the one below in open()
        QFileInfo fi(url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery));
        // On Windows and Symbian the drive letter is detected as the scheme.
        if (fi.exists() && (url.scheme().isEmpty() || (url.scheme().length() == 1)))
            qWarning("QNetworkAccessFileBackendFactory: URL has no schema set, use file:// for files");
        if (fi.exists() || (op == QNetworkAccessManager::PutOperation && fi.dir().exists()))
            return new QNetworkAccessFileBackend;
    }

    return 0;
}
开发者ID:Suneal,项目名称:qt,代码行数:37,代码来源:qnetworkaccessfilebackend.cpp

示例15: fi

QNetworkAccessBackend *
QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op,
        const QNetworkRequest &request) const
{
    // is it an operation we know of?
    switch (op) {
    case QNetworkAccessManager::GetOperation:
    case QNetworkAccessManager::PutOperation:
        break;

    default:
        // no, we can't handle this operation
        return 0;
    }

    QUrl url = request.url();
    if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0
#if defined(Q_OS_ANDROID)
            || url.scheme().compare(QLatin1String("assets"), Qt::CaseInsensitive) == 0
#endif
            || url.isLocalFile()) {
        return new QNetworkAccessFileBackend;
    } else if (!url.scheme().isEmpty() && url.authority().isEmpty() && (url.scheme().length() > 1)) {
        // check if QFile could, in theory, open this URL via the file engines
        // it has to be in the format:
        //    prefix:path/to/file
        // or prefix:/path/to/file
        //
        // this construct here must match the one below in open()
        QFileInfo fi(url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery));
        if (fi.exists() || (op == QNetworkAccessManager::PutOperation && fi.dir().exists()))
            return new QNetworkAccessFileBackend;
    }

    return 0;
}
开发者ID:lifeIsGame,项目名称:phantomjs,代码行数:36,代码来源:qnetworkaccessfilebackend.cpp


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