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


C++ QUrlQuery::queryItems方法代码示例

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


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

示例1: setQueryItems

void tst_QUrlQuery::setQueryItems()
{
    QFETCH(QueryItems, items);
    QUrlQuery query;

    QueryItems::const_iterator it = items.constBegin();
    for ( ; it != items.constEnd(); ++it)
        query.addQueryItem(it->first, it->second);
    COMPARE_ITEMS(query.queryItems(), items);

    query.clear();

    query.setQueryItems(items);
    COMPARE_ITEMS(query.queryItems(), items);
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:15,代码来源:tst_qurlquery.cpp

示例2: findStationsByName

void ParserResRobot::findStationsByName(const QString &stationName)
{
    lastStationSearch = stationName;
    if (stationName.length() < 2)
        return;
    if (currentRequestState != FahrplanNS::noneRequest)
        return;
    currentRequestState = FahrplanNS::stationsByNameRequest;

    QUrl url(journeyBaseURL + QLatin1String("FindLocation.json"));
#if defined(BUILD_FOR_QT5)
    QUrlQuery query;
#else
    QUrl query;
#endif
    query.addQueryItem("key", journeyAPIKey);
    query.addQueryItem("apiVersion", journeyAPIVersion);
    query.addQueryItem("from", stationName);
    query.addQueryItem("coordSys", "WGS84");
#if defined(BUILD_FOR_QT5)
    url.setQuery(query);
#else
    url.setQueryItems(query.queryItems());
#endif
    sendHttpRequest(url);
}
开发者ID:412b,项目名称:fahrplan,代码行数:26,代码来源:parser_resrobot.cpp

示例3: getTimeTableForStation

void ParserXmlVasttrafikSe::getTimeTableForStation(const Station &currentStation, const Station &, const QDateTime &dateTime, Mode mode, int)
{
    if (currentRequestState != FahrplanNS::noneRequest)
        return;
    currentRequestState = FahrplanNS::getTimeTableForStationRequest;

    m_timeTableForStationParameters.isValid = false;

    QUrl uri(baseRestUrl + (mode == Departure ? QLatin1String("departureBoard") : QLatin1String("arrivalBoard")));

#if defined(BUILD_FOR_QT5)
    QUrlQuery query;
#else
    QUrl query;
#endif
    query.addQueryItem("authKey", apiKey);
    query.addQueryItem("format", "xml");
    query.addQueryItem("date", dateTime.toString("yyyy-MM-dd"));
    query.addQueryItem("time", dateTime.toString("hh:mm"));
    query.addQueryItem("id", currentStation.id.toString());
    query.addQueryItem("useVas", "1");
    query.addQueryItem("useLDTrain", "0");
    query.addQueryItem("useRegTrain", "1");
    query.addQueryItem("useBus", "1");
    query.addQueryItem("useBoat", "1");
    query.addQueryItem("useTram", "1");
    query.addQueryItem("excludeDR", "1");
#if defined(BUILD_FOR_QT5)
    uri.setQuery(query);
#else
    uri.setQueryItems(query.queryItems());
#endif
    sendHttpRequest(uri);
}
开发者ID:evansebire,项目名称:fahrplan,代码行数:34,代码来源:parser_xmlvasttrafikse.cpp

示例4: findStationsByCoordinates

void ParserResRobot::findStationsByCoordinates(qreal longitude, qreal latitude)
{
    if (currentRequestState != FahrplanNS::noneRequest)
        return;
    currentRequestState = FahrplanNS::stationsByCoordinatesRequest;

    QUrl url(journeyBaseURL + QLatin1String("StationsInZone.json"));
#if defined(BUILD_FOR_QT5)
    QUrlQuery query;
#else
    QUrl query;
#endif
    query.addQueryItem("key", journeyAPIKey);
    query.addQueryItem("apiVersion", journeyAPIVersion);
    query.addQueryItem("centerX", QString::number(longitude));
    query.addQueryItem("centerY", QString::number(latitude));
    query.addQueryItem("radius", QString::number(nearbyRadius));
    query.addQueryItem("coordSys", "WGS84");
#if defined(BUILD_FOR_QT5)
    url.setQuery(query);
#else
    url.setQueryItems(query.queryItems());
#endif
    sendHttpRequest(url);
}
开发者ID:412b,项目名称:fahrplan,代码行数:25,代码来源:parser_resrobot.cpp

示例5: findStationsByCoordinates

void ParserXmlVasttrafikSe::findStationsByCoordinates(qreal longitude, qreal latitude)
{
    qDebug() << "ParserXmlVasttrafikSe::findStationsByCoordinates(longitude=" << longitude << ", latitude=" << latitude << ")";

    if (currentRequestState != FahrplanNS::noneRequest)
        return;
    currentRequestState = FahrplanNS::stationsByCoordinatesRequest;

    QUrl uri(baseRestUrl + QLatin1String("location.nearbystops"));
#if defined(BUILD_FOR_QT5)
    QUrlQuery query;
#else
    QUrl query;
#endif
    query.addQueryItem("authKey", apiKey);
    query.addQueryItem("format", "xml");
    query.addQueryItem("originCoordLat", QString::number(latitude));
    query.addQueryItem("originCoordLong", QString::number(longitude));
    query.addQueryItem("maxNo", QString::number(5));
#if defined(BUILD_FOR_QT5)
    uri.setQuery(query);
#else
    uri.setQueryItems(query.queryItems());
#endif
    sendHttpRequest(uri);
}
开发者ID:evansebire,项目名称:fahrplan,代码行数:26,代码来源:parser_xmlvasttrafikse.cpp

示例6: findStationsByName

void ParserResRobot::findStationsByName(const QString &stationName)
{
    lastStationSearch = stationName;
    if (stationName.length() < 2)
        return;
    if (currentRequestState != FahrplanNS::noneRequest)
        return;
    currentRequestState = FahrplanNS::stationsByNameRequest;

    QUrl url(baseURL + QLatin1String("/location.name"));
#if defined(BUILD_FOR_QT5)
    QUrlQuery query;
#else
    QUrl query;
#endif
    query.addQueryItem("key", journeyAPIKey);
    query.addQueryItem("input", stationName);
    query.addQueryItem("maxNo", "30"); // Max number of results
    if (QLocale().language() == QLocale::Swedish)
        query.addQueryItem("lang", "sv");
    else if (QLocale().language() == QLocale::German)
        query.addQueryItem("lang", "de");
    else
        query.addQueryItem("lang", "en");
    query.addQueryItem("format", "json");
#if defined(BUILD_FOR_QT5)
    url.setQuery(query);
#else
    url.setQueryItems(query.queryItems());
#endif
    sendHttpRequest(url);
}
开发者ID:leppa,项目名称:fahrplan,代码行数:32,代码来源:parser_resrobot.cpp

示例7: findStationsByCoordinates

void ParserResRobot::findStationsByCoordinates(qreal longitude, qreal latitude)
{
    if (currentRequestState != FahrplanNS::noneRequest)
        return;
    currentRequestState = FahrplanNS::stationsByCoordinatesRequest;

    QUrl url(baseURL + QLatin1String("/location.nearbystops"));
#if defined(BUILD_FOR_QT5)
    QUrlQuery query;
#else
    QUrl query;
#endif
    query.addQueryItem("key", journeyAPIKey);
    query.addQueryItem("originCoordLat", QString::number(latitude));
    query.addQueryItem("originCoordLong", QString::number(longitude));
    query.addQueryItem("r", "1000"); // Radius in meters
    query.addQueryItem("maxNo", "30"); // Max number of results
    if (QLocale().language() == QLocale::Swedish)
        query.addQueryItem("lang", "sv");
    else if (QLocale().language() == QLocale::German)
        query.addQueryItem("lang", "de");
    else
        query.addQueryItem("lang", "en");
    query.addQueryItem("format", "json");
#if defined(BUILD_FOR_QT5)
    url.setQuery(query);
#else
    url.setQueryItems(query.queryItems());
#endif
    sendHttpRequest(url);
}
开发者ID:leppa,项目名称:fahrplan,代码行数:31,代码来源:parser_resrobot.cpp

示例8: old_queryItems

void tst_QUrlQuery::old_queryItems()
{
    // test imported from old tst_qurl.cpp
    QUrlQuery url;

    QList<QPair<QString, QString> > newItems;
    newItems += qMakePair(QString("1"), QString("a"));
    newItems += qMakePair(QString("2"), QString("b"));
    newItems += qMakePair(QString("3"), QString("c"));
    newItems += qMakePair(QString("4"), QString("a b"));
    newItems += qMakePair(QString("5"), QString("&"));
    newItems += qMakePair(QString("foo bar"), QString("hello world"));
    newItems += qMakePair(QString("foo+bar"), QString("hello+world"));
    newItems += qMakePair(QString("tex"), QString("a + b = c"));
    url.setQueryItems(newItems);
    QVERIFY(!url.isEmpty());

    QList<QPair<QString, QString> > setItems = url.queryItems();
    QVERIFY(newItems == setItems);

    url.addQueryItem("1", "z");

#if 0
    // undefined behaviour in the new QUrlQuery

    QVERIFY(url.hasQueryItem("1"));
    QCOMPARE(url.queryItemValue("1").toLatin1().constData(), "a");

    url.addQueryItem("1", "zz");

    QStringList expected;
    expected += "a";
    expected += "z";
    expected += "zz";
    QCOMPARE(url.allQueryItemValues("1"), expected);

    url.removeQueryItem("1");
    QCOMPARE(url.allQueryItemValues("1").size(), 2);
    QCOMPARE(url.queryItemValue("1").toLatin1().constData(), "z");
#endif

    url.removeAllQueryItems("1");
    QVERIFY(!url.hasQueryItem("1"));

    QCOMPARE(url.queryItemValue("4").toLatin1().constData(), "a b");
    QCOMPARE(url.queryItemValue("5").toLatin1().constData(), "&");
    QCOMPARE(url.queryItemValue("tex").toLatin1().constData(), "a + b = c");
    QCOMPARE(url.queryItemValue("foo bar").toLatin1().constData(), "hello world");

    //url.setUrl("http://www.google.com/search?q=a+b");
    url.setQuery("q=a+b");
    QCOMPARE(url.queryItemValue("q"), QString("a+b"));

    //url.setUrl("http://www.google.com/search?q=a=b"); // invalid, but should be tolerated
    url.setQuery("q=a=b");
    QCOMPARE(url.queryItemValue("q"), QString("a=b"));
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:57,代码来源:tst_qurlquery.cpp

示例9: QUrlQuery

ServerRequest::ServerRequest(const QHttpRequest &req) : _request(req)
{
    _path = req.path();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 2)
    QUrlQuery query = QUrlQuery(req.url());
    _queryItems = query.queryItems();
#else
    _queryItems = req.url().queryItems();
#endif

    //TODO: parse principal
}
开发者ID:haseebshujja,项目名称:signalr-qt,代码行数:12,代码来源:ServerRequest.cpp

示例10: parseBitcoinURI

bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
{
    // return if URI is not valid or is no sapcoin URI
    if(!uri.isValid() || uri.scheme() != QString("sapcoin"))
        return false;

    SendCoinsRecipient rv;
    rv.address = uri.path();
    rv.amount = 0;
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
    QUrlQuery q;
    q.setQuery(uri.query());
    QList<QPair<QString, QString> > items = q.queryItems();
#else
    QList<QPair<QString, QString> > items = uri.queryItems();
#endif
    for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++)
    {
        bool fShouldReturnFalse = false;
        if (i->first.startsWith("req-"))
        {
            i->first.remove(0, 4);
            fShouldReturnFalse = true;
        }

        if (i->first == "label")
        {
            rv.label = i->second;
            fShouldReturnFalse = false;
        }
        else if (i->first == "amount")
        {
            if(!i->second.isEmpty())
            {
                if(!BitcoinUnits::parse(BitcoinUnits::SAP, i->second, &rv.amount))
                {
                    return false;
                }
            }
            fShouldReturnFalse = false;
        }

        if (fShouldReturnFalse)
            return false;
    }
    if(out)
    {
        *out = rv;
    }
    return true;
}
开发者ID:sapcoin,项目名称:sapcoin,代码行数:51,代码来源:guiutil.cpp

