← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~vthompson/ubuntu-weather-app/reboot-manage-current-location into lp:ubuntu-weather-app/reboot

 

Victor Thompson has proposed merging lp:~vthompson/ubuntu-weather-app/reboot-manage-current-location into lp:ubuntu-weather-app/reboot.

Commit message:
* Manage current location

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

For more details, see:
https://code.launchpad.net/~vthompson/ubuntu-weather-app/reboot-manage-current-location/+merge/260648

Manage current location
-- 
Your team Ubuntu Weather Developers is requested to review the proposed merge of lp:~vthompson/ubuntu-weather-app/reboot-manage-current-location into lp:ubuntu-weather-app/reboot.
=== modified file 'app/components/CurrentLocation.qml'
--- app/components/CurrentLocation.qml	2015-05-20 00:01:46 +0000
+++ app/components/CurrentLocation.qml	2015-05-30 17:55:16 +0000
@@ -54,7 +54,26 @@
         onCountChanged: {
             // Update the currentLocation if one is found and it does not match the stored location
             if (count > 0 && currentLocation.string !== geocodeModel.get(0).address.city) {
-                currentLocation.string = geocodeModel.get(0).address.city
+                var loc = geocodeModel.get(0)
+                currentLocation.string = loc.address.city
+                var addLoc = {
+                    "location": {
+                        "coord": {
+                            "lon": loc.coordinate.longitude,
+                            "lat": loc.coordinate.latitude
+                        },
+                        "name": loc.address.city,
+                        "country": loc.address.countryCode,
+                        "countryName": loc.address.country,
+                        "adminName1": loc.address.city,
+                        "adminName2": loc.address.state !== undefined ? loc.address.state : "",
+                        "adminName3": loc.address.countryCode
+                    }
+                }
+
+                console.log("Loc to add:", JSON.stringify(addLoc))
+
+                storage.addLocation(addLoc)
                 refreshData(false, true)
             }
         }

=== modified file 'app/ui/LocationsPage.qml'
--- app/ui/LocationsPage.qml	2015-05-20 00:08:32 +0000
+++ app/ui/LocationsPage.qml	2015-05-30 17:55:16 +0000
@@ -139,9 +139,6 @@
         var loc = {}, data = {},
             tempUnits = settings.tempScale === "°C" ? "metric" : "imperial";
 
-        // TODO: Manage the current location as an entry in the locationsList.
-        locationsModel.append({ "name": currentLocation.string, "temp": "0", "icon": "weather-clear-symbolic" })
-
         for (var i=0; i < weatherApp.locationsList.length; i++) {
             data = weatherApp.locationsList[i];
             loc = {


References