Merge lp:~nik90/ubuntu-clock-app/sync-clock-backend into lp:ubuntu-clock-app/saucy
- sync-clock-backend
- Merge into saucy
Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Alan Pope πΊπ§π± π¦ | ||||||||||||
Approved revision: | 223 | ||||||||||||
Merged at revision: | 205 | ||||||||||||
Proposed branch: | lp:~nik90/ubuntu-clock-app/sync-clock-backend | ||||||||||||
Merge into: | lp:ubuntu-clock-app/saucy | ||||||||||||
Diff against target: |
370 lines (+124/-59) 5 files modified
clock/ClockPage.qml (+57/-31) clock/EasterEgg.qml (+3/-3) clock/GeoIPModel.qml (+31/-0) clock/WorldClockModel.qml (+21/-22) clock/WorldPage.qml (+12/-3) |
||||||||||||
To merge this branch: | bzr merge lp:~nik90/ubuntu-clock-app/sync-clock-backend | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
David Planella | Needs Information | ||
Review via email: mp+186923@code.launchpad.net |
Commit message
This commits implements the following,
- Remove the ability to see world clock as current location (since on changing system time, this will not be reflected in the clock app causing a discrepancy)
- Always show current system time to maintain uniformity between clock app, indicator time and welcome screen time
- Change world clock time diff calculation to be based on utc time instead of local time (more reliable)
- Add the ability for the user to edit/set the current location name
- Retrieve current location *automatically* using geoIP from http://
Description of the change
This MP implements the following,
- Remove the ability to see world clock as current location (since on changing system time, this will not be reflected in the clock app causing a discrepancy)
- Always show current system time to maintain uniformity between clock app, indicator time and welcome screen time
- Change world clock time diff calculation to be based on utc time instead of local time (more reliable)
- Add the ability for the user to edit/set the current location name
- Retrieve current location *automatically* using geoIP from http://
GPS Location backend (using qtlocation) will be added in a future MP. This MP is more focused on fixing issues with the clock app not following system time. As a result, dont want these bug fixes waiting on GPS.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
David Planella (dpm) wrote : | # |
Nice work as usual, Nekhelesh. A couple of questions:
121 + text: i18n.tr("Retrieving current location...")
- What's the behaviour if you're offline?
- Is GeoIP a backend that could be accessed via Qt Location instead of querying http://
Nekhelesh Ramananthan (nik90) wrote : | # |
> Nice work as usual, Nekhelesh. A couple of questions:
>
> 121 + text: i18n.tr("Retrieving current location...")
>
> - What's the behaviour if you're offline?
>
Nice question. This is something I specifically tested to ensure that when offline, it notifies the user. So when offline, it will set the string to "Set current location name". The user can click the current location list item to set it manually via the same database used to add a world city. You can test this behaviour on your desktop by clearing the clock database and then going offline.
> - Is GeoIP a backend that could be accessed via Qt Location instead of
> querying http://
I will look into this. Popey contact bzoltan for sample code to get location via GPS. You can find his branch at https:/
Nekhelesh Ramananthan (nik90) wrote : | # |
After a discussion with dpm and bzoltan this morning, it was concluded that qtlocation is not able to retrieve location reliably and quickly. And hence until that is worked out, the direct lookup method is acceptable. We will return to the qtlocation method in the near future.
David Planella (dpm) wrote : | # |
Note that the the initial (long) delay in getting the GPS location is
probably to be expected and it is not a bug in Qt Location.
I'm not an expert on GPS, but I'm told it can take around 12 mins to get a
fix (your position from GPS measurements), as we currently don't have any
AGPS support to speed it. Take this statement with a pinch of salt, but
also bear it in mind when testing GPS support.
Thanks!
On Wed, Sep 25, 2013 at 1:44 PM, Nekhelesh Ramananthan <
<email address hidden>> wrote:
> The proposal to merge lp:~nik90/ubuntu-clock-app/sync-clock-backend into
> lp:ubuntu-clock-app has been updated.
>
> Status: Needs review => Work in progress
>
> For more details, see:
>
> https:/
> --
>
> https:/
> You are reviewing the proposed merge of
> lp:~nik90/ubuntu-clock-app/sync-clock-backend into lp:ubuntu-clock-app.
>
Nekhelesh Ramananthan (nik90) wrote : | # |
@dpm, thnx for the info. I will be testing the qtlocation this weekend. While using qtlocation, i had a few crashes on the desktop which is not good. Anyways this branch is more focussed on fixing the default time shown by the clock app and ensure it is the same as the system time. As a bonus, I added the geoIP feature for automatic location retrieval. So from the perspective I consider this MP complete and ready for trunk merge.
As said above, I will test qtlocation in the weekend and propose that in a new branch by itself to spot any regression due to qtlocation quicker. Please approve if you agree.
- 222. By Nekhelesh Ramananthan
-
merge from trunk
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:222
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 223. By Nekhelesh Ramananthan
-
merged trunk
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:223
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'clock/ClockPage.qml' | |||
2 | --- clock/ClockPage.qml 2013-09-26 06:14:47 +0000 | |||
3 | +++ clock/ClockPage.qml 2013-09-27 08:38:25 +0000 | |||
4 | @@ -30,18 +30,23 @@ | |||
5 | 30 | 30 | ||
6 | 31 | // Property to hold the formatted time string to show on the screen | 31 | // Property to hold the formatted time string to show on the screen |
7 | 32 | property string currentTimeFormatted | 32 | property string currentTimeFormatted |
9 | 33 | property real currentTimeStamp | 33 | property real currentUTCTime |
10 | 34 | property real diff: new Date().getTimezoneOffset() | 34 | property real diff: new Date().getTimezoneOffset() |
11 | 35 | property alias currentCity: currentLocationCity.text | ||
12 | 36 | property alias currentLat: easterEggCircle.latitude | ||
13 | 37 | property alias currentLng: easterEggCircle.longitude | ||
14 | 35 | 38 | ||
15 | 36 | Component.onCompleted: { | 39 | Component.onCompleted: { |
21 | 37 | Utils.log("ClockPage loaded"); | 40 | // TODO: Query GPS for location data |
22 | 38 | diff = worldModel.timeDiff; | 41 | Utils.log("ClockPage loaded"); |
23 | 39 | currentLocationCity.text = worldModel.city; | 42 | if (worldModel.city !== "undefined") { |
24 | 40 | easterEggCircle.longitude = worldModel.longitude; | 43 | currentCity = worldModel.city; |
25 | 41 | easterEggCircle.latitude = worldModel.latitude; | 44 | currentLng = worldModel.longitude; |
26 | 45 | currentLat = worldModel.latitude; | ||
27 | 46 | } | ||
28 | 42 | Utils.log("Saved Current Location: " + worldModel.city); | 47 | Utils.log("Saved Current Location: " + worldModel.city); |
31 | 43 | Utils.log("Saved Current Location Coordinates: " + easterEggCircle.longitude + "," + easterEggCircle.latitude) | 48 | Utils.log("Saved Current Location Coordinates: " + currentLng + "," + currentLat) |
32 | 44 | currentTimeFormatted = Qt.formatTime(new Date(currentTimeStamp + (diff * 60000)), "hh:mm") | 49 | currentTimeFormatted = Qt.formatTime(new Date(), "hh:mm") |
33 | 45 | updateTime(); | 50 | updateTime(); |
34 | 46 | } | 51 | } |
35 | 47 | 52 | ||
36 | @@ -53,13 +58,12 @@ | |||
37 | 53 | keywords: i18n.tr("Add;Timezone;Timezones;World;City;Cities;Town;Towns;Place;Places;Location;Locations;Time;Locale;Local;Current") | 58 | keywords: i18n.tr("Add;Timezone;Timezones;World;City;Cities;Town;Towns;Place;Places;Location;Locations;Time;Locale;Local;Current") |
38 | 54 | description: "Add a world city" | 59 | description: "Add a world city" |
39 | 55 | iconSource: Qt.resolvedUrl("../images/add_icon.png") | 60 | iconSource: Qt.resolvedUrl("../images/add_icon.png") |
41 | 56 | onTriggered: pagestack.push(Qt.resolvedUrl("WorldPage.qml")) | 61 | onTriggered: pagestack.push(Qt.resolvedUrl("WorldPage.qml"), {"isWorldCity": true}) |
42 | 57 | } | 62 | } |
43 | 58 | ] | 63 | ] |
44 | 59 | 64 | ||
45 | 60 | function onTimerUpdate(now) { | 65 | function onTimerUpdate(now) { |
48 | 61 | currentTimeFormatted = Qt.formatTime(new Date(currentTimeStamp + (diff * 60000)), "hh:mm") | 66 | currentTimeFormatted = Qt.formatTime(new Date(), "hh:mm") |
47 | 62 | now.setMinutes(now.getMinutes() + diff) | ||
49 | 63 | clockFace.timeChanged(now) | 67 | clockFace.timeChanged(now) |
50 | 64 | if (now.getUTCSeconds() == 0) { | 68 | if (now.getUTCSeconds() == 0) { |
51 | 65 | updateTime(); | 69 | updateTime(); |
52 | @@ -68,15 +72,42 @@ | |||
53 | 68 | 72 | ||
54 | 69 | function updateTime() { | 73 | function updateTime() { |
55 | 70 | var now = new Date(); | 74 | var now = new Date(); |
58 | 71 | currentTimeStamp = now.getTime(); | 75 | now.setMinutes(now.getMinutes() + diff) |
59 | 72 | } | 76 | currentUTCTime = now.getTime(); |
60 | 77 | } | ||
61 | 78 | |||
62 | 79 | GeoIPModel { | ||
63 | 80 | id: geoIP | ||
64 | 81 | onStatusChanged: { | ||
65 | 82 | if (status == XmlListModel.Ready && geoIP.get(0).city != worldModel.city && geoIP.get(0).city != "None") { | ||
66 | 83 | Utils.log("Retrieved current location using GeoIP. Writing into database and setting it as current location") | ||
67 | 84 | currentCity = geoIP.get(0).city | ||
68 | 85 | currentLng = geoIP.get(0).lng | ||
69 | 86 | currentLat = geoIP.get(0).lat | ||
70 | 87 | worldModel.appendCurrentLocation(currentCity, currentLng, currentLat); | ||
71 | 88 | } | ||
72 | 89 | else if (status == XmlListModel.Ready && geoIP.get(0).city == "None") { | ||
73 | 90 | if (worldModel.city == "undefined") { | ||
74 | 91 | currentCity = i18n.tr("Set current location name") | ||
75 | 92 | currentLocation.progression = true | ||
76 | 93 | } | ||
77 | 94 | } | ||
78 | 95 | else if(status == XmlListModel.Error) { | ||
79 | 96 | Utils.error("Unable to retrieve GeoIP Data -> " + geoIP.errorString()) | ||
80 | 97 | if (worldModel.city == "undefined") { | ||
81 | 98 | currentCity = i18n.tr("Set current location name") | ||
82 | 99 | currentLocation.progression = true | ||
83 | 100 | } | ||
84 | 101 | } | ||
85 | 102 | } | ||
86 | 103 | } | ||
87 | 73 | 104 | ||
88 | 74 | Flickable { | 105 | Flickable { |
89 | 75 | id: clockAnimationContainer | 106 | id: clockAnimationContainer |
90 | 76 | 107 | ||
91 | 77 | clip: true; | 108 | clip: true; |
92 | 78 | anchors.fill: parent | 109 | anchors.fill: parent |
94 | 79 | contentWidth: parent.width | 110 | contentWidth: parent.width |
95 | 80 | contentHeight: clockFace.height + clockFace.anchors.topMargin + savedWorldClock.height + savedWorldClock.anchors.topMargin + units.gu(3) | 111 | contentHeight: clockFace.height + clockFace.anchors.topMargin + savedWorldClock.height + savedWorldClock.anchors.topMargin + units.gu(3) |
96 | 81 | 112 | ||
97 | 82 | // Label to show the current time | 113 | // Label to show the current time |
98 | @@ -108,10 +139,10 @@ | |||
99 | 108 | anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter } | 139 | anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter } |
100 | 109 | 140 | ||
101 | 110 | onClicked: { | 141 | onClicked: { |
103 | 111 | if (easterEggCircle.isReady == XmlListModel.Ready) { | 142 | if (easterEggCircle.isReady == XmlListModel.Ready && worldModel.city !== "undefined") { |
104 | 112 | clockFace.state == "" ? clockFace.state = "easteregg" : clockFace.state = ""; | 143 | clockFace.state == "" ? clockFace.state = "easteregg" : clockFace.state = ""; |
105 | 113 | } else { | 144 | } else { |
107 | 114 | Utils.log("Sunrise/Sunset times not yet loaded.") | 145 | Utils.error("Sunrise/Sunset times cannot be loaded without setting the current location or without a internet connection.") |
108 | 115 | } | 146 | } |
109 | 116 | } | 147 | } |
110 | 117 | 148 | ||
111 | @@ -127,7 +158,6 @@ | |||
112 | 127 | name: "easteregg" | 158 | name: "easteregg" |
113 | 128 | PropertyChanges { target: easterEggCircle; opacity: 1; } | 159 | PropertyChanges { target: easterEggCircle; opacity: 1; } |
114 | 129 | PropertyChanges { target: currentTimeLabel; opacity: 0; } | 160 | PropertyChanges { target: currentTimeLabel; opacity: 0; } |
115 | 130 | // TODO: Do some caching of data here. Store data locally to reduce API calls. | ||
116 | 131 | PropertyChanges { target: easterEggCircle; sunriseLabel: easterEggCircle.getSunTime(easterEggCircle.model.get(0).sunriseTime); } | 161 | PropertyChanges { target: easterEggCircle; sunriseLabel: easterEggCircle.getSunTime(easterEggCircle.model.get(0).sunriseTime); } |
117 | 132 | PropertyChanges { target: easterEggCircle; sunsetLabel: easterEggCircle.getSunTime(easterEggCircle.model.get(0).sunsetTime); } | 162 | PropertyChanges { target: easterEggCircle; sunsetLabel: easterEggCircle.getSunTime(easterEggCircle.model.get(0).sunsetTime); } |
118 | 133 | }, | 163 | }, |
119 | @@ -161,20 +191,24 @@ | |||
120 | 161 | 191 | ||
121 | 162 | ListItem.Standard { | 192 | ListItem.Standard { |
122 | 163 | id: currentLocation | 193 | id: currentLocation |
123 | 194 | |||
124 | 164 | Label { | 195 | Label { |
125 | 165 | id: currentLocationCity | 196 | id: currentLocationCity |
128 | 166 | // TRANSLATORS: this refers to Coordinated Universal Time | 197 | text: i18n.tr("Retrieving current location...") |
127 | 167 | text: i18n.tr("UTC") | ||
129 | 168 | anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: units.gu(3) } | 198 | anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: units.gu(3) } |
130 | 169 | color: Theme.palette.normal.baseText | 199 | color: Theme.palette.normal.baseText |
131 | 170 | fontSize: "large" | 200 | fontSize: "large" |
132 | 171 | } | 201 | } |
133 | 172 | Label { | 202 | Label { |
136 | 173 | text: Qt.formatTime(new Date(currentTimeStamp + (diff * 60000)), "hh:mm A") | 203 | id: currentLocationTime |
137 | 174 | anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: units.gu(2) } | 204 | visible: worldModel.city !== "undefined" ? true : false |
138 | 205 | text: currentTimeFormatted | ||
139 | 206 | anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: currentLocation.progression == true ? units.gu(6) : units.gu(2) } | ||
140 | 175 | color: Theme.palette.normal.baseText | 207 | color: Theme.palette.normal.baseText |
141 | 176 | fontSize: "large" | 208 | fontSize: "large" |
142 | 177 | } | 209 | } |
143 | 210 | |||
144 | 211 | onClicked: pagestack.push(Qt.resolvedUrl("WorldPage.qml"), {"isWorldCity": false}) | ||
145 | 178 | } | 212 | } |
146 | 179 | 213 | ||
147 | 180 | ListItem.Header { | 214 | ListItem.Header { |
148 | @@ -190,7 +224,7 @@ | |||
149 | 190 | id: listWorldClocks | 224 | id: listWorldClocks |
150 | 191 | 225 | ||
151 | 192 | clip: true | 226 | clip: true |
153 | 193 | anchors { left: parent.left; right: parent.right } | 227 | anchors { left: parent.left; right: parent.right } |
154 | 194 | height: 3 * units.gu(6) + units.gu(1) // height is defined to show 3 items by default with a small margin | 228 | height: 3 * units.gu(6) + units.gu(1) // height is defined to show 3 items by default with a small margin |
155 | 195 | model: worldModel | 229 | model: worldModel |
156 | 196 | currentIndex: -1 | 230 | currentIndex: -1 |
157 | @@ -204,7 +238,7 @@ | |||
158 | 204 | } | 238 | } |
159 | 205 | 239 | ||
160 | 206 | Label { | 240 | Label { |
162 | 207 | text: Qt.formatTime(new Date(currentTimeStamp + (rawOffSet * 60000)), "hh:mm A") | 241 | text: Qt.formatTime(new Date(currentUTCTime + (rawOffSet * 60000)), "hh:mm") |
163 | 208 | anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: units.gu(2) } | 242 | anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: units.gu(2) } |
164 | 209 | color: Theme.palette.normal.baseText | 243 | color: Theme.palette.normal.baseText |
165 | 210 | fontSize: "large" | 244 | fontSize: "large" |
166 | @@ -221,14 +255,6 @@ | |||
167 | 221 | onItemRemoved: { | 255 | onItemRemoved: { |
168 | 222 | worldModel.removePreset(index); | 256 | worldModel.removePreset(index); |
169 | 223 | } | 257 | } |
170 | 224 | |||
171 | 225 | onClicked: { | ||
172 | 226 | currentLocationCity.text = cityName; | ||
173 | 227 | diff = rawOffSet; | ||
174 | 228 | easterEggCircle.longitude = longitude; | ||
175 | 229 | easterEggCircle.latitude = latitude; | ||
176 | 230 | worldModel.appendCurrentLocation(cityName, diff, longitude, latitude); | ||
177 | 231 | } | ||
178 | 232 | } | 258 | } |
179 | 233 | } | 259 | } |
180 | 234 | } | 260 | } |
181 | 235 | 261 | ||
182 | === modified file 'clock/EasterEgg.qml' | |||
183 | --- clock/EasterEgg.qml 2013-09-03 18:55:04 +0000 | |||
184 | +++ clock/EasterEgg.qml 2013-09-27 08:38:25 +0000 | |||
185 | @@ -86,8 +86,8 @@ | |||
186 | 86 | } | 86 | } |
187 | 87 | 87 | ||
188 | 88 | // FIXME: Replace these constant values with user's location coordinates when automatic location detection is implemented. | 88 | // FIXME: Replace these constant values with user's location coordinates when automatic location detection is implemented. |
191 | 89 | property real latitude: 52.01; | 89 | property real latitude: 200; |
192 | 90 | property real longitude: 4.35; | 90 | property real longitude: 200; |
193 | 91 | 91 | ||
194 | 92 | // properties to set/retrieve the sunrise and sunset times | 92 | // properties to set/retrieve the sunrise and sunset times |
195 | 93 | property alias sunriseLabel: sunriseTimeLabel.text; | 93 | property alias sunriseLabel: sunriseTimeLabel.text; |
196 | @@ -134,7 +134,7 @@ | |||
197 | 134 | var savedData = getSavedData(); | 134 | var savedData = getSavedData(); |
198 | 135 | var checkedDate = savedData[0][1].split('T')[0] | 135 | var checkedDate = savedData[0][1].split('T')[0] |
199 | 136 | var date = new Date().toISOString(); | 136 | var date = new Date().toISOString(); |
201 | 137 | if (status == XmlListModel.Ready && checkedDate != date.split('T')[0]){ | 137 | if (status == XmlListModel.Ready && checkedDate != date.split('T')[0] && longitude != 200 && latitude != 200){ |
202 | 138 | sunriseTimeLabel.text = getSunTime(sunRiseModel.get(0).sunriseTime); | 138 | sunriseTimeLabel.text = getSunTime(sunRiseModel.get(0).sunriseTime); |
203 | 139 | sunsetTimeLabel.text = getSunTime(sunRiseModel.get(0).sunsetTime); | 139 | sunsetTimeLabel.text = getSunTime(sunRiseModel.get(0).sunsetTime); |
204 | 140 | saveSunTimes(date, sunriseTimeLabel.text, sunsetTimeLabel.text); | 140 | saveSunTimes(date, sunriseTimeLabel.text, sunsetTimeLabel.text); |
205 | 141 | 141 | ||
206 | === added file 'clock/GeoIPModel.qml' | |||
207 | --- clock/GeoIPModel.qml 1970-01-01 00:00:00 +0000 | |||
208 | +++ clock/GeoIPModel.qml 2013-09-27 08:38:25 +0000 | |||
209 | @@ -0,0 +1,31 @@ | |||
210 | 1 | /* | ||
211 | 2 | * Copyright (C) 2013 Canonical Ltd | ||
212 | 3 | * | ||
213 | 4 | * This program is free software: you can redistribute it and/or modify | ||
214 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
215 | 6 | * published by the Free Software Foundation. | ||
216 | 7 | * | ||
217 | 8 | * This program is distributed in the hope that it will be useful, | ||
218 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
219 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
220 | 11 | * GNU General Public License for more details. | ||
221 | 12 | * | ||
222 | 13 | * You should have received a copy of the GNU General Public License | ||
223 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
224 | 15 | * | ||
225 | 16 | * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com> | ||
226 | 17 | */ | ||
227 | 18 | |||
228 | 19 | import QtQuick 2.0 | ||
229 | 20 | import QtQuick.XmlListModel 2.0 | ||
230 | 21 | |||
231 | 22 | // Xml model to retrieve user's current location based on geoIP | ||
232 | 23 | XmlListModel { | ||
233 | 24 | id: geoIPModel; | ||
234 | 25 | |||
235 | 26 | source: "http://geoip.ubuntu.com/lookup" | ||
236 | 27 | query: "/Response" | ||
237 | 28 | XmlRole { name: "city"; query: "City/string()"; isKey: true } | ||
238 | 29 | XmlRole { name: "lat"; query: "Latitude/string()"; isKey: true } | ||
239 | 30 | XmlRole { name: "lng"; query: "Longitude/string()"; isKey: true } | ||
240 | 31 | } | ||
241 | 0 | 32 | ||
242 | === modified file 'clock/WorldClockModel.qml' | |||
243 | --- clock/WorldClockModel.qml 2013-07-01 14:40:35 +0000 | |||
244 | +++ clock/WorldClockModel.qml 2013-09-27 08:38:25 +0000 | |||
245 | @@ -27,31 +27,31 @@ | |||
246 | 27 | readonly property string dbVersion: "0.1" | 27 | readonly property string dbVersion: "0.1" |
247 | 28 | readonly property string dbDescription: "World Clock" | 28 | readonly property string dbDescription: "World Clock" |
248 | 29 | 29 | ||
253 | 30 | property real timeDiff: new Date().getTimezoneOffset() | 30 | property string city: "undefined"; |
254 | 31 | property string city: "UTC"; | 31 | property real longitude: 200; |
255 | 32 | property real longitude: 4.35; | 32 | property real latitude: 200; |
252 | 33 | property real latitude: 52.01; | ||
256 | 34 | 33 | ||
257 | 35 | property var _db: null | 34 | property var _db: null |
258 | 36 | 35 | ||
260 | 37 | function appendCurrentLocation(cityname, rawOffSet, longitude, latitude) | 36 | function appendCurrentLocation(cityname, longitude, latitude) |
261 | 38 | { | 37 | { |
262 | 39 | try { | 38 | try { |
263 | 40 | _db.transaction(function(tx){ | 39 | _db.transaction(function(tx){ |
264 | 41 | var currentValue; | 40 | var currentValue; |
265 | 42 | var res = tx.executeSql('SELECT * FROM CurrentClock'); | 41 | var res = tx.executeSql('SELECT * FROM CurrentClock'); |
278 | 43 | if (res.rows.length > 0) { | 42 | |
279 | 44 | currentValue = res.rows.item(0).rawOffSet; | 43 | if (res.rows.length > 0) |
280 | 45 | } | 44 | currentValue = res.rows.item(0).cityName; |
281 | 46 | 45 | ||
282 | 47 | if (currentValue !== rawOffSet) { | 46 | if (currentValue !== undefined) // Update existing value or insert if none |
283 | 48 | // Update existing value or insert if none | 47 | res = tx.executeSql('UPDATE CurrentClock SET cityName = ?, longitude = ?, latitude = ?', [cityname, longitude, latitude]); |
284 | 49 | if (currentValue !== undefined) { | 48 | else |
285 | 50 | res = tx.executeSql('UPDATE CurrentClock SET rawOffSet = ?, cityName = ?, longitude = ?, latitude = ?', [rawOffSet, cityname, longitude, latitude]); | 49 | res = tx.executeSql('INSERT INTO CurrentClock VALUES(?, ?, ?)', [cityname, longitude, latitude]); |
286 | 51 | } else { | 50 | |
287 | 52 | res = tx.executeSql('INSERT INTO CurrentClock VALUES(?, ?, ?, ?)', [cityname, rawOffSet, longitude, latitude]); | 51 | clockPage.currentCity = model.city = cityname |
288 | 53 | } | 52 | clockPage.currentLng = model.longitude = longitude |
289 | 54 | } | 53 | clockPage.currentLat = model.latitude = latitude |
290 | 54 | Utils.log("Updating current location (manually)") | ||
291 | 55 | }); | 55 | }); |
292 | 56 | } catch (err) { | 56 | } catch (err) { |
293 | 57 | Utils.error("Error setting current location '" + "': " + err); | 57 | Utils.error("Error setting current location '" + "': " + err); |
294 | @@ -86,7 +86,7 @@ | |||
295 | 86 | } | 86 | } |
296 | 87 | try { | 87 | try { |
297 | 88 | _db.transaction(function(tx){ | 88 | _db.transaction(function(tx){ |
299 | 89 | tx.executeSql('CREATE TABLE IF NOT EXISTS CurrentClock(cityName TEXT, rawOffSet REAL, longitude REAL, latitude REAL)'); | 89 | tx.executeSql('CREATE TABLE IF NOT EXISTS CurrentClock(cityName TEXT, longitude REAL, latitude REAL)'); |
300 | 90 | }); | 90 | }); |
301 | 91 | } catch (err) { | 91 | } catch (err) { |
302 | 92 | Utils.error("Error creating CurrentClock table in db:" + err); | 92 | Utils.error("Error creating CurrentClock table in db:" + err); |
303 | @@ -108,9 +108,9 @@ | |||
304 | 108 | if (res.rows.length > 0) { | 108 | if (res.rows.length > 0) { |
305 | 109 | for (var i = 0; i < res.rows.length; i++) { | 109 | for (var i = 0; i < res.rows.length; i++) { |
306 | 110 | model.append({"cityName" : res.rows.item(i).cityName, | 110 | model.append({"cityName" : res.rows.item(i).cityName, |
310 | 111 | "rawOffSet": res.rows.item(i).rawOffSet, | 111 | "rawOffSet": res.rows.item(i).rawOffSet, |
311 | 112 | "longitude": res.rows.item(i).longitude, | 112 | "longitude": res.rows.item(i).longitude, |
312 | 113 | "latitude" : res.rows.item(i).latitude | 113 | "latitude" : res.rows.item(i).latitude |
313 | 114 | }); | 114 | }); |
314 | 115 | } | 115 | } |
315 | 116 | } | 116 | } |
316 | @@ -125,7 +125,6 @@ | |||
317 | 125 | var currentstate = tx.executeSql('SELECT * FROM CurrentClock ORDER BY cityName'); | 125 | var currentstate = tx.executeSql('SELECT * FROM CurrentClock ORDER BY cityName'); |
318 | 126 | if (currentstate.rows.length > 0) { | 126 | if (currentstate.rows.length > 0) { |
319 | 127 | city = currentstate.rows.item(0).cityName; | 127 | city = currentstate.rows.item(0).cityName; |
320 | 128 | timeDiff = currentstate.rows.item(0).rawOffSet; | ||
321 | 129 | longitude = currentstate.rows.item(0).longitude; | 128 | longitude = currentstate.rows.item(0).longitude; |
322 | 130 | latitude = currentstate.rows.item(0).latitude; | 129 | latitude = currentstate.rows.item(0).latitude; |
323 | 131 | } | 130 | } |
324 | 132 | 131 | ||
325 | === modified file 'clock/WorldPage.qml' | |||
326 | --- clock/WorldPage.qml 2013-09-04 11:28:52 +0000 | |||
327 | +++ clock/WorldPage.qml 2013-09-27 08:38:25 +0000 | |||
328 | @@ -23,14 +23,20 @@ | |||
329 | 23 | Page { | 23 | Page { |
330 | 24 | id: worldPage | 24 | id: worldPage |
331 | 25 | 25 | ||
332 | 26 | property bool isWorldCity; | ||
333 | 27 | |||
334 | 26 | visible: false; | 28 | visible: false; |
336 | 27 | title: i18n.tr("Add City") | 29 | title: isWorldCity ? i18n.tr("Add City") : i18n.tr("Edit Current Location") |
337 | 28 | 30 | ||
338 | 29 | function getTimeDifference(data) { | 31 | function getTimeDifference(data) { |
339 | 30 | var worldTime = data.split(' ')[1].split(':'); | 32 | var worldTime = data.split(' ')[1].split(':'); |
340 | 31 | var hoursWT = parseInt(worldTime[0]); | 33 | var hoursWT = parseInt(worldTime[0]); |
341 | 32 | var minutesWT = parseInt(worldTime[1]); | 34 | var minutesWT = parseInt(worldTime[1]); |
342 | 33 | var now = new Date(); | 35 | var now = new Date(); |
343 | 36 | var UTCdiff = new Date().getTimezoneOffset() | ||
344 | 37 | now.setMinutes(now.getMinutes() + UTCdiff) | ||
345 | 38 | |||
346 | 39 | // Calculating world city time diff w.r.t UTC | ||
347 | 34 | return ((hoursWT - now.getHours()) * 60 + (minutesWT - now.getMinutes())); | 40 | return ((hoursWT - now.getHours()) * 60 + (minutesWT - now.getMinutes())); |
348 | 35 | } | 41 | } |
349 | 36 | 42 | ||
350 | @@ -48,7 +54,10 @@ | |||
351 | 48 | 54 | ||
352 | 49 | onStatusChanged: { | 55 | onStatusChanged: { |
353 | 50 | if(status == XmlListModel.Ready && worldClockList.city != "null") { | 56 | if(status == XmlListModel.Ready && worldClockList.city != "null") { |
355 | 51 | worldModel.appendPreset(worldClockList.city, getTimeDifference(cityDetailsModel.get(0).time), worldClockList.lng, worldClockList.lat); | 57 | if (isWorldCity) |
356 | 58 | worldModel.appendPreset(worldClockList.city, getTimeDifference(cityDetailsModel.get(0).time), worldClockList.lng, worldClockList.lat); | ||
357 | 59 | else | ||
358 | 60 | worldModel.appendCurrentLocation(worldClockList.city, worldClockList.lng, worldClockList.lat); | ||
359 | 52 | worldClockList.clearUserSearch(); | 61 | worldClockList.clearUserSearch(); |
360 | 53 | pageStack.pop() | 62 | pageStack.pop() |
361 | 54 | } | 63 | } |
362 | @@ -61,7 +70,7 @@ | |||
363 | 61 | lat = searchModel.get(index).lat; | 70 | lat = searchModel.get(index).lat; |
364 | 62 | lng = searchModel.get(index).lng; | 71 | lng = searchModel.get(index).lng; |
365 | 63 | city = searchModel.get(index).city; | 72 | city = searchModel.get(index).city; |
367 | 64 | cityDetailsModel.reload() | 73 | cityDetailsModel.reload() |
368 | 65 | } | 74 | } |
369 | 66 | } | 75 | } |
370 | 67 | } | 76 | } |
PASSED: Continuous integration, rev:219 91.189. 93.70:8080/ job/ubuntu- clock-app- ci/35/ 91.189. 93.70:8080/ job/generic- mediumtests/ 464 91.189. 93.70:8080/ job/ubuntu- clock-app- precise- amd64-ci/ 35 91.189. 93.70:8080/ job/ubuntu- clock-app- quantal- amd64-ci/ 35 91.189. 93.70:8080/ job/ubuntu- clock-app- raring- amd64-ci/ 35 91.189. 93.70:8080/ job/ubuntu- clock-app- saucy-amd64- ci/35
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/ubuntu- clock-app- ci/35/rebuild
http://