mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Cosmetics
This commit is contained in:
parent
06901d8d7a
commit
ed4e201b08
@ -89,9 +89,10 @@ bool Downloader::_http2 = true;
|
||||
bool Downloader::doDownload(const Download &dl,
|
||||
const QByteArray &authorization, const Redirect *redirect)
|
||||
{
|
||||
QUrl url(dl.url());
|
||||
const QUrl &url = dl.url();
|
||||
|
||||
if (!url.isValid() || !(url.scheme() == "http" || url.scheme() == "https")) {
|
||||
if (!url.isValid() || !(url.scheme() == QLatin1String("http")
|
||||
|| url.scheme() == QLatin1String("https"))) {
|
||||
qWarning("%s: Invalid URL", qPrintable(url.toString()));
|
||||
if (redirect)
|
||||
_errorDownloads.insert(redirect->origin(), RETRIES);
|
||||
@ -161,11 +162,11 @@ void Downloader::insertError(const QUrl &url, QNetworkReply::NetworkError error)
|
||||
|
||||
void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
{
|
||||
QUrl url = reply->request().url();
|
||||
QUrl url(reply->request().url());
|
||||
QNetworkReply::NetworkError error = reply->error();
|
||||
|
||||
if (error) {
|
||||
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
||||
QUrl origin(reply->request().attribute(ATTR_ORIGIN).toUrl());
|
||||
if (origin.isEmpty()) {
|
||||
insertError(url, error);
|
||||
qWarning("Error downloading file: %s: %s",
|
||||
@ -177,12 +178,11 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
qPrintable(reply->errorString()));
|
||||
}
|
||||
} else {
|
||||
QUrl location = reply->attribute(ATTR_REDIRECT).toUrl();
|
||||
QString filename = reply->request().attribute(ATTR_FILE)
|
||||
.toString();
|
||||
QUrl location(reply->attribute(ATTR_REDIRECT).toUrl());
|
||||
QString filename(reply->request().attribute(ATTR_FILE).toString());
|
||||
|
||||
if (!location.isEmpty()) {
|
||||
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
||||
QUrl origin(reply->request().attribute(ATTR_ORIGIN).toUrl());
|
||||
int level = reply->request().attribute(ATTR_LEVEL).toInt();
|
||||
|
||||
if (level >= MAX_REDIRECT_LEVEL) {
|
||||
|
@ -32,15 +32,17 @@ void TileLoader::loadTilesAsync(QList<Tile> &list)
|
||||
Tile &t = list[i];
|
||||
QString file(tileFile(t));
|
||||
QFileInfo fi(file);
|
||||
QUrl url(tileUrl(t));
|
||||
|
||||
if (fi.exists())
|
||||
loadTileFile(t, file);
|
||||
else {
|
||||
QUrl url(tileUrl(t));
|
||||
if (url.isLocalFile())
|
||||
loadTileFile(t, url.toLocalFile());
|
||||
else if (fi.exists())
|
||||
loadTileFile(t, file);
|
||||
else
|
||||
dl.append(Download(url, file));
|
||||
}
|
||||
}
|
||||
|
||||
if (!dl.empty())
|
||||
_downloader->get(dl, _authorization);
|
||||
@ -54,15 +56,17 @@ void TileLoader::loadTilesSync(QList<Tile> &list)
|
||||
Tile &t = list[i];
|
||||
QString file(tileFile(t));
|
||||
QFileInfo fi(file);
|
||||
QUrl url(tileUrl(t));
|
||||
|
||||
if (fi.exists())
|
||||
loadTileFile(t, file);
|
||||
else {
|
||||
QUrl url(tileUrl(t));
|
||||
if (url.isLocalFile())
|
||||
loadTileFile(t, url.toLocalFile());
|
||||
else if (fi.exists())
|
||||
loadTileFile(t, file);
|
||||
else
|
||||
dl.append(Download(url, file));
|
||||
}
|
||||
}
|
||||
|
||||
if (dl.empty())
|
||||
return;
|
||||
@ -116,8 +120,7 @@ QUrl TileLoader::tileUrl(const Tile &tile) const
|
||||
|
||||
QString TileLoader::tileFile(const Tile &tile) const
|
||||
{
|
||||
QString file = _dir + QString("/%1-%2-%3").arg(tile.zoom().toString())
|
||||
.arg(tile.xy().x()).arg(tile.xy().y());
|
||||
|
||||
return file;
|
||||
return _dir + QLatin1Char('/') + tile.zoom().toString() + QLatin1Char('-')
|
||||
+ QString::number(tile.xy().x()) + QLatin1Char('-')
|
||||
+ QString::number(tile.xy().y());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user