← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~martin-borho/ubuntu-weather-app/reboot-flatten-locationpage into lp:ubuntu-weather-app/reboot

 

Martin Borho has proposed merging lp:~martin-borho/ubuntu-weather-app/reboot-flatten-locationpage into lp:ubuntu-weather-app/reboot.

Commit message:
Flatten out ListModel in LocationPage and using needed data  directly from the location objects.

Requested reviews:
  Ubuntu Weather Developers (ubuntu-weather-dev)

For more details, see:
https://code.launchpad.net/~martin-borho/ubuntu-weather-app/reboot-flatten-locationpage/+merge/253762

Flatten out ListModel in LocationPage.

Using the needed data in the locations list (name, icon, temp) directy from the location objects and not from the UI improves the list. See screenshot: http://imgur.com/RFMwNI6 (Left one with this MP)

-- 
Your team Ubuntu Weather Developers is requested to review the proposed merge of lp:~martin-borho/ubuntu-weather-app/reboot-flatten-locationpage into lp:ubuntu-weather-app/reboot.
=== modified file 'app/ui/LocationsPage.qml'
--- app/ui/LocationsPage.qml	2015-03-18 00:05:43 +0000
+++ app/ui/LocationsPage.qml	2015-03-21 17:17:36 +0000
@@ -99,7 +99,7 @@
                         verticalCenter: parent.verticalCenter
                     }
                     elide: Text.ElideRight
-                    text: model.location.name
+                    text: name
                 }
 
                 Icon {
@@ -109,7 +109,7 @@
                         verticalCenter: parent.verticalCenter
                     }
                     height: units.gu(3)
-                    name: locationPage.iconMap[locationPages.contentItem.children[index].iconName] || ""
+                    name: icon
                     visible: locationsPage.state === "default"
                     width: units.gu(3)
                 }
@@ -126,11 +126,13 @@
                     elide: Text.ElideRight
                     font.pixelSize: units.gu(4)
                     font.weight: Font.Light
-                    horizontalAlignment: Text.AlignRight
-                    text: locationPages.contentItem.children[index].currentTemp ? locationPages.contentItem.children[index].currentTemp + settings.tempScale[1]
-                                                                                : ""
+                    horizontalAlignment: Text.AlignRight                    
+                    text: temp + ""+ settings.tempScale
                     visible: locationsPage.state === "default"
                 }
+                Component.onCompleted: {
+
+                }
             }
 
             ListItem.ThinDivider {
@@ -143,9 +145,16 @@
 
     function populateLocationsModel() {
         locationsModel.clear()
-
+        var loc = {}, data = {},
+            tempUnits = settings.tempScale === "°C" ? "metric" : "imperial";
         for (var i=0; i < weatherApp.locationsList.length; i++) {
-            locationsModel.append(weatherApp.locationsList[i])
+            data = weatherApp.locationsList[i];
+            loc = {
+                "name": data.location.name,
+                "temp": Math.round(data.data[0].current[tempUnits].temp).toString(),
+                "icon": iconMap[data.data[0].current.icon]
+            }
+            locationsModel.append(loc)
         }
     }
 

=== modified file 'po/com.ubuntu.weather.pot'
--- po/com.ubuntu.weather.pot	2015-03-19 10:21:28 +0000
+++ po/com.ubuntu.weather.pot	2015-03-21 17:17:36 +0000
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: ubuntu-weather-app\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-03-19 10:21+0000\n"
+"POT-Creation-Date: 2015-03-21 18:07+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"


Follow ups