本文整理汇总了C++中QUrl::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::isValid方法的具体用法?C++ QUrl::isValid怎么用?C++ QUrl::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseBitcoinURI
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
{
// return if URI is not valid or is no bitcoin URI
if(!uri.isValid() || uri.scheme() != QString("bitcoin"))
return false;
SendCoinsRecipient rv;
rv.address = uri.path();
rv.amount = 0;
#if QT_VERSION < 0x050000
QList<QPair<QString, QString> > items = uri.queryItems();
#else
QUrlQuery uriQuery(uri);
QList<QPair<QString, QString> > items = uriQuery.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::BTC, i->second, &rv.amount))
{
return false;
}
}
fShouldReturnFalse = false;
}
if (fShouldReturnFalse)
return false;
}
if(out)
{
*out = rv;
}
return true;
}
示例2: startDownloading
void DownloadItem::startDownloading()
{
QUrl locationHeader = m_reply->header(QNetworkRequest::LocationHeader).toUrl();
bool hasFtpUrlInHeader = locationHeader.isValid() && (locationHeader.scheme() == "ftp");
if (m_reply->url().scheme() == "ftp" || hasFtpUrlInHeader) {
QUrl url = hasFtpUrlInHeader ? locationHeader : m_reply->url();
m_reply->abort();
m_reply->deleteLater();
m_reply = 0;
startDownloadingFromFtp(url);
return;
}
else if (locationHeader.isValid()) {
m_reply->abort();
m_reply->deleteLater();
m_reply = mApp->networkManager()->get(QNetworkRequest(locationHeader));
}
m_reply->setParent(this);
connect(m_reply, SIGNAL(finished()), this, SLOT(finished()));
connect(m_reply, SIGNAL(readyRead()), this, SLOT(readyRead()));
connect(m_reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64)));
connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error()));
connect(m_reply, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged()));
m_downloading = true;
m_timer.start(1000, this);
readyRead();
QTimer::singleShot(200, this, SLOT(updateDownload()));
if (m_reply->error() != QNetworkReply::NoError) {
stop(false);
error();
}
}
示例3: finished
void NetworkAccessManager::finished(QNetworkReply *reply) {
QUrl redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
if (redirectUrl.isValid())
m_redirectMappings[reply->url().resolved(redirectUrl)] = reply->url();
else {
QUrl requestedUrl = reply->url();
while (m_redirectMappings.contains(requestedUrl))
requestedUrl = m_redirectMappings.take(requestedUrl);
NetworkResponse response;
response.statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
response.headers = reply->rawHeaderPairs();
m_responses[requestedUrl] = response;
}
}
示例4: setUrl
void ContactImage::setUrl(const QUrl& url)
{
if (!m_engine) {
return;
}
if (!m_source.isEmpty()) {
m_engine->disconnectSource(m_source, this);
}
m_source = url.isValid() ? "Pixmap\\url:" + url.toString() : QString();
dataUpdated(m_source, DataEngine::Data());
if (!m_source.isEmpty()) {
m_engine->connectSource(m_source, this);
}
}
示例5: Resource
NetworkTexture::NetworkTexture(const QUrl& url, bool normalMap) :
Resource(url),
_translucent(false) {
if (!url.isValid()) {
_loaded = true;
return;
}
// default to white/blue
glBindTexture(GL_TEXTURE_2D, getID());
loadSingleColorTexture(normalMap ? OPAQUE_BLUE : OPAQUE_WHITE);
glBindTexture(GL_TEXTURE_2D, 0);
}
示例6: slotRecived
void EWAFaviconLoader::slotRecived( QNetworkReply *pReply )
{
QUrl anotherLocation = pReply->attribute( QNetworkRequest::RedirectionTargetAttribute ).toUrl();
QByteArray binaryData = pReply->readAll();
bool bNoError = QNetworkReply::NoError == pReply->error();
QString strError = pReply->errorString();
QString strReqUrl = pReply->url().toString();
int iLastDotId = strReqUrl.lastIndexOf( "." );
QString strFormat( "ICO" );
if( iLastDotId > 0
&& !strReqUrl.endsWith( strFormat, Qt::CaseInsensitive ) )
{
strReqUrl.right( strReqUrl.length() - 1 - iLastDotId ).toUpper();
}
pReply->deleteLater();
stop();
if( anotherLocation.isValid() )
{
if( anotherLocation.isRelative() )
{
anotherLocation = QUrl( strReqUrl ).resolved( anotherLocation );
}
qDebug() << "EWAFaviconLoader::slotRecived: redirecting from ["
<< strReqUrl << "] to [" << anotherLocation.toString() << "]";
setTargetUrl( anotherLocation.toString() );
start();
}
else
{
if( bNoError )
{
QPixmap pixmap = QPixmap::fromImage( QImage::fromData( binaryData, qPrintable( strFormat ) ) );
if( pixmap.isNull() )
qWarning() << "EWAFaviconLoader::slotRecived: received icon is null";
else
emit signalIconRecived( QIcon( pixmap ) );
}
else
{
qWarning() << "EWAFaviconLoader::slotRecived:" << strError;
}
}
}
示例7: changeLocation
void MainWindow::changeLocation()
{
#ifndef QT_NO_INPUTDIALOG
QString string = urlEdit->text();
QUrl mainFrameURL = page()->mainFrame()->url();
if (mainFrameURL.isValid() && string == mainFrameURL.toString()) {
page()->triggerAction(QWebPage::Reload);
return;
}
load(string);
#endif
}
示例8: setSource
void HelpViewer::setSource(const QUrl &url)
{
bool help = url.toString() == QLatin1String("help");
if (url.isValid() && !help) {
if (launchedWithExternalApp(url))
return;
QUrl u = helpEngine->findFile(url);
if (u.isValid()) {
QTextBrowser::setSource(u);
return;
}
}
if (help) {
QTextBrowser::setSource(QUrl(QLatin1String("qthelp://com.trolltech.com."
"assistantinternal-1.0.0/assistant/assistant.html")));
} else {
QTextBrowser::setSource(url);
setHtml(PageNotFoundMessage.arg(url.toString()));
emit sourceChanged(url);
}
}
示例9: inf
QString Ilwis3Connector::outputNameFor(const IlwisObject *obj, bool isMulti, IlwisTypes type) {
QUrl url = obj->resource(IlwisObject::cmOUTPUT).url();
QString outputName = sUNDEF;
if ( url.isValid() && url.scheme() == "file") {
QFileInfo inf(url.toLocalFile());
outputName = inf.absolutePath() + "/"+ inf.baseName();
} else {
QString dir = context()->workingCatalog()->resource().toLocalFile();
outputName = dir + "/" + obj->name();
}
if ( isMulti)
outputName += "_" + Ilwis3Connector::type2humanName(type) ;
return outputName;
}
示例10: startupUrl
static QUrl startupUrl()
{
QUrl ret;
QStringList args(qApp->arguments());
args.takeFirst();
Q_FOREACH (const QString& arg, args) {
if (arg.startsWith(QLatin1Char('-')))
continue;
ret = Utils::fromUserInput(arg);
if (ret.isValid())
return ret;
}
return QUrl(QStringLiteral("ftp://ftp.ncbi.nih.gov/"));
}
示例11: validateUrl
/* A public static function which is used to screen crawled URLs
* for potential queuing
*/
bool Parser::validateUrl(QUrl url) {
if (!url.isValid()) {
qDebug() << "discarding invalid " << url;
return false;
} else if (url.scheme() == "https") {
qDebug() << "discarding https " << url;
return false;
} else if (url.host() == "") {
qDebug() << "discarding url with no host" << url;
return false;
}
return true;
}
示例12: addEngine
void SearchEnginesManager::addEngine(const QUrl &url)
{
ENSURE_LOADED;
if (!url.isValid()) {
return;
}
qApp->setOverrideCursor(Qt::WaitCursor);
QNetworkReply* reply = mApp->networkManager()->get(QNetworkRequest(url));
reply->setParent(this);
connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
}
示例13: addUrlToRecentFolders
void GvCore::addUrlToRecentFolders(QUrl url)
{
if (!GwenviewConfig::historyEnabled()) {
return;
}
if (!url.isValid()) {
return;
}
if (url.path() != "") { // This check is a workaround for bug #312060
url.setPath(url.path()+'/');
}
recentFoldersModel();
d->mRecentFoldersModel->addUrl(url);
}
示例14: hasEntry
bool HistoryManager::hasEntry(const QUrl &url)
{
if (!m_isEnabled || !url.isValid())
{
return false;
}
if (!m_browsingHistoryModel)
{
getBrowsingHistoryModel();
}
return m_browsingHistoryModel->hasEntry(url);
}
示例15: if
bool
TrackImageFetcher::downloadImage( QNetworkReply* reply, const QString& root_node )
{
XmlQuery lfm;
if ( reply && lfm.parse( reply->readAll() ) )
{
// cache all the sizes
if ( root_node == "album" )
{
m_track.album().setImageUrl( Track::MegaImage, lfm[root_node]["image size=mega"].text() );
m_track.album().setImageUrl( Track::ExtraLargeImage, lfm[root_node]["image size=extralarge"].text() );
m_track.album().setImageUrl( Track::LargeImage, lfm[root_node]["image size=large"].text() );
m_track.album().setImageUrl( Track::MediumImage, lfm[root_node]["image size=medium"].text() );
m_track.album().setImageUrl( Track::SmallImage, lfm[root_node]["image size=small"].text() );
}
else if ( root_node == "artist" )
{
m_track.artist().setImageUrl( Track::MegaImage, lfm[root_node]["image size=mega"].text() );
m_track.artist().setImageUrl( Track::ExtraLargeImage, lfm[root_node]["image size=extralarge"].text() );
m_track.artist().setImageUrl( Track::LargeImage, lfm[root_node]["image size=large"].text() );
m_track.artist().setImageUrl( Track::MediumImage, lfm[root_node]["image size=medium"].text() );
m_track.artist().setImageUrl( Track::SmallImage, lfm[root_node]["image size=small"].text() );
}
}
else
{
qWarning() << lfm.parseError().message();
}
QUrl imageUrl = url( root_node );
qWarning() << root_node << imageUrl;
if ( imageUrl.isValid() )
{
QNetworkReply* get = lastfm::nam()->get( QNetworkRequest( imageUrl ) );
if ( root_node == "album" )
connect( get, SIGNAL(finished()), SLOT(onAlbumImageDownloaded()) );
else if ( root_node == "track" )
connect( get, SIGNAL(finished()), SLOT(onTrackImageDownloaded()) );
else
connect( get, SIGNAL(finished()), SLOT(onArtistImageDownloaded()) );
return true;
}
return false;
}