本文整理汇总了C++中QUrl::queryItemValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::queryItemValue方法的具体用法?C++ QUrl::queryItemValue怎么用?C++ QUrl::queryItemValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::queryItemValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_mui_browser_anchorClicked
void Devolucion::on_mui_browser_anchorClicked ( const QUrl &anchor )
{
if ( anchor.queryItemValue ( "op" ) == "minus" ) {
if ( m_ticket->dbValue ( "idalbaran" ).isEmpty() ) return;
int sizein = m_ticket->listaLineas()->size();
for ( int i = 0; i < sizein; ++i ) {
BlDbRecord *item = m_ticket->listaLineas() ->at ( i );
if ( item->dbValue ( "numlalbaran" ) == anchor.queryItemValue ( "numlalbaran" ) ) {
BlDbRecord *nitem = m_ticket->agregarLinea();
QList<BlDbField *> *lista = item->lista();
for ( int j = 0; j < lista->size(); ++j ) {
BlDbField * camp = lista->at ( j );
if ( camp->fieldName() != "numlalbaran" ) {
nitem->setDbValue ( camp->fieldName(), camp->fieldValue() );
} // end if
if ( camp->fieldName() == "cantlalbaran" && camp->fieldValue().toFloat() > 0 ) {
nitem->setDbValue ( camp->fieldName(), "-1" );
}// end if
} // end if
} // end for
}// end for
} // end if
pintar();
}
示例2: openLocalFile
bool OpenLocalHelper::openLocalFile(const QUrl &url)
{
if (url.scheme() != kSeafileProtocolScheme) {
qWarning("[OpenLocalHelper] unknown scheme %s\n", url.scheme().toUtf8().data());
return false;
}
if (url.host() != kSeafileProtocolHostOpenFile) {
qWarning("[OpenLocalHelper] unknown command %s\n", url.host().toUtf8().data());
return false;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QUrlQuery url_query = QUrlQuery(url.query());
QString repo_id = url_query.queryItemValue("repo_id", QUrl::FullyDecoded);
QString email = url_query.queryItemValue("email", QUrl::FullyDecoded);
QString path = url_query.queryItemValue("path", QUrl::FullyDecoded);
#else
QString repo_id = url.queryItemValue("repo_id");
QString email = url.queryItemValue("email");
QString path = url.queryItemValue("path");
#endif
if (repo_id.size() < 36) {
qWarning("[OpenLocalHelper] invalid repo_id %s\n", repo_id.toUtf8().data());
return false;
}
qDebug("[OpenLocalHelper] open local file: repo %s, path %s\n",
repo_id.toUtf8().data(), path.toUtf8().data());
RepoService::instance()->openLocalFile(repo_id, path);
return true;
}
示例3: 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 );
}
示例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") )
{
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;
}
示例5: Login
void Client::Login(const QUrl& loginUrl)
{
// We support tundra, http and https scheme login urls
QString urlScheme = loginUrl.scheme().toLower();
if (urlScheme.isEmpty())
return;
if (urlScheme != "tundra" && urlScheme != "http" && urlScheme != "https")
return;
// Make sure to logout to empty the previous properties map.
if (IsConnected())
DoLogout();
// Set properties that the "lower" overload wont be adding:
// Iterate all query items and parse them to go into the login properties.
// This will leave percent encoding to the parameters! We remove it by hand from username below!
QList<QPair<QString, QString> > queryItems = loginUrl.queryItems();
for (int i=0; i<queryItems.size(); i++)
{
// Skip the ones that are handled by below logic
QPair<QString, QString> queryItem = queryItems.at(i);
if (queryItem.first == "username" || queryItem.first == "password" || queryItem.first == "protocol")
continue;
QByteArray utfQueryValue = queryItem.second.toUtf8();
if (utfQueryValue.contains('%'))
{
// Use QUrl to decode percent encoding instead of QByteArray.
queryItem.second = QUrl::fromEncoded(utfQueryValue).toString();
}
SetLoginProperty(queryItem.first, queryItem.second);
}
// Parse values from url
QString username = loginUrl.queryItemValue("username");
QString password = loginUrl.queryItemValue("password");
QString protocol = loginUrl.queryItemValue("protocol");
QString address = loginUrl.host();
int port = loginUrl.port();
// If the username is more exotic or has spaces, prefer
// decoding the percent encoding before it is sent to the server.
QByteArray utfUsername = loginUrl.queryItemValue("username").toUtf8();
if (utfUsername.contains('%'))
{
// Use QUrl to decode percent encoding instead of QByteArray.
username = QUrl::fromEncoded(utfUsername).toString();
}
// Validation: Username and address is the minimal set that with we can login with
if (username.isEmpty() || address.isEmpty())
{
::LogError("Client::Login: Cannot log to server, no username defined in login url: " + loginUrl.toString());
return;
}
if (port < 0)
port = 2345;
Login(address, port, username, password, protocol);
}
示例6: getAccessToken
bool ActivatePage::getAccessToken()
{
serverQueryFinished = false;
serverQueryError = false;
disconnect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
label_message->setText("Requesting key...");
QUrl url( "https://screencloud.net/1.0/oauth/access_token_xauth" );
// create a request parameters map
QUrl bodyParams;
bodyParams.addQueryItem( "data[User][email]", field("register.email").toString());
bodyParams.addQueryItem( "data[User][password]", field("register.password").toString());
bodyParams.addQueryItem("oauth_version", "1.0");
bodyParams.addQueryItem("oauth_signature_method", "PLAINTEXT");
bodyParams.addQueryItem("oauth_consumer_key", CONSUMER_KEY_SCREENCLOUD);
bodyParams.addQueryItem("oauth_signature", CONSUMER_SECRET_SCREENCLOUD);
bodyParams.addQueryItem("oauth_timestamp", QString::number(QDateTime::currentDateTimeUtc().toTime_t()));
bodyParams.addQueryItem("oauth_nonce", NetworkUtils::generateNonce(15));
QByteArray body = bodyParams.encodedQuery();
QNetworkRequest request;
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
request.setUrl(url);
QNetworkReply* reply = manager->post(request, body);
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
if ( reply->error() == QNetworkReply::NoError ) {
//Save to qsettings
QString replyText = reply->readAll();
if(replyText.isEmpty())
{
label_message->setText("<font color='red'>Failed to get credentials. Empty reply from server.</font>");
return false;
}
INFO(reply->request().url().toString() + " returned: " + replyText);
QUrl replyParams = QUrl("?" + replyText);
QSettings settings("screencloud", "ScreenCloud");
settings.beginGroup("account");
settings.setValue("token", replyParams.queryItemValue("oauth_token"));
settings.setValue("token-secret", replyParams.queryItemValue("oauth_token_secret"));
settings.setValue("email", field("register.email").toString());
settings.setValue("logged-in", true);
settings.endGroup();
return true;
}else
{
label_message->setText("<font color='red'>OAuth error</font>");
return false;
}
return false;
}
示例7: 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;
}
示例8: linkClicked
void BrowserDialog::linkClicked(const QUrl& url)
{
do {
if (url.host() != DOWNLOAD_HOST_BASE) {
break;
}
if (url.path() != "/dict/download_cell.php") {
break;
}
QString id = url.queryItemValue("id");
QByteArray name = url.encodedQueryItemValue("name");
QString sname = decodeName(name);
m_name = sname;
if (!id.isEmpty() && !sname.isEmpty()) {
download(url);
return;
}
} while(0);
if (url.host() != HOST_BASE) {
QMessageBox::information(this, _("Wrong Link"),
_("No browsing outside pinyin.sogou.com, now redirect to home page."));
m_ui->webView->load(QUrl(URL_BASE));
} else {
m_ui->webView->load(url);
}
}
示例9: queryItemValue
QString QUrlProto::queryItemValue(const QString &key) const
{
QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
if (item)
return item->queryItemValue(key);
return QString();
}
示例10: testIncludeUrlParams
void Utils::testIncludeUrlParams() {
QUrl urla(QString("http://example.com"));
QHash<QString, QString> params;
params.insert("simple", "c");
params.insert("withspecial", "a?b");
params.insert("withspace", "a b");
params.insert("username", "a123fx b");
params.insert("password", "[email protected]#+-$%^12&*()qweqesaf\"';`~");
params.insert("withplus", "a+b");
QUrl urlb = ::includeQueryParams(urla, params);
QVERIFY(urla.scheme() == urlb.scheme());
QVERIFY(urla.host() == urlb.host());
Q_FOREACH (const QString& key, params.keys()) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QString encoded_key = QUrl::toPercentEncoding(key);
QString encoded_value = QUrl::toPercentEncoding(params[encoded_key]);
QUrlQuery query = QUrlQuery(urlb.query());
QVERIFY(query.queryItemValue(encoded_key, QUrl::FullyEncoded) == encoded_value);
#else
QVERIFY(urlb.queryItemValue(key) == params[key]);
#endif
}
}
示例11: queryItemValue
int Url::queryItemValue ( lua_State * L )// ( const QString & key ) const : QString
{
QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 );
//QString* key = ValueInstaller2<QString>::check( L, 2 );
Util::push(L, lhs->queryItemValue( Util::toString( L, 2 ) ) );
return 1;
}
示例12: 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()));
}
示例13: CheckIsBlank
bool VkAuthManager::CheckIsBlank (QUrl location)
{
if (location.path () != "/blank.html")
return false;
location = QUrl::fromEncoded (location.toEncoded ().replace ('#', '?'));
Token_ = location.queryItemValue ("access_token");
ValidFor_ = location.queryItemValue ("expires_in").toInt ();
ReceivedAt_ = QDateTime::currentDateTime ();
qDebug () << Q_FUNC_INFO << Token_ << ValidFor_;
IsRequesting_ = false;
emit gotAuthKey (Token_);
return true;
}
示例14: CheckError
bool VkAuthManager::CheckError (const QUrl& url)
{
if (url.path () != "/error")
return false;
#if QT_VERSION < 0x050000
const auto errNum = url.queryItemValue ("err").toInt ();
#else
const auto errNum = QUrlQuery { url }.queryItemValue ("err").toInt ();
#endif
IsRequesting_ = false;
qWarning () << Q_FUNC_INFO
<< "got error"
<< errNum;
if (errNum == 2)
{
clearAuthData ();
RequestAuthKey ();
return true;
}
const auto& e = Util::MakeNotification ("VK.com",
tr ("VK.com authentication for %1 failed because of error %2. "
"Report upstream please.")
.arg (AccountHR_)
.arg (errNum),
PCritical_);
Proxy_->GetEntityManager ()->HandleEntity (e);
return true;
}
示例15: anchorClicked
void Comments::anchorClicked(const QUrl & url)
{
if(url.host().isEmpty() && url.path() == "edit")
{
#if QT_VERSION >= 0x050000
int cid = QUrlQuery(url).queryItemValue("id").toInt();
#else
int cid = url.queryItemValue("id").toInt();
#endif
if(userCanEdit(cid))
{
ParameterList params;
params.append("mode", "edit");
params.append("sourceType", _sourcetype);
params.append("source_id", _sourceid);
params.append("comment_id", cid);
params.append("commentIDList", _commentIDList);
comment newdlg(this, "", true);
newdlg.set(params);
newdlg.exec();
refresh();
}
}
else
{
QDesktopServices::openUrl(url);
}
}