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


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

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


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

示例1: QgsVectorLayer

QgsVectorLayer *QgsMimeDataUtils::Uri::vectorLayer( bool &owner, QString &error ) const
{
  owner = false;
  if ( layerType != QLatin1String( "vector" ) )
  {
    error = QObject::tr( "%1: Not a vector layer." ).arg( name );
    return nullptr;
  }
  if ( providerKey == QLatin1String( "memory" ) )
  {
    QUrl url = QUrl::fromEncoded( uri.toUtf8() );
    if ( !url.hasQueryItem( QStringLiteral( "pid" ) ) || !url.hasQueryItem( QStringLiteral( "layerid" ) ) )
    {
      error = QObject::tr( "Memory layer uri does not contain process or layer id." );
      return nullptr;
    }
    qint64 pid = url.queryItemValue( QStringLiteral( "pid" ) ).toLongLong();
    if ( pid != QCoreApplication::applicationPid() )
    {
      error = QObject::tr( "Memory layer from another QGIS instance." );
      return nullptr;
    }
    QString layerId = url.queryItemValue( QStringLiteral( "layerid" ) );
    QgsVectorLayer *vectorLayer = QgsProject::instance()->mapLayer<QgsVectorLayer *>( layerId );
    if ( !vectorLayer )
    {
      error = QObject::tr( "Cannot get memory layer." );
      return nullptr;
    }
    return vectorLayer;
  }
  owner = true;
  return new QgsVectorLayer( uri, name, providerKey );
}
开发者ID:jonnyforestGIS,项目名称:QGIS,代码行数:34,代码来源:qgsmimedatautils.cpp

示例2: if

bool
GlobalActionManager::handlePlaylistCommand( const QUrl& url )
{
    QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command
    if ( parts.isEmpty() )
    {
        tLog() << "No specific playlist command:" << url.toString();
        return false;
    }

    if ( parts[ 0 ] == "import" )
    {
        if ( !url.hasQueryItem( "xspf" ) && !url.hasQueryItem( "jspf") )
        {
            tDebug() << "No xspf or jspf to load...";
            return false;
        }
        if ( url.hasQueryItem( "xspf") )
        {
            QUrl xspf = QUrl::fromUserInput( url.queryItemValue( "xspf" ) );
            QString title =  url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString();
            XSPFLoader* l= new XSPFLoader( true, this );
            l->setOverrideTitle( title );
            l->load( xspf );
            connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
        }
        else if ( url.hasQueryItem( "jspf" ) )
        {
            QUrl jspf = QUrl::fromUserInput( url.queryItemValue( "jspf" ) );
            QString title =  url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString();
            JSPFLoader* l= new JSPFLoader( true, this );
            l->setOverrideTitle( title );
            l->load( jspf );
            connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
        }
    }
    else if ( parts [ 0 ] == "new" )
    {
        if ( !url.hasQueryItem( "title" ) )
        {
            tLog() << "New playlist command needs a title...";
            return false;
        }
        playlist_ptr pl = Playlist::create( SourceList::instance()->getLocal(), uuid(), url.queryItemValue( "title" ), QString(), QString(), false );
        ViewManager::instance()->show( pl );
    }
    else if ( parts[ 0 ] == "add" )
    {
        if ( !url.hasQueryItem( "playlistid" ) || !url.hasQueryItem( "title" ) || !url.hasQueryItem( "artist" ) )
        {
            tLog() << "Add to playlist command needs playlistid, track, and artist..." << url.toString();
            return false;
        }
        // TODO implement. Let the user select what playlist to add to
        return false;
    }

    return false;
}
开发者ID:mguentner,项目名称:tomahawk,代码行数:59,代码来源:GlobalActionManager.cpp

示例3: buildRequest

