int Url::setAuthority ( lua_State * L )// ( const QString & authority ) { QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 ); //QString* authority = ValueInstaller2<QString>::check( L, 2 ); lhs->setAuthority( Util::toString( L, 2 ) ); return 0; }
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(); }
QUrl QHelpDBReader::buildQUrl(const QString &ns, const QString &folder, const QString &relFileName, const QString &anchor) const { QUrl url; url.setScheme(QLatin1String("qthelp")); url.setAuthority(ns); url.setPath(QLatin1Char('/') + folder + QLatin1Char('/') + relFileName); url.setFragment(anchor); return url; }
void QUrlProto::setAuthority(const QString &authority) { QUrl *item = qscriptvalue_cast<QUrl*>(thisObject()); if (item) item->setAuthority(authority); }