ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #02676
[Merge] lp:~vthompson/ubuntu-weather-app/reboot-static-current-location into lp:ubuntu-weather-app/reboot
Victor Thompson has proposed merging lp:~vthompson/ubuntu-weather-app/reboot-static-current-location into lp:ubuntu-weather-app/reboot.
Commit message:
* Make current location static in LocationsPage.
Requested reviews:
Ubuntu Weather Developers (ubuntu-weather-dev)
For more details, see:
https://code.launchpad.net/~vthompson/ubuntu-weather-app/reboot-static-current-location/+merge/261584
* Make current location static in LocationsPage.
--
Your team Ubuntu Weather Developers is requested to review the proposed merge of lp:~vthompson/ubuntu-weather-app/reboot-static-current-location into lp:ubuntu-weather-app/reboot.
=== modified file 'app/ubuntu-weather-app.qml'
--- app/ubuntu-weather-app.qml 2015-06-05 01:02:17 +0000
+++ app/ubuntu-weather-app.qml 2015-06-10 01:48:59 +0000
@@ -210,6 +210,10 @@
}
function moveLocation(from, to) {
+ // Indexes are offset by 1 to account for current location
+ from += 1
+ to += 1
+
// Update settings to respect new changes
if (from === settings.current) {
settings.current = to;
@@ -226,6 +230,8 @@
// Remove a location from the list
function removeLocation(index) {
+ // Indexes are offset by 1 to account for current location
+ index += 1
if (settings.current >= index) { // Update settings to respect new changes
settings.current -= settings.current;
}
@@ -242,7 +248,7 @@
indexes.sort(function(a,b) { return a - b })
for (i=0; i < indexes.length; i++) {
- if (settings.current >= i) { // Update settings to respect new changes
+ if (settings.current >= indexes[i] + 1) { // Update settings to respect new changes
settings.current -= settings.current;
}
}
@@ -251,7 +257,7 @@
var locations = []
for (i=0; i < indexes.length; i++) {
- locations.push(locationsList[indexes[i]].db.id)
+ locations.push(locationsList[indexes[i] + 1].db.id)
}
storage.clearMultiLocation(locations);
=== modified file 'app/ui/LocationsPage.qml'
--- app/ui/LocationsPage.qml 2015-06-05 23:15:57 +0000
+++ app/ui/LocationsPage.qml 2015-06-10 01:48:59 +0000
@@ -54,6 +54,10 @@
}
]
+ ListModel {
+ id: currentLocationModel
+ }
+
MultiSelectListView {
id: locationsListView
anchors {
@@ -62,6 +66,89 @@
model: ListModel {
id: locationsModel
}
+ header: ListView {
+ id: currentLocationListView
+ anchors {
+ left: parent.left
+ leftMargin: units.gu(2)
+ right: parent.right
+ rightMargin: units.gu(2)
+ top: parent.top
+
+ }
+ height: units.gu(8)
+ interactive: false
+ model: currentLocationModel
+ delegate: WeatherListItem {
+ id: currentLocationsListItem
+
+ onItemClicked: {
+ settings.current = index;
+ pageStack.pop()
+ }
+
+ Column {
+ anchors {
+ left: parent.left
+ right: currentWeatherImage.visible ? currentWeatherImage.left : parent.right
+ rightMargin: units.gu(1)
+ verticalCenter: parent.verticalCenter
+ }
+
+ Label {
+ id: currentLocationName
+ elide: Text.ElideRight
+ fontSize: "medium"
+ text: i18n.tr("Current Location")
+ }
+ Label {
+ id: currentLocationName2
+ color: UbuntuColors.lightGrey
+ elide: Text.ElideRight
+ fontSize: "small"
+ font.weight: Font.Light
+ text: name + ", " + (adminName1 == name ? countryName : adminName1)
+ }
+ }
+
+ Icon {
+ id: currentWeatherImage
+ anchors {
+ right: parent.right
+ rightMargin: units.gu(12)
+ verticalCenter: parent.verticalCenter
+ }
+ name: icon
+ height: units.gu(3)
+ width: units.gu(3)
+ visible: locationsPage.state === "default"
+ }
+
+ Label {
+ id: currentTemperatureLabel
+ anchors {
+ left: currentWeatherImage.right
+ leftMargin: units.gu(1)
+ right: parent.right
+ verticalCenter: parent.verticalCenter
+ }
+ color: UbuntuColors.orange
+ elide: Text.ElideRight
+ font.pixelSize: units.gu(4)
+ font.weight: Font.Light
+ horizontalAlignment: Text.AlignRight
+ text: temp + settings.tempScale
+ visible: locationsPage.state === "default"
+ }
+ }
+
+ ListItem.ThinDivider {
+ anchors {
+ bottom: parent.bottom
+ }
+ }
+ }
+
delegate: WeatherListItem {
id: locationsListItem
leftSideAction: Remove {
@@ -71,7 +158,7 @@
reorderable: true
onItemClicked: {
- settings.current = index;
+ settings.current = index + 1;
pageStack.pop()
}
onReorder: {
@@ -99,7 +186,7 @@
id: locationName
elide: Text.ElideRight
fontSize: "medium"
- text: index != 0 ? name : i18n.tr("Current Location")
+ text: name
}
Label {
id: locationName2
@@ -107,8 +194,7 @@
elide: Text.ElideRight
fontSize: "small"
font.weight: Font.Light
- text: index != 0 ? (adminName1 == name ? countryName : adminName1)
- : name + ", " + (adminName1 == name ? countryName : adminName1)
+ text: adminName1 == name ? countryName : adminName1
}
}
@@ -152,6 +238,7 @@
}
function populateLocationsModel() {
+ currentLocationModel.clear()
locationsModel.clear()
var loc = {}, data = {},
tempUnits = settings.tempScale === "°C" ? "metric" : "imperial";
@@ -166,7 +253,12 @@
"temp": Math.round(data.data[0].current[tempUnits].temp).toString(),
"icon": iconMap[data.data[0].current.icon]
}
- locationsModel.append(loc)
+
+ if (i > 0) {
+ locationsModel.append(loc)
+ } else {
+ currentLocationModel.append(loc)
+ }
}
}
Follow ups