QNetworkRequest RequestPrivate::buildRequest(QUrl u, bool authRequired) {
    if (authRequired) {
#if QT_VERSION >= 0x050000
        QUrlQuery query(u);
    
        if ((!query.hasQueryItem("key")) && (!apiKey.isEmpty())) {
            query.addQueryItem("key", apiKey);
        }
    
        if ((!query.hasQueryItem("access_token")) && (!accessToken.isEmpty())) {
            query.addQueryItem("access_token", accessToken);
        }
    
        u.setQuery(query);
#else
        if ((!u.hasQueryItem("key")) && (!apiKey.isEmpty())) {
            u.addQueryItem("key", apiKey);
        }
    
        if ((!u.hasQueryItem("access_token")) && (!accessToken.isEmpty())) {
            u.addQueryItem("access_token", accessToken);
        }
#endif
    }
#ifdef QYOUTUBE_DEBUG
    qDebug() << "QYouTube::RequestPrivate::buildRequest" << u;
#endif
    QNetworkRequest request(u);
    
    switch (operation) {
    case Request::PostOperation:
    case Request::PutOperation:
        switch (data.type()) {
        case QVariant::Map:
        case QVariant::List:
        case QVariant::StringList:
            request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
            break;
        default:
            request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
            break;
        }
        
        break;
    default:
        break;
    }
    
    if (!headers.isEmpty()) {
        addRequestHeaders(&request, headers);
    }
    
    return request;
}
开发者ID:freemangordon,项目名称:qyoutube,代码行数:54,代码来源:request.cpp

示例4: if

bool
GlobalActionManager::handlePlaylistCommand( const QUrl& url )
{
    QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command
    if ( parts.isEmpty() )
    {
        tLog() << "No specific playlist command:" << url.toString();
        return false;
    }

    if ( parts[ 0 ] == "import" )
    {
        if ( !url.hasQueryItem( "xspf" ) && !url.hasQueryItem( "jspf") )
        {
            tDebug() << "No xspf or jspf to load...";
            return false;
        }
        if ( url.hasQueryItem( "xspf" ) )
        {
            createPlaylistFromUrl( "xspf", url.queryItemValue( "xspf" ), url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString() );
            return true;
        }
        else if ( url.hasQueryItem( "jspf" ) )
        {
            createPlaylistFromUrl( "jspf", url.queryItemValue( "jspf" ), url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString() );
            return true;
        }
    }
    else if ( parts [ 0 ] == "new" )
    {
        if ( !url.hasQueryItem( "title" ) )
        {
            tLog() << "New playlist command needs a title...";
            return false;
        }
        playlist_ptr pl = Playlist::create( SourceList::instance()->getLocal(), uuid(), url.queryItemValue( "title" ), QString(), QString(), false );
        ViewManager::instance()->show( pl );
    }
    else if ( parts[ 0 ] == "add" )
    {
        if ( !url.hasQueryItem( "playlistid" ) || !url.hasQueryItem( "title" ) || !url.hasQueryItem( "artist" ) )
        {
            tLog() << "Add to playlist command needs playlistid, track, and artist..." << url.toString();
            return false;
        }
        // TODO implement. Let the user select what playlist to add to
        return false;
    }

    return false;
}
开发者ID:creichert,项目名称:tomahawk,代码行数:51,代码来源:GlobalActionManager.cpp

示例5: checkUrl

void SoundCloud::checkUrl(const QUrl &webUrl) {
    QUrl url;

    if (webUrl.hasQueryItem("client_id")) {
        url = webUrl;
        url.setHost("api.soundcloud.com");
    }
    else {
        url.setUrl("http://api.soundcloud.com/resolve.json");
#if QT_VERSION >= 0x050000
        QUrlQuery query(url);
        query.addQueryItem("url", webUrl.toString());
        query.addQueryItem("client_id", CLIENT_ID);
        url.setQuery(query);
#else
        url.addQueryItem("url", webUrl.toString());
        url.addQueryItem("client_id", CLIENT_ID);
#endif
    }

    QNetworkRequest request(url);
    QNetworkReply *reply = this->networkAccessManager()->get(request);
    this->connect(reply, SIGNAL(finished()), this, SLOT(checkUrlIsValid()));
    this->connect(this, SIGNAL(currentOperationCancelled()), reply, SLOT(deleteLater()));
}
开发者ID:marxoft,项目名称:qdl,代码行数:25,代码来源:soundcloud.cpp

