Merge lp:~nik90/ubuntu-clock-app/sync-clock-backend into lp:ubuntu-clock-app/saucy

Proposed by Nekhelesh Ramananthan
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
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://geoip.ubuntu.com/lookup

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://geoip.ubuntu.com/lookup

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.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
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://geoip.ubuntu.com directly?

review: Needs Information
Revision history for this message
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://geoip.ubuntu.com directly?

I will look into this. Popey contact bzoltan for sample code to get location via GPS. You can find his branch at https://code.launchpad.net/~bzoltan/+junk/SystemInfo. However bzoltan while testing it came to the conclusion that it takes a long time to find a gps satellite and retrieve the location coordinates. He said that a bug report needs to be reported on this. I was told all this by Popey, so please contact him regarding gps support. As for using qtlocation for geoIP, the same code used by bzoltan can be used as well for geoIP. However on testing it on my desktop and phone, I found it unreliable to get coordinates via geoIP using qtlocation. Sometime it worked and sometime it didnt.

Revision history for this message
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.

Revision history for this message
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://code.launchpad.net/~nik90/ubuntu-clock-app/sync-clock-backend/+merge/186923
> --
>
> https://code.launchpad.net/~nik90/ubuntu-clock-app/sync-clock-backend/+merge/186923
> You are reviewing the proposed merge of
> lp:~nik90/ubuntu-clock-app/sync-clock-backend into lp:ubuntu-clock-app.
>

Revision history for this message
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

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
223. By Nekhelesh Ramananthan

