本文整理汇总了C++中QUrl::hasQuery方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::hasQuery方法的具体用法?C++ QUrl::hasQuery怎么用?C++ QUrl::hasQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::hasQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseUrl
void RequestParameters::parseUrl(const QUrl & url)
{
if (!url.hasQuery())
{
return;
}
QList<QPair<QString, QVariant >> parameters;
for (const QString & parameter : url.query().split('&'))
{
int splitIndex = parameter.indexOf('=');
if (splitIndex<=0)
{
continue;
}
QString key = parameter.left(splitIndex);
QString value = parameter.mid(splitIndex + 1);
parameters << QPair<QString, QVariant>(key, value);
}
parseList(parameters);
}
示例2: hasQuery
bool QUrlProto::hasQuery() const
{
QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
if (item)
return item->hasQuery();
return false;
}
示例3: setQueryDelimiters
/*!
Constructs a QUrlQuery object and parses the query string found in the \a
url URL, using the default query delimiters. To parse a query string using
other delimiters, you should first set them using setQueryDelimiters() and
then set the query with setQuery().
\sa QUrl::query()
*/
QUrlQuery::QUrlQuery(const QUrl &url)
: d(0)
{
// use internals to avoid unnecessary recoding
// ### FIXME: actually do it
if (url.hasQuery())
d = new QUrlQueryPrivate(url.query());
}
示例4: addQuery
QUrl MainWindow::addQuery(QUrl url, QString key, QString value) {
QString url_s = url.toDisplayString();
if (url.hasQuery()) {
url_s += "&" + key + "=" + value;
} else {
url_s += "?" + key + "=" + value;
}
return QUrl(url_s);
}
示例5: addQuery
QUrl BrowseWidget::addQuery(const QUrl &t_url, const QString &t_key,
const QString &t_value) {
QString url = t_url.toDisplayString();
if (t_url.hasQuery()) {
url += "&" + t_key + "=" + t_value;
} else {
url += "?" + t_key + "=" + t_value;
}
return QUrl(url);
}
示例6: QString
HttpEngine::HttpEngine(QUrl url, QUrl referrer, QUuid proxyUuid) : m_pRemote(0), m_url(url)
{
QString user_info;
QString query, host;
// QList<Proxy> listProxy = Proxy::loadProxys();
m_proxyData.nType = Proxy::ProxyNone;
host = url.host();
if(url.port(80) != 80)
host += QString(":") + QString::number(url.port(80));
if (Proxy::isProxyEnabled()){
Proxy p = Proxy:: loadProxy();
if(p.uuid == proxyUuid)
{
m_proxyData = p;
}
}
if(!url.hasQuery())
query = url.path();
else
query = url.path()+"?"+url.encodedQuery();
if(query.isEmpty())
query = "/";
if(m_proxyData.nType == Proxy::ProxyHttp)
{
m_header.setRequest("GET", QString("%1://%2%3").arg(url.scheme()).arg(host).arg(query));
if(!m_proxyData.strUser.isEmpty())
m_header.addValue("Proxy-Authorization", QString("Basic %1").arg((QString) (m_proxyData.strUser+":"+m_proxyData.strPassword).toUtf8().toBase64()) );
}
else
m_header.setRequest("GET", query);
user_info = url.userInfo();
if(!user_info.isEmpty())
m_header.addValue("Authorization", QString("Basic %1").arg( QString(user_info.toUtf8().toBase64()) ));
if(referrer.isValid())
m_header.addValue("Referrer", referrer.toString());
m_header.addValue("Host", host);
m_header.addValue("Connection", "close");
}
示例7: addPage
QUrl BrowseWidget::addPage(const QUrl &t_url, const int t_page) {
QString url = t_url.toDisplayString();
if (t_url.hasQuery()) {
if (url.contains("page=[0-9]")) {
url.replace("page=[0-9]", "page=" + QString::number(t_page));
} else {
url += "&page=" + QString::number(t_page);
}
} else {
url += "?page=" + QString::number(t_page);
}
return QUrl(url);
}
示例8: addPage
QUrl MainWindow::addPage(QUrl url, int page) {
QString url_s = url.toDisplayString();
if (url.hasQuery()) {
if (url_s.contains("page=[0-9]")) {
url_s.replace("page=[0-9]", "page=" + QString::number(page));
} else {
url_s += "&page=" + QString::number(page);
}
} else {
url_s += "?page=" + QString::number(page);
}
return QUrl(url_s);
}
示例9: urlEncodeQueryString
QString QzTools::urlEncodeQueryString(const QUrl &url)
{
QString returnString = url.toString(QUrl::RemoveQuery | QUrl::RemoveFragment);
if (url.hasQuery()) {
returnString += QLatin1Char('?') + url.query(QUrl::FullyEncoded);
}
if (url.hasFragment()) {
returnString += QLatin1Char('#') + url.fragment(QUrl::FullyEncoded);
}
returnString.replace(QLatin1Char(' '), QLatin1String("%20"));
return returnString;
}
示例10: processQuery
void processQuery() {
QTcpSocket *socket = qobject_cast<QTcpSocket*>(sender());
QByteArray requestData = socket->readAll();
int pos = requestData.indexOf("\r\n");
QByteArray requestLine = requestData.left(pos);
requestData.remove(0, pos + 2);
QList<QByteArray> entries = requestLine.split(' ');
QByteArray method = entries.value(0);
QByteArray address = entries.value(1);
QByteArray version = entries.value(2);
QUrl url = QUrl::fromEncoded(address);
if (!url.isValid()) {
qWarning() << "Invalid URL:" << url;
socket->disconnectFromHost();
return;
}
QString host = url.host();
int port = (url.port() < 0) ? 80 : url.port();
QByteArray req = url.encodedPath();
if (url.hasQuery())
req.append('?').append(url.encodedQuery());
requestLine = method + " " + req + " " + version + "\r\n";
requestData.prepend(requestLine);
QString key = host + ':' + QString::number(port);
QTcpSocket *proxySocket = socket->findChild<QTcpSocket*>(key);
if (proxySocket) {
proxySocket->setObjectName(key);
proxySocket->setProperty("url", url);
proxySocket->setProperty("requestData", requestData);
proxySocket->write(requestData);
} else {
proxySocket = new QTcpSocket(socket);
proxySocket->setObjectName(key);
proxySocket->setProperty("url", url);
proxySocket->setProperty("requestData", requestData);
connect(proxySocket, SIGNAL(connected()), this, SLOT(sendRequest()));
connect(proxySocket, SIGNAL(readyRead()), this, SLOT(transferData()));
connect(proxySocket, SIGNAL(disconnected()), this, SLOT(closeConnection()));
connect(proxySocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(closeConnection()));
proxySocket->connectToHost(host, port);
}
}
示例11: handleClick
bool ActionURLHandlerWebEngine::handleClick(const QUrl &url, ArticleViewerWebEngine *articleViewer) const
{
if (url.scheme() == QLatin1String("akregatoraction")) {
const QString urlPath(url.path());
if (url.hasQuery()) {
const QUrlQuery urlQuery(url);
const QString articleId = urlQuery.queryItemValue(QStringLiteral("id"));
const QString feed = urlQuery.queryItemValue(QStringLiteral("feed"));
if (!articleId.isEmpty()) {
if (urlPath == QLatin1String("delete")) {
articleViewer->setArticleAction(ArticleViewerWebEngine::DeleteAction, articleId, feed);
return true;
} else if (urlPath == QLatin1String("markAsRead")) {
articleViewer->setArticleAction(ArticleViewerWebEngine::MarkAsRead, articleId, feed);
return true;
} else if (urlPath == QLatin1String("markAsUnRead")) {
articleViewer->setArticleAction(ArticleViewerWebEngine::MarkAsUnRead, articleId, feed);
return true;
} else if (urlPath == QLatin1String("markAsImportant")) {
articleViewer->setArticleAction(ArticleViewerWebEngine::MarkAsImportant, articleId, feed);
return true;
} else if (urlPath == QLatin1String("sendUrlArticle")) {
articleViewer->setArticleAction(ArticleViewerWebEngine::SendUrlArticle, articleId, feed);
return true;
} else if (urlPath == QLatin1String("sendFileArticle")) {
articleViewer->setArticleAction(ArticleViewerWebEngine::SendFileArticle, articleId, feed);
return true;
} else if (urlPath == QLatin1String("openInExternalBrowser")) {
articleViewer->setArticleAction(ArticleViewerWebEngine::OpenInExternalBrowser, articleId, feed);
return true;
} else if (urlPath == QLatin1String("share")) {
articleViewer->setArticleAction(ArticleViewerWebEngine::Share, articleId, feed);
return true;
} else if (urlPath == QLatin1String("openInBackgroundTab")) {
articleViewer->setArticleAction(ArticleViewerWebEngine::OpenInBackgroundTab, articleId, feed);
return true;
}
}
} else {
qCWarning(AKREGATOR_LOG) << "Undefined article id";
return true;
}
}
return false;
}
示例12: request
void HttpComms::request(QUrl &url, int timeoutms, bool allowGzip)
{
QString path = url.path();
if (url.hasQuery())
path += '?' + url.encodedQuery();
QHttpRequestHeader header("GET", path);
QString userAgent = "Mozilla/9.876 (X11; U; Linux 2.2.12-20 i686, en) "
"Gecko/25250101 Netscape/5.432b1";
header.setValue("Host", url.host());
header.setValue("User-Agent", userAgent);
if (allowGzip)
header.setValue( "Accept-Encoding", "gzip");
request(url, header, timeoutms);
}
示例13: setUrl
void setUrl(const QUrl &url)
{
QString hdr;
hdr = QString("GET %PATH% HTTP/1.1\r\n"
"Host: %HOST%\r\n"
"User-Agent: MythMusic/%VERSION%\r\n"
"Accept: */*\r\n");
QString path = url.path();
QString host = url.host();
if (path.isEmpty())
path = "/";
if (url.hasQuery())
path += '?' + url.encodedQuery();
if (url.port() != -1)
host += QString(":%1").arg(url.port());
hdr.replace("%PATH%", path);
hdr.replace("%HOST%", host);
hdr.replace("%VERSION%", MYTH_BINARY_VERSION);
if (!url.userName().isEmpty() && !url.password().isEmpty())
{
QString authstring = url.userName() + ":" + url.password();
QString auth = QCodecs::base64Encode(authstring.toLocal8Bit());
hdr += "Authorization: Basic " + auth + "\r\n";
}
hdr += QString("TE: trailers\r\n"
"Icy-Metadata: 1\r\n"
"\r\n");
LOG(VB_NETWORK, LOG_INFO, QString("ShoutCastRequest: '%1'").arg(hdr));
m_data = hdr.toAscii();
}
示例14: extractMimeTypeFor
static void extractMimeTypeFor(const QUrl& url, QString& mimeType)
{
const QString fname(url.fileName());
if (fname.isEmpty() || url.hasFragment() || url.hasQuery())
return;
KMimeType::Ptr pmt = KMimeType::findByPath(fname, 0, true);
// Further check for mime types guessed from the extension which,
// on a web page, are more likely to be a script delivering content
// of undecidable type. If the mime type from the extension is one
// of these, don't use it. Retain the original type 'text/html'.
if (pmt->name() == KMimeType::defaultMimeType() ||
pmt->is(QL1S("application/x-perl")) ||
pmt->is(QL1S("application/x-perl-module")) ||
pmt->is(QL1S("application/x-php")) ||
pmt->is(QL1S("application/x-python-bytecode")) ||
pmt->is(QL1S("application/x-python")) ||
pmt->is(QL1S("application/x-shellscript")))
return;
mimeType = pmt->name();
}
示例15: urlEncodeQueryString
QString QzTools::urlEncodeQueryString(const QUrl &url)
{
QString returnString = url.toString(QUrl::RemoveQuery | QUrl::RemoveFragment);
if (url.hasQuery()) {
#if QT_VERSION >= 0x050000
returnString += QLatin1Char('?') + url.query(QUrl::FullyEncoded);
#else
returnString += QLatin1Char('?') + url.encodedQuery();
#endif
}
if (url.hasFragment()) {
#if QT_VERSION >= 0x050000
returnString += QLatin1Char('#') + url.fragment(QUrl::FullyEncoded);
#else
returnString += QLatin1Char('#') + url.encodedFragment();
#endif
}
returnString.replace(QLatin1Char(' '), QLatin1String("%20"));
return returnString;
}