summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaroline Chao <caroline.chao@digia.com>2014-02-05 16:37:58 +0100
committerCaroline Chao <caroline.chao@digia.com>2014-02-06 13:26:44 +0100
commit8e675effd1f33d0c2bb6ab368ac5b9cee1ef7f5f (patch)
tree1cb8a3ff29d14945585144b45ddc93a064e8dfaa
parent3d47d665f4b72e03052f845545520a72994b54b4 (diff)
Silently ignores failures while downloading imagesv1.2_android
It seems some large icons (b200) are missing from yr.no symbols. Thus trying to download them fails and causes the app to be unusable for the cities using them. Now the app will silenttly ignore the images download failures and will use a smaller icon instead (b100) if available. The Image using the large icons is made smaller. Change-Id: Iaefe5f7ef85fe0d985d26873083045e44f944a17 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
-rw-r--r--qml/pages/OneDayZoomItem.qml4
-rw-r--r--src/citymodel.cpp4
-rw-r--r--src/daymodel.cpp16
3 files changed, 17 insertions, 7 deletions
diff --git a/qml/pages/OneDayZoomItem.qml b/qml/pages/OneDayZoomItem.qml
index d6f14c5..0ea5275 100644
--- a/qml/pages/OneDayZoomItem.qml
+++ b/qml/pages/OneDayZoomItem.qml
@@ -113,8 +113,8 @@ GridLayout {
}
Layout.rowSpan: 1
- Layout.preferredHeight: 200 * ApplicationInfo.ratio
- Layout.preferredWidth: 200 * ApplicationInfo.ratio
+ Layout.preferredHeight: 160 * ApplicationInfo.ratio
+ Layout.preferredWidth: 160 * ApplicationInfo.ratio
Layout.alignment: Qt.AlignCenter
}
TouchLabel {
diff --git a/src/citymodel.cpp b/src/citymodel.cpp
index 3b5c3db..47e1f03 100644
--- a/src/citymodel.cpp
+++ b/src/citymodel.cpp
@@ -228,7 +228,9 @@ bool CityModel::dataExpired(qint64 timeStamp) {
void CityModel::replyFinished(QNetworkReply *reply)
{
if (reply->error() != QNetworkReply::NoError) {
- setError(reply->errorString());
+ // "Silently" ignores failures while downloading images
+ if (!reply->request().url().toString().contains(".png"))
+ setError(reply->errorString());
} else {
QString requestUrl = reply->request().url().toString();
if (requestUrl.endsWith(".xml")) {
diff --git a/src/daymodel.cpp b/src/daymodel.cpp
index e3166cb..9d55861 100644
--- a/src/daymodel.cpp
+++ b/src/daymodel.cpp
@@ -112,15 +112,23 @@ void DayModel::addRow(QString day, QString weatherUrl, QString timeRange, QStrin
QUrl DayModel::getCachedImageFile(const QString url)
{
bool isLargeImage = url.contains("b200");
- QString filename = url.right(url.length() - url.lastIndexOf("/") - 1);
+ QString baseFilename = url.right(url.length() - url.lastIndexOf("/") - 1);
+ QString filename = baseFilename;
if (isLargeImage)
filename.prepend("large_");
filename = QString("%1%2").arg(ApplicationPaths::dowloadedFilesPath()).arg(filename);
+ baseFilename = QString("%1%2").arg(ApplicationPaths::dowloadedFilesPath()).arg(baseFilename);;
QFile file(filename);
- if (file.exists())
+ if (file.exists()) {
return QUrl(QString("image://weatherImages/%1").arg(filename));
- else
- return QUrl(url);
+ } else {
+ QFile standardSize(baseFilename);
+ // Some large icons are not available anymore on yr.no
+ if (isLargeImage && standardSize.exists())
+ return QUrl(QString("image://weatherImages/%1").arg(baseFilename));
+ else
+ return QUrl(url);
+ }
}
QString DayModel::getDayDetails(int index, QString prop) const