示例6: hasQueryItem

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

示例7: hasQueryItem

int Url::hasQueryItem ( lua_State * L )// ( const QString & key ) const : bool
{
	QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 );
	//QString* key = ValueInstaller2<QString>::check( L, 2 );
	Util::push( L, lhs->hasQueryItem( Util::toString( L, 2 ) ) );
	return 1;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:7,代码来源:QtlUrl.cpp

示例8: checkUrl

void MegaShares::checkUrl(const QUrl &webUrl) {
    QNetworkRequest request;
#if QT_VERSION >= 0x050000
    QUrlQuery query(webUrl);
    
    if (query.hasQueryItem("d01")) {
        m_fileName = query.queryItemValue("d01");
        request.setUrl(webUrl);
    }
#else
    if (webUrl.hasQueryItem("d01")) {
        m_fileName = webUrl.queryItemValue("d01");
        request.setUrl(webUrl);
    }
#endif
    else {
        QString urlString = webUrl.toString();
        m_fileName = urlString.section('/', -1);
        QString id = urlString.section("/dl/", 1, 1).section('/', 0, 0);
        request.setUrl(QUrl("http://d01.megashares.com/?d01=" + id));
    }

    request.setRawHeader("Accept-Language", "en-GB,en-US;q=0.8,en;q=0.6");
    QNetworkReply *reply = this->networkAccessManager()->get(request);
    this->connect(reply, SIGNAL(finished()), this, SLOT(checkUrlIsValid()));
    this->connect(this, SIGNAL(currentOperationCancelled()), reply, SLOT(deleteLater()));
}
开发者ID:marxoft,项目名称:qdl,代码行数:27,代码来源:megashares.cpp

示例9: urlHasQueryItem

bool UTIL::urlHasQueryItem( const QUrl& url, const QString& key )
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
    return QUrlQuery( url ).hasQueryItem( key );
#else
    return url.hasQueryItem( key );
#endif
}
开发者ID:kehugter,项目名称:Yarock,代码行数:8,代码来源:utilities.cpp

示例10: respond

bool QXmppSaslClientFacebook::respond(const QByteArray &challenge, QByteArray &response)
{
    if (m_step == 0) {
        // no initial response
        response = QByteArray();
        m_step++;
        return true;
    } else if (m_step == 1) {
        // parse request
#if QT_VERSION >= 0x050000
        QUrlQuery requestUrl(challenge);
#else
        QUrl requestUrl;
        requestUrl.setEncodedQuery(challenge);
#endif
        if (!requestUrl.hasQueryItem("method") || !requestUrl.hasQueryItem("nonce")) {
            warning("QXmppSaslClientFacebook : Invalid challenge, nonce or method missing");
            return false;
        }

        // build response
#if QT_VERSION >= 0x050000
        QUrlQuery responseUrl;
#else
        QUrl responseUrl;
#endif
        responseUrl.addQueryItem("access_token", password());
        responseUrl.addQueryItem("api_key", username());
        responseUrl.addQueryItem("call_id", 0);
        responseUrl.addQueryItem("method", requestUrl.queryItemValue("method"));
        responseUrl.addQueryItem("nonce", requestUrl.queryItemValue("nonce"));
        responseUrl.addQueryItem("v", "1.0");

#if QT_VERSION >= 0x050000
        response = responseUrl.query().toUtf8();
#else
        response = responseUrl.encodedQuery();
#endif
        m_step++;
        return true;
    } else {
        warning("QXmppSaslClientFacebook : Invalid step");
        return false;
    }
}
开发者ID:Lerentis,项目名称:qxmpp,代码行数:45,代码来源:QXmppSasl.cpp