merged trunk

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'clock/ClockPage.qml'
--- clock/ClockPage.qml 2013-09-26 06:14:47 +0000
+++ clock/ClockPage.qml 2013-09-27 08:38:25 +0000
@@ -30,18 +30,23 @@
3030
31 // Property to hold the formatted time string to show on the screen31 // Property to hold the formatted time string to show on the screen
32 property string currentTimeFormatted32 property string currentTimeFormatted
33 property real currentTimeStamp33 property real currentUTCTime
34 property real diff: new Date().getTimezoneOffset()34 property real diff: new Date().getTimezoneOffset()
35 property alias currentCity: currentLocationCity.text
36 property alias currentLat: easterEggCircle.latitude
37 property alias currentLng: easterEggCircle.longitude
3538
36 Component.onCompleted: {39 Component.onCompleted: {
37 Utils.log("ClockPage loaded");40 // TODO: Query GPS for location data
38 diff = worldModel.timeDiff;41 Utils.log("ClockPage loaded");
39 currentLocationCity.text = worldModel.city;42 if (worldModel.city !== "undefined") {
40 easterEggCircle.longitude = worldModel.longitude;43 currentCity = worldModel.city;
41 easterEggCircle.latitude = worldModel.latitude;44 currentLng = worldModel.longitude;
45 currentLat = worldModel.latitude;
46 }
42 Utils.log("Saved Current Location: " + worldModel.city);47 Utils.log("Saved Current Location: " + worldModel.city);
43 Utils.log("Saved Current Location Coordinates: " + easterEggCircle.longitude + "," + easterEggCircle.latitude)48 Utils.log("Saved Current Location Coordinates: " + currentLng + "," + currentLat)
44 currentTimeFormatted = Qt.formatTime(new Date(currentTimeStamp + (diff * 60000)), "hh:mm")49 currentTimeFormatted = Qt.formatTime(new Date(), "hh:mm")
45 updateTime();50 updateTime();
46 }51 }
4752
@@ -53,13 +58,12 @@
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")
54 description: "Add a world city"59 description: "Add a world city"
55 iconSource: Qt.resolvedUrl("../images/add_icon.png")60 iconSource: Qt.resolvedUrl("../images/add_icon.png")
56 onTriggered: pagestack.push(Qt.resolvedUrl("WorldPage.qml"))61 onTriggered: pagestack.push(Qt.resolvedUrl("WorldPage.qml"), {"isWorldCity": true})
57 }62 }
58 ]63 ]
5964
60 function onTimerUpdate(now) {65 function onTimerUpdate(now) {
61 currentTimeFormatted = Qt.formatTime(new Date(currentTimeStamp + (diff * 60000)), "hh:mm")66 currentTimeFormatted = Qt.formatTime(new Date(), "hh:mm")
62 now.setMinutes(now.getMinutes() + diff)
63 clockFace.timeChanged(now)67 clockFace.timeChanged(now)
64 if (now.getUTCSeconds() == 0) {68 if (now.getUTCSeconds() == 0) {
65 updateTime();69 updateTime();
@@ -68,15 +72,42 @@
6872
69 function updateTime() {73 function updateTime() {
70 var now = new Date();74 var now = new Date();
71 currentTimeStamp = now.getTime();75 now.setMinutes(now.getMinutes() + diff)
72 } 76 currentUTCTime = now.getTime();
77 }
78
79 GeoIPModel {
80 id: geoIP
81 onStatusChanged: {
82 if (status == XmlListModel.Ready && geoIP.get(0).city != worldModel.city && geoIP.get(0).city != "None") {
83 Utils.log("Retrieved current location using GeoIP. Writing into database and setting it as current location")
84 currentCity = geoIP.get(0).city
85 currentLng = geoIP.get(0).lng
86 currentLat = geoIP.get(0).lat
87 worldModel.appendCurrentLocation(currentCity, currentLng, currentLat);
88 }
89 else if (status == XmlListModel.Ready && geoIP.get(0).city == "None") {
90 if (worldModel.city == "undefined") {
91 currentCity = i18n.tr("Set current location name")
92 currentLocation.progression = true
93 }
94 }
95 else if(status == XmlListModel.Error) {
96 Utils.error("Unable to retrieve GeoIP Data -> " + geoIP.errorString())
97 if (worldModel.city == "undefined") {
98 currentCity = i18n.tr("Set current location name")
99 currentLocation.progression = true
100 }
101 }
102 }
103 }
73104
74 Flickable {105 Flickable {
75 id: clockAnimationContainer106 id: clockAnimationContainer
76107
77 clip: true;108 clip: true;
78 anchors.fill: parent109 anchors.fill: parent
79 contentWidth: parent.width 110 contentWidth: parent.width
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)
81112
82 // Label to show the current time113 // Label to show the current time
@@ -108,10 +139,10 @@
108 anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter }139 anchors { top: parent.top; topMargin: units.gu(10); horizontalCenter: parent.horizontalCenter }
109140
110 onClicked: {141 onClicked: {
111 if (easterEggCircle.isReady == XmlListModel.Ready) {142 if (easterEggCircle.isReady == XmlListModel.Ready && worldModel.city !== "undefined") {
112 clockFace.state == "" ? clockFace.state = "easteregg" : clockFace.state = "";143 clockFace.state == "" ? clockFace.state = "easteregg" : clockFace.state = "";
113 } else {144 } else {
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.")
115 }146 }
116 }147 }
117148
@@ -127,7 +158,6 @@
127 name: "easteregg"158 name: "easteregg"
128 PropertyChanges { target: easterEggCircle; opacity: 1; }159 PropertyChanges { target: easterEggCircle; opacity: 1; }
129 PropertyChanges { target: currentTimeLabel; opacity: 0; }160 PropertyChanges { target: currentTimeLabel; opacity: 0; }
130 // TODO: Do some caching of data here. Store data locally to reduce API calls.
131 PropertyChanges { target: easterEggCircle; sunriseLabel: easterEggCircle.getSunTime(easterEggCircle.model.get(0).sunriseTime); }161 PropertyChanges { target: easterEggCircle; sunriseLabel: easterEggCircle.getSunTime(easterEggCircle.model.get(0).sunriseTime); }
132 PropertyChanges { target: easterEggCircle; sunsetLabel: easterEggCircle.getSunTime(easterEggCircle.model.get(0).sunsetTime); }162 PropertyChanges { target: easterEggCircle; sunsetLabel: easterEggCircle.getSunTime(easterEggCircle.model.get(0).sunsetTime); }
133 },163 },
@@ -161,20 +191,24 @@
161191
162 ListItem.Standard {192 ListItem.Standard {
163 id: currentLocation193 id: currentLocation
194
164 Label {195 Label {
165 id: currentLocationCity196 id: currentLocationCity
166 // TRANSLATORS: this refers to Coordinated Universal Time197 text: i18n.tr("Retrieving current location...")
167 text: i18n.tr("UTC")
168 anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: units.gu(3) }198 anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: units.gu(3) }
169 color: Theme.palette.normal.baseText199 color: Theme.palette.normal.baseText
170 fontSize: "large"200 fontSize: "large"
171 }201 }
172 Label {202 Label {
173 text: Qt.formatTime(new Date(currentTimeStamp + (diff * 60000)), "hh:mm A")203 id: currentLocationTime
174 anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: units.gu(2) }204 visible: worldModel.city !== "undefined" ? true : false
205 text: currentTimeFormatted
206 anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: currentLocation.progression == true ? units.gu(6) : units.gu(2) }
175 color: Theme.palette.normal.baseText207 color: Theme.palette.normal.baseText
176 fontSize: "large"208 fontSize: "large"
177 }209 }
210
211 onClicked: pagestack.push(Qt.resolvedUrl("WorldPage.qml"), {"isWorldCity": false})
178 }212 }
179213
180 ListItem.Header {214 ListItem.Header {
@@ -190,7 +224,7 @@
190 id: listWorldClocks224 id: listWorldClocks
191225
192 clip: true226 clip: true
193 anchors { left: parent.left; right: parent.right } 227 anchors { left: parent.left; right: parent.right }
194 height: 3 * units.gu(6) + units.gu(1) // height is defined to show 3 items by default with a small margin228 height: 3 * units.gu(6) + units.gu(1) // height is defined to show 3 items by default with a small margin
195 model: worldModel229 model: worldModel
196 currentIndex: -1230 currentIndex: -1
@@ -204,7 +238,7 @@
204 }238 }
205239
206 Label {240 Label {
207 text: Qt.formatTime(new Date(currentTimeStamp + (rawOffSet * 60000)), "hh:mm A")241 text: Qt.formatTime(new Date(currentUTCTime + (rawOffSet * 60000)), "hh:mm")
208 anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: units.gu(2) }242 anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: units.gu(2) }
209 color: Theme.palette.normal.baseText243 color: Theme.palette.normal.baseText
210 fontSize: "large"244 fontSize: "large"
@@ -221,14 +255,6 @@
221 onItemRemoved: {255 onItemRemoved: {
222 worldModel.removePreset(index);256 worldModel.removePreset(index);
223 }257 }
224
225 onClicked: {
226 currentLocationCity.text = cityName;
227 diff = rawOffSet;
228 easterEggCircle.longitude = longitude;
229 easterEggCircle.latitude = latitude;
230 worldModel.appendCurrentLocation(cityName, diff, longitude, latitude);
231 }
232 }258 }
233 }259 }
234 }260 }
235261
=== modified file 'clock/EasterEgg.qml'
--- clock/EasterEgg.qml 2013-09-03 18:55:04 +0000
+++ clock/EasterEgg.qml 2013-09-27 08:38:25 +0000
@@ -86,8 +86,8 @@
86 }86 }
8787
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.
89 property real latitude: 52.01;89 property real latitude: 200;
90 property real longitude: 4.35;90 property real longitude: 200;
9191
92 // properties to set/retrieve the sunrise and sunset times92 // properties to set/retrieve the sunrise and sunset times
93 property alias sunriseLabel: sunriseTimeLabel.text;93 property alias sunriseLabel: sunriseTimeLabel.text;
@@ -134,7 +134,7 @@
134 var savedData = getSavedData();134 var savedData = getSavedData();
135 var checkedDate = savedData[0][1].split('T')[0]135 var checkedDate = savedData[0][1].split('T')[0]
136 var date = new Date().toISOString();136 var date = new Date().toISOString();
137 if (status == XmlListModel.Ready && checkedDate != date.split('T')[0]){137 if (status == XmlListModel.Ready && checkedDate != date.split('T')[0] && longitude != 200 && latitude != 200){
138 sunriseTimeLabel.text = getSunTime(sunRiseModel.get(0).sunriseTime);138 sunriseTimeLabel.text = getSunTime(sunRiseModel.get(0).sunriseTime);
139 sunsetTimeLabel.text = getSunTime(sunRiseModel.get(0).sunsetTime);139 sunsetTimeLabel.text = getSunTime(sunRiseModel.get(0).sunsetTime);
140 saveSunTimes(date, sunriseTimeLabel.text, sunsetTimeLabel.text);140 saveSunTimes(date, sunriseTimeLabel.text, sunsetTimeLabel.text);
141141
=== added file 'clock/GeoIPModel.qml'
--- clock/GeoIPModel.qml 1970-01-01 00:00:00 +0000
+++ clock/GeoIPModel.qml 2013-09-27 08:38:25 +0000
@@ -0,0 +1,31 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
17 */
18
19import QtQuick 2.0
20import QtQuick.XmlListModel 2.0
21
22// Xml model to retrieve user's current location based on geoIP
23XmlListModel {
24 id: geoIPModel;
25
26 source: "http://geoip.ubuntu.com/lookup"
27 query: "/Response"
28 XmlRole { name: "city"; query: "City/string()"; isKey: true }
29 XmlRole { name: "lat"; query: "Latitude/string()"; isKey: true }
30 XmlRole { name: "lng"; query: "Longitude/string()"; isKey: true }
31}
032
=== modified file 'clock/WorldClockModel.qml'
--- clock/WorldClockModel.qml 2013-07-01 14:40:35 +0000
+++ clock/WorldClockModel.qml 2013-09-27 08:38:25 +0000
@@ -27,31 +27,31 @@
27 readonly property string dbVersion: "0.1"27 readonly property string dbVersion: "0.1"
28 readonly property string dbDescription: "World Clock"28 readonly property string dbDescription: "World Clock"
2929
30 property real timeDiff: new Date().getTimezoneOffset()30 property string city: "undefined";
31 property string city: "UTC";31 property real longitude: 200;
32 property real longitude: 4.35;32 property real latitude: 200;
33 property real latitude: 52.01;
3433
35 property var _db: null34 property var _db: null
3635
37 function appendCurrentLocation(cityname, rawOffSet, longitude, latitude)36 function appendCurrentLocation(cityname, longitude, latitude)
38 {37 {
39 try {38 try {
40 _db.transaction(function(tx){39 _db.transaction(function(tx){
41 var currentValue;40 var currentValue;
42 var res = tx.executeSql('SELECT * FROM CurrentClock');41 var res = tx.executeSql('SELECT * FROM CurrentClock');
43 if (res.rows.length > 0) {42
44 currentValue = res.rows.item(0).rawOffSet;43 if (res.rows.length > 0)
45 }44 currentValue = res.rows.item(0).cityName;
4645
47 if (currentValue !== rawOffSet) {46 if (currentValue !== undefined) // Update existing value or insert if none
48 // Update existing value or insert if none 47 res = tx.executeSql('UPDATE CurrentClock SET cityName = ?, longitude = ?, latitude = ?', [cityname, longitude, latitude]);
49 if (currentValue !== undefined) {48 else
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]);
51 } else {50
52 res = tx.executeSql('INSERT INTO CurrentClock VALUES(?, ?, ?, ?)', [cityname, rawOffSet, longitude, latitude]);51 clockPage.currentCity = model.city = cityname
53 }52 clockPage.currentLng = model.longitude = longitude
54 }53 clockPage.currentLat = model.latitude = latitude
54 Utils.log("Updating current location (manually)")
55 });55 });
56 } catch (err) {56 } catch (err) {
57 Utils.error("Error setting current location '" + "': " + err);57 Utils.error("Error setting current location '" + "': " + err);
@@ -86,7 +86,7 @@
86 }86 }
87 try {87 try {
88 _db.transaction(function(tx){88 _db.transaction(function(tx){
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)');
90 });90 });
91 } catch (err) {91 } catch (err) {
92 Utils.error("Error creating CurrentClock table in db:" + err);92 Utils.error("Error creating CurrentClock table in db:" + err);
@@ -108,9 +108,9 @@
108 if (res.rows.length > 0) {108 if (res.rows.length > 0) {
109 for (var i = 0; i < res.rows.length; i++) {109 for (var i = 0; i < res.rows.length; i++) {
110 model.append({"cityName" : res.rows.item(i).cityName,110 model.append({"cityName" : res.rows.item(i).cityName,
111 "rawOffSet": res.rows.item(i).rawOffSet,111 "rawOffSet": res.rows.item(i).rawOffSet,
112 "longitude": res.rows.item(i).longitude,112 "longitude": res.rows.item(i).longitude,
113 "latitude" : res.rows.item(i).latitude113 "latitude" : res.rows.item(i).latitude
114 });114 });
115 }115 }
116 }116 }
@@ -125,7 +125,6 @@
125 var currentstate = tx.executeSql('SELECT * FROM CurrentClock ORDER BY cityName');125 var currentstate = tx.executeSql('SELECT * FROM CurrentClock ORDER BY cityName');
126 if (currentstate.rows.length > 0) {126 if (currentstate.rows.length > 0) {
127 city = currentstate.rows.item(0).cityName;127 city = currentstate.rows.item(0).cityName;
128 timeDiff = currentstate.rows.item(0).rawOffSet;
129 longitude = currentstate.rows.item(0).longitude;128 longitude = currentstate.rows.item(0).longitude;
130 latitude = currentstate.rows.item(0).latitude;129 latitude = currentstate.rows.item(0).latitude;
131 }130 }
132131
=== modified file 'clock/WorldPage.qml'
--- clock/WorldPage.qml 2013-09-04 11:28:52 +0000
+++ clock/WorldPage.qml 2013-09-27 08:38:25 +0000
@@ -23,14 +23,20 @@
23Page {23Page {
24 id: worldPage24 id: worldPage
2525
26 property bool isWorldCity;
27
26 visible: false;28 visible: false;
27 title: i18n.tr("Add City")29 title: isWorldCity ? i18n.tr("Add City") : i18n.tr("Edit Current Location")
2830
29 function getTimeDifference(data) {31 function getTimeDifference(data) {
30 var worldTime = data.split(' ')[1].split(':');32 var worldTime = data.split(' ')[1].split(':');
31 var hoursWT = parseInt(worldTime[0]);33 var hoursWT = parseInt(worldTime[0]);
32 var minutesWT = parseInt(worldTime[1]);34 var minutesWT = parseInt(worldTime[1]);
33 var now = new Date();35 var now = new Date();
36 var UTCdiff = new Date().getTimezoneOffset()
37 now.setMinutes(now.getMinutes() + UTCdiff)
38
39 // Calculating world city time diff w.r.t UTC
34 return ((hoursWT - now.getHours()) * 60 + (minutesWT - now.getMinutes()));40 return ((hoursWT - now.getHours()) * 60 + (minutesWT - now.getMinutes()));
35 }41 }
3642
@@ -48,7 +54,10 @@
4854
49 onStatusChanged: {55 onStatusChanged: {
50 if(status == XmlListModel.Ready && worldClockList.city != "null") {56 if(status == XmlListModel.Ready && worldClockList.city != "null") {
51 worldModel.appendPreset(worldClockList.city, getTimeDifference(cityDetailsModel.get(0).time), worldClockList.lng, worldClockList.lat);57 if (isWorldCity)
58 worldModel.appendPreset(worldClockList.city, getTimeDifference(cityDetailsModel.get(0).time), worldClockList.lng, worldClockList.lat);
59 else
60 worldModel.appendCurrentLocation(worldClockList.city, worldClockList.lng, worldClockList.lat);
52 worldClockList.clearUserSearch();61 worldClockList.clearUserSearch();
53 pageStack.pop()62 pageStack.pop()
54 }63 }
@@ -61,7 +70,7 @@
61 lat = searchModel.get(index).lat;70 lat = searchModel.get(index).lat;
62 lng = searchModel.get(index).lng;71 lng = searchModel.get(index).lng;
63 city = searchModel.get(index).city;72 city = searchModel.get(index).city;
64 cityDetailsModel.reload() 73 cityDetailsModel.reload()
65 }74 }
66 }75 }
67}76}

Subscribers

People subscribed via source and target branches