示例11: encodedSetQueryItems

void tst_QUrlQuery::encodedSetQueryItems()
{
    QFETCH(QString, key);
    QFETCH(QString, value);
    QFETCH(QString, expectedQuery);
    QFETCH(QString, expectedKey);
    QFETCH(QString, expectedValue);
    QFETCH(QUrl::ComponentFormattingOptions, encoding);
    QUrlQuery query;

    query.addQueryItem(key, value);
    COMPARE_ITEMS(query.queryItems(encoding), QueryItems() << qItem(expectedKey, expectedValue));
    QCOMPARE(query.query(encoding), expectedQuery);
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:14,代码来源:tst_qurlquery.cpp

示例12: getTimeTableForStation

void ParserResRobot::getTimeTableForStation(const Station &currentStation,
                                            const Station &directionStation,
                                            const QDateTime &dateTime,
                                            ParserAbstract::Mode mode,
                                            int trainrestrictions)
{
    if (currentRequestState != FahrplanNS::noneRequest)
        return;
    currentRequestState = FahrplanNS::getTimeTableForStationRequest;

    timetableSearchMode = mode;

    QUrl url;
    if (mode == Arrival)
        url.setUrl(baseURL + QLatin1String("/arrivalBoard"));
    else
        url.setUrl(baseURL + QLatin1String("/departureBoard"));
#if defined(BUILD_FOR_QT5)
    QUrlQuery query;
#else
    QUrl query;
#endif
    query.addQueryItem("key", timetableAPIKey);
    query.addQueryItem("id", stationIDv2(currentStation.id.toString()));
    if (directionStation.valid)
        query.addQueryItem("direction", stationIDv2(directionStation.id.toString()));
    query.addQueryItem("date", dateTime.toString("yyyy-MM-dd"));
    query.addQueryItem("time", dateTime.toString("hh:mm"));
    query.addQueryItem("maxJourneys", "30"); // Max number of results
    query.addQueryItem("passlist", "0"); // We don't need any intermediate stops in the result
    QString formattedRestrictions(formatRestrictions(trainrestrictions));
    if (!formattedRestrictions.isEmpty())
        query.addQueryItem("products", formattedRestrictions);
    if (QLocale().language() == QLocale::Swedish)
        query.addQueryItem("lang", "sv");
    else if (QLocale().language() == QLocale::German)
        query.addQueryItem("lang", "de");
    else
        query.addQueryItem("lang", "en");
    query.addQueryItem("format", "json");

#if defined(BUILD_FOR_QT5)
    url.setQuery(query);
#else
    url.setQueryItems(query.queryItems());
#endif
    qDebug() << "Searching for timetable:" << url.toString();
    sendHttpRequest(url);
}
开发者ID:leppa,项目名称:fahrplan,代码行数:49,代码来源:parser_resrobot.cpp

示例13: differentDelimiters

void tst_QUrlQuery::differentDelimiters()
{
    QUrlQuery query;
    query.setQueryDelimiters('(', ')');

    {
        // parse:
        query.setQuery("foo(bar)hello(world)");

        QueryItems expected;
        expected << qItem("foo", "bar") << qItem("hello", "world");
        COMPARE_ITEMS(query.queryItems(), expected);
        COMPARE_ITEMS(query.queryItems(QUrl::FullyEncoded), expected);
        COMPARE_ITEMS(query.queryItems(QUrl::PrettyDecoded), expected);
    }

    {
        // reconstruct:
        // note the final ')' is missing because there are no further items
        QCOMPARE(query.query(), QString("foo(bar)hello(world"));
    }

    {
        // set items containing the new delimiters and the old ones
        query.clear();
        query.addQueryItem("z(=)", "y(&)");
        QCOMPARE(query.query(), QString("z%28=%29(y%28&%29"));

        QUrlQuery copy = query;
        QCOMPARE(query.query(), QString("z%28=%29(y%28&%29"));

        copy.setQueryDelimiters(QUrlQuery::defaultQueryValueDelimiter(),
                                QUrlQuery::defaultQueryPairDelimiter());
        QCOMPARE(copy.query(), QString("z(%3D)=y(%26)"));
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:36,代码来源:tst_qurlquery.cpp

示例14: searchJourney

void ParserXmlVasttrafikSe::searchJourney(const Station &departureStation, const Station &viaStation, const Station &arrivalStation, const QDateTime &dateTime, ParserAbstract::Mode mode, int trainrestrictions)
{
    qDebug() << "ParserXmlVasttrafikSe::searchJourney(departureStation=" << departureStation.name << ", arrivalStation=" << arrivalStation.name << ", viaStation=" << viaStation.name << ", dateTime=" << dateTime.toString() << ", mode=" << mode << ", trainrestrictions=" << trainrestrictions << ")";

    if (currentRequestState != FahrplanNS::noneRequest)
        return;
    currentRequestState = FahrplanNS::searchJourneyRequest;

    m_searchJourneyParameters.isValid = false;
    m_searchJourneyParameters.departureStation = departureStation;
    m_searchJourneyParameters.arrivalStation = arrivalStation;
    m_searchJourneyParameters.viaStation = viaStation;
    m_searchJourneyParameters.dateTime = dateTime;
    m_searchJourneyParameters.mode = mode;
    m_searchJourneyParameters.trainrestrictions = trainrestrictions;

    QUrl uri(baseRestUrl + QLatin1String("trip"));
#if defined(BUILD_FOR_QT5)
    QUrlQuery query;
#else
    QUrl query;
#endif
    query.addQueryItem("authKey", apiKey);
    query.addQueryItem("format", "xml");
    query.addQueryItem("date", dateTime.toString("yyyy-MM-dd"));
    query.addQueryItem("time", dateTime.toString("hh:mm"));
    query.addQueryItem("originId", departureStation.id.toString());
    if (viaStation.valid)
        query.addQueryItem("viaId", viaStation.id.toString());
    if (mode == Arrival)
        query.addQueryItem("searchForArrival", "yes");
    query.addQueryItem("destId", arrivalStation.id.toString());
    query.addQueryItem("useVas", "1");
    query.addQueryItem("useLDTrain", "0");
    query.addQueryItem("useRegTrain", "1");
    query.addQueryItem("useBus", "1");
    query.addQueryItem("useBoat", "1");
    query.addQueryItem("useTram", "1");
    query.addQueryItem("excludeDR", "1");
    query.addQueryItem("numTrips", "5");
#if defined(BUILD_FOR_QT5)
    uri.setQuery(query);
#else
    uri.setQueryItems(query.queryItems());
#endif
    sendHttpRequest(uri);
}
开发者ID:evansebire,项目名称:fahrplan,代码行数:47,代码来源:parser_xmlvasttrafikse.cpp

示例15:

QHash<QString, QString> HTTPConnection::parseUrlEncodedForm() {
    // make sure we have the correct MIME type
    QList<QByteArray> elements = _requestHeaders.value("Content-Type").split(';');

    QString contentType = elements.at(0).trimmed();
    if (contentType != "application/x-www-form-urlencoded") {
        return QHash<QString, QString>();
    }

    QUrlQuery form { _requestContent };
    QHash<QString, QString> pairs;
    for (auto pair : form.queryItems()) {
        auto key = QUrl::fromPercentEncoding(pair.first.toLatin1().replace('+', ' '));
        auto value = QUrl::fromPercentEncoding(pair.second.toLatin1().replace('+', ' '));
        pairs[key] = value;
    }

    return pairs;
}
开发者ID:howard-stearns,项目名称:hifi,代码行数:19,代码来源:HTTPConnection.cpp


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