ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #00189
[Merge] lp:~martin-borho/ubuntu-weather-app/reboot-hourly into lp:ubuntu-weather-app/reboot
Martin Borho has proposed merging lp:~martin-borho/ubuntu-weather-app/reboot-hourly into lp:ubuntu-weather-app/reboot.
Commit message:
Listview for hourly forecasts added, becomes visible when todays icon is clicked.
Requested reviews:
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot): continuous-integration
Ubuntu Weather Developers (ubuntu-weather-dev)
For more details, see:
https://code.launchpad.net/~martin-borho/ubuntu-weather-app/reboot-hourly/+merge/251367
Listview for hourly forecasts added, becomes visible when todays icon is clicked.
--
Your team Ubuntu Weather Developers is requested to review the proposed merge of lp:~martin-borho/ubuntu-weather-app/reboot-hourly into lp:ubuntu-weather-app/reboot.
=== added file 'app/components/HomeHourly.qml'
--- app/components/HomeHourly.qml 1970-01-01 00:00:00 +0000
+++ app/components/HomeHourly.qml 2015-02-28 16:31:40 +0000
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2015 Canonical Ltd
+ *
+ * This file is part of Ubuntu Weather App
+ *
+ * Ubuntu Weather App is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Ubuntu Weather App is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.3
+import Ubuntu.Components 1.1
+import Ubuntu.Components.ListItems 0.1 as ListItem
+import QtGraphicalEffects 1.0
+
+Item {
+ id: homeHourly
+ height: units.gu(32)
+ width: parent.width
+
+ property var forecasts: []
+ property string tempUnits: ""
+
+ onVisibleChanged: {
+ if(visible) {
+ ListView.model = forecasts.length
+ }
+ }
+
+ ListView {
+ id: hourlyForecasts
+ width:parent.width
+ height:parent.height
+ contentWidth: childrenRect.width
+ contentHeight: parent.height
+ model: forecasts.length
+ orientation: ListView.Horizontal
+ clip:true
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ homeGraphic.visible = true
+ }
+ }
+ delegate: Rectangle {
+ width: childrenRect.width
+ height: parent.height
+ property var hourData: forecasts[index]
+ Column {
+ id: hourColumn
+ width: units.gu(10)
+ height: childrenRect.height
+ anchors.verticalCenter: parent.verticalCenter
+ Label {
+ text: formatTimestamp(hourData.date, 'ddd')+" "+formatTime(hourData.date, 'h:mm')
+ fontSize: "small"
+ font.weight: Font.Light
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Item {
+ width: units.gu(7)
+ height: units.gu(7)
+ anchors.horizontalCenter: parent.horizontalCenter
+ Image {
+ id: iconImage
+ fillMode: Image.PreserveAspectFit
+ anchors.fill: parent
+ source: (hourData.icon !== undefined && iconMap[hourData.icon] !== undefined) ? iconMap[hourData.icon] : ""
+ }
+ ColorOverlay {
+ anchors.fill: iconImage
+ source: iconImage
+ color: UbuntuColors.orange
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ Label {
+ font.pixelSize: units.gu(3)
+ font.weight: Font.Light
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: Math.round(hourData[tempUnits].temp).toString()+settings.tempScale
+ }
+
+ }
+ Rectangle {
+ width: units.gu(0.1)
+ height: hourColumn.height
+ color: UbuntuColors.darkGrey
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+ }
+}
=== modified file 'app/ui/HomePage.qml'
--- app/ui/HomePage.qml 2015-02-23 03:41:30 +0000
+++ app/ui/HomePage.qml 2015-02-28 16:31:40 +0000
@@ -70,6 +70,14 @@
}
/*
+ Format time object by given format.
+ */
+ function formatTime(dateData, format) {
+ var date = new Date(dateData.year, dateData.month, dateData.date, dateData.hours, dateData.minutes)
+ return Qt.formatTime(date, i18n.tr(format))
+ }
+
+ /*
Flickable to scroll the location vertically.
The respective contentHeight gets calculated after the Location is filled with data.
*/
=== modified file 'app/ui/LocationPane.qml'
--- app/ui/LocationPane.qml 2015-02-23 03:41:30 +0000
+++ app/ui/LocationPane.qml 2015-02-28 16:31:40 +0000
@@ -61,7 +61,8 @@
current = data.data[0].current,
forecasts = data.data,
forecastsLength = forecasts.length,
- today = forecasts[0];
+ today = forecasts[0],
+ hourlyForecasts = [];
var tempUnits = settings.tempScale === "°C" ? "metric" : "imperial"
@@ -81,8 +82,17 @@
// set daily forecasts
if(forecastsLength > 0) {
- for(var x=1;x<forecastsLength;x++) {
- // print(JSON.stringify(forecasts[x][units]))
+ for(var x=0;x<forecastsLength;x++) {
+ // collect hourly forecasts if available
+ if(forecasts[x].hourly !== undefined && forecasts[x].hourly.length > 0) {
+ hourlyForecasts = hourlyForecasts.concat(forecasts[x].hourly)
+ }
+ if(x === 0) {
+ // skip todays daydata
+ continue;
+ }
+
+ // set daydata
var dayData = {
day: formatTimestamp(forecasts[x].date, 'dddd'),
low: Math.round(forecasts[x][tempUnits].tempMin).toString() + settings.tempScale,
@@ -93,6 +103,12 @@
}
}
setFlickableContentHeight();
+
+ // set data for hourly forecasts
+ if(hourlyForecasts.length > 0) {
+ homeHourly.forecasts = hourlyForecasts;
+ homeHourly.tempUnits = tempUnits;
+ }
}
Column {
@@ -112,6 +128,17 @@
HomeGraphic {
id: homeGraphic
icon: locationItem.icon
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ homeGraphic.visible = false;
+ }
+ }
+ }
+
+ HomeHourly {
+ id: homeHourly
+ visible: !homeGraphic.visible
}
HomeTempInfo {