Merge lp:~acerisara/ubuntu-clock-app/city-multiple-times into lp:ubuntu-clock-app/saucy

Proposed by Andrea Cerisara
Status: Merged
Approved by: Nekhelesh Ramananthan
Approved revision: 239
Merged at revision: 239
Proposed branch: lp:~acerisara/ubuntu-clock-app/city-multiple-times
Merge into: lp:ubuntu-clock-app/saucy
Diff against target: 34 lines (+21/-1)
1 file modified
clock/WorldClockModel.qml (+21/-1)
To merge this branch: bzr merge lp:~acerisara/ubuntu-clock-app/city-multiple-times
Reviewer Review Type Date Requested Status
Nekhelesh Ramananthan Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+191264@code.launchpad.net

Commit message

Added a check to prevent adding the same location multiple times in the clock page.

Description of the change

Added a check to prevent adding the same location multiple times in the clock page.

https://bugs.launchpad.net/ubuntu-clock-app/+bug/1236518.

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
Nekhelesh Ramananthan (nik90) wrote :

lgtm! Nice work! I am not sure if this will make it into the phone image since its code freeze was supposed to be tonight. However I am still merging this into trunk. If there is time, then your fix might make it into 1.0 release.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'clock/WorldClockModel.qml'
2--- clock/WorldClockModel.qml 2013-10-08 13:01:27 +0000
3+++ clock/WorldClockModel.qml 2013-10-15 18:26:18 +0000
4@@ -58,10 +58,30 @@
5 }
6 }
7
8+ function indexOf(cityName)
9+ {
10+ for(var i = 0; i < model.count; i++) {
11+ var element = model.get(i);
12+
13+ if(element.cityName == cityName) {
14+ return i;
15+ }
16+ }
17+
18+ return -1;
19+ }
20+
21 function appendPreset(cityName, rawOffSet, longitude, latitude)
22 {
23 if (_appendDB(cityName, rawOffSet, longitude, latitude)) {
24- model.append({"cityName" : cityName, "rawOffSet" : rawOffSet, "longitude" : longitude, "latitude" : latitude})
25+ var index = indexOf(cityName);
26+ var location = {"cityName" : cityName, "rawOffSet" : rawOffSet, "longitude" : longitude, "latitude" : latitude}
27+
28+ if(index != -1) {
29+ model.set(index, location);
30+ } else {
31+ model.append(location);
32+ }
33 }
34 }
35

Subscribers

People subscribed via source and target branches