示例11: qurl

int 
QDjViewOutline::pageNumber(const char *link)
{
  if (link && link[0] == '#')
    return djview->pageNumber(QString::fromUtf8(link+1));
  if (link == 0 || link[0] != '?')
    return -1;
  QByteArray burl = QByteArray("http://f/f") + link;
#if QT_VERSION >= 0x50000
  QUrlQuery qurl(QUrl::fromEncoded(burl));
#else
  QUrl qurl = QUrl::fromEncoded(burl);
#endif
  if (qurl.hasQueryItem("page"))
    return djview->pageNumber(qurl.queryItemValue("page"));
  else if (qurl.hasQueryItem("pageno"))
    return djview->pageNumber("$" + qurl.queryItemValue("pageno"));
  return -1;
}
开发者ID:Distrotech,项目名称:djview4,代码行数:19,代码来源:qdjviewsidebar.cpp

示例12: startHandleRequest

	void startHandleRequest(ZhttpRequest *req, int basePathStart, const QByteArray &asPath, const DomainMap::Entry &route)
	{
		Session *s = new Session(this);
		s->req = req;

		QUrl uri = req->requestUri();

		QByteArray encPath = uri.encodedPath();
		s->path = encPath.mid(basePathStart);

		QList<QByteArray> parts = s->path.split('/');
		if(!parts.isEmpty() && parts.last().startsWith("jsonp"))
		{
			if(uri.hasQueryItem("callback"))
			{
				s->jsonpCallback = uri.queryItemValue("callback").toUtf8();
				uri.removeAllQueryItems("callback");
			}
			else if(uri.hasQueryItem("c"))
			{
				s->jsonpCallback = uri.queryItemValue("c").toUtf8();
				uri.removeAllQueryItems("c");
			}
		}

		s->asUri = uri;
		s->asUri.setScheme((s->asUri.scheme() == "https") ? "wss" : "ws");
		if(!asPath.isEmpty())
			s->asUri.setEncodedPath(asPath);
		else
			s->asUri.setEncodedPath(encPath.mid(0, basePathStart));

		s->route = route;

		connect(req, SIGNAL(readyRead()), SLOT(req_readyRead()));
		connect(req, SIGNAL(bytesWritten(int)), SLOT(req_bytesWritten(int)));
		connect(req, SIGNAL(error()), SLOT(req_error()));

		sessions += s;
		sessionsByRequest.insert(s->req, s);

		processRequestInput(s);
	}
开发者ID:aedrish,项目名称:projecten_server1,代码行数:43,代码来源:sockjsmanager.cpp

示例13: openUrlFile

void LiteDoc::openUrlFile(const QUrl &url)
{
    QFileInfo info(url.toLocalFile());
    if (!info.exists()) {
        info.setFile(url.path());
    }
    QString ext = info.suffix().toLower();
    if (ext == "html") {
        QFile file(info.filePath());
        if (file.open(QIODevice::ReadOnly)) {
            QByteArray ba = file.readAll();
            file.close();
            if (info.fileName().compare("docs.html",Qt::CaseInsensitive) == 0) {
                updateHtmlDoc(url,ba,QString(),false);
            } else {
                updateHtmlDoc(url,ba);
            }
        }
    } else if (ext == "md") {
        QFile file(info.filePath());
        if (file.open(QIODevice::ReadOnly)) {
            QByteArray ba = mdtohtml(file.readAll());
            updateHtmlDoc(url,ba);
        }
    } else if (ext == "go") {
        LiteApi::IEditor *editor = m_liteApp->fileManager()->openEditor(info.filePath());
        if (editor) {
            editor->setReadOnly(true);
            QPlainTextEdit *ed = LiteApi::findExtensionObject<QPlainTextEdit*>(editor,"LiteApi.QPlainTextEdit");
            if (ed && url.hasQueryItem("s")) {
                QStringList pos = url.queryItemValue("s").split(":");
                if (pos.length() == 2) {
                    bool ok = false;
                    int begin = pos.at(0).toInt(&ok);
                    if (ok) {
                        QTextCursor cur = ed->textCursor();
                        cur.setPosition(begin);
                        ed->setTextCursor(cur);
                        ed->centerCursor();
                    }
                }
            }
        }
    } else if (ext == "pdf") {
        QDesktopServices::openUrl(info.filePath());
    } else {
        QFile file(info.filePath());
        if (file.open(QIODevice::ReadOnly)) {
            QByteArray ba = file.readAll();
            updateTextDoc(url,ba,info.fileName());
        }
    }
}
开发者ID:screscent,项目名称:liteide,代码行数:53,代码来源:litedoc.cpp

示例14: downloadUrl

QUrl WmsServerLayout::downloadUrl( const QUrl &prototypeUrl, const Marble::TileId &tileId ) const
{
    GeoDataLatLonBox box = tileId.toLatLonBox( m_textureLayer );

#if QT_VERSION < 0x050000
    QUrl url = prototypeUrl;
#else
    QUrlQuery url(prototypeUrl.query());
#endif
    url.addQueryItem( "service", "WMS" );
    url.addQueryItem( "request", "GetMap" );
    url.addQueryItem( "version", "1.1.1" );
    if ( !url.hasQueryItem( "styles" ) )
        url.addQueryItem( "styles", "" );
    if ( !url.hasQueryItem( "format" ) ) {
        if ( m_textureLayer->fileFormat().toLower() == "jpg" )
            url.addQueryItem( "format", "image/jpeg" );
        else
            url.addQueryItem( "format", "image/" + m_textureLayer->fileFormat().toLower() );
    }
    if ( !url.hasQueryItem( "srs" ) ) {
        url.addQueryItem( "srs", epsgCode() );
    }
    if ( !url.hasQueryItem( "layers" ) )
        url.addQueryItem( "layers", m_textureLayer->name() );
    url.addQueryItem( "width", QString::number( m_textureLayer->tileSize().width() ) );
    url.addQueryItem( "height", QString::number( m_textureLayer->tileSize().height() ) );
    url.addQueryItem( "bbox", QString( "%1,%2,%3,%4" ).arg( QString::number( box.west( GeoDataCoordinates::Degree ), 'f', 12 ) )
                                                      .arg( QString::number( box.south( GeoDataCoordinates::Degree ), 'f', 12 ) )
                                                      .arg( QString::number( box.east( GeoDataCoordinates::Degree ), 'f', 12 ) )
                                                      .arg( QString::number( box.north( GeoDataCoordinates::Degree ), 'f', 12 ) ) );
#if QT_VERSION < 0x050000
    return url;
#else
    QUrl finalUrl = prototypeUrl;
    finalUrl.setQuery(url);
    return finalUrl;
#endif
}
开发者ID:abhgangwar,项目名称:marble,代码行数:39,代码来源:ServerLayout.cpp

示例15: onUrlChanged

void WebView::onUrlChanged(const QUrl &u) {
#ifdef QSOUNDCLOUD_DEBUG
    qDebug() << "WebView::onUrlChanged" << u;
#endif
#if QT_VERSION >= 0x050000
    QUrlQuery query(u);
    
    if (query.hasQueryItem("code")) {
        request.exchangeCodeForAccessToken(query.queryItemValue("code"));
    }
#else
    if (u.hasQueryItem("code")) {
        request.exchangeCodeForAccessToken(u.queryItemValue("code"));
    }
#endif
}
开发者ID:lukedirtwalker,项目名称:qsoundcloud,代码行数:16,代码来源:webview.cpp


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