Merge lp:~martin-borho/ubuntu-weather-app/fix-1366343-deleting into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Martin Borho
Status: Merged
Approved by: Alan Pope 🍺🐧🐱 πŸ¦„
Approved revision: 370
Merged at revision: 374
Proposed branch: lp:~martin-borho/ubuntu-weather-app/fix-1366343-deleting
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 140 lines (+19/-60)
2 files modified
components/LocationManagerPage.qml (+19/-41)
tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py (+0/-19)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/fix-1366343-deleting
Reviewer Review Type Date Requested Status
Alan Pope 🍺🐧🐱 πŸ¦„ (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+235374@code.launchpad.net

Commit message

Deleting and adding locations in database immediately after removing or adding in location manager, fixes Bug #1366343

Description of the change

Deleting and adding locations in database immediately after removing or adding in location manager, not on back action than. Fixes Bug #1366343

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
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Looks good to me! Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components/LocationManagerPage.qml'
2--- components/LocationManagerPage.qml 2014-09-05 09:57:29 +0000
3+++ components/LocationManagerPage.qml 2014-09-20 12:10:04 +0000
4@@ -36,53 +36,27 @@
5
6 property int initial_sum: 0
7 property bool limited: (locationModel.count > 7)
8+ property bool locationsChanged: false
9
10 head.backAction: Action {
11 iconName: "back"
12 onTriggered: {
13- var locationsChanged = false,
14- refresh = false;
15- // remove
16- for(var x=0;x<locationsRemoved.count;x++) {
17- var delLoc = locationsRemoved.get(x);
18- storage.clearLocation(delLoc.dbId);
19- locationsChanged = true;
20- }
21- // add
22- for(var y=0;y<locationModel.count;y++) {
23- var loc = locationModel.get(y);
24- if(loc.dbId === undefined || loc.dbId=== 0) {
25- storage.insertLocation({location:loc});
26- locationsChanged = true;
27- }
28- }
29- // refresh tabs if neccessary
30- if(locationsChanged || locationModel.count === 0) {
31- refresh = true;
32- }
33- // handle dummy "current location" item
34- currentLocationItem.visible = false
35- locationLookupItem.visible = true
36- lookupItemAddButton.visible = true
37- mainView.shortCutsLimited = false;
38 if(locationModel.count > 0) {
39- popFromStack(refresh)
40+ popFromStack()
41 }
42 }
43 }
44
45- Component.onCompleted: {
46- mainView.shortCutsLimited = true;
47- locationsRemoved.clear();
48+ Component.onCompleted: {
49 loadData();
50 }
51
52 Connections { target: mainView; onEscapeKey: popFromStack()}
53
54- function popFromStack(refresh) {
55+ function popFromStack() {
56 pageStack.pop()
57 // refresh at least from storage, to prevent header content from disapearing
58- refreshData(!refresh, refresh);
59+ refreshData(!locationsChanged, locationsChanged);
60 }
61
62 function lookupResponseHandler(messageObject) {
63@@ -131,10 +105,22 @@
64
65 function addLocation(location) {
66 if(!checkLocationExists(location)) {
67- locationModel.append(location)
68+ if(location.dbId === undefined || location.dbId=== 0) {
69+ locationModel.append(location)
70+ storage.insertLocation({location:location});
71+ locationsChanged = true;
72+ }
73 }
74 }
75
76+ function deleteLocation(index) {
77+ var location = locationModel.get(index),
78+ locDbId = location.dbId;
79+ locationModel.remove(index)
80+ storage.clearLocation(locDbId);
81+ locationsChanged = true;
82+ }
83+
84 Dialog {
85 id:existsNotification
86 title: i18n.tr("Location already added.")
87@@ -148,10 +134,6 @@
88 id: locationModel
89 }
90
91- ListModel {
92- id: locationsRemoved
93- }
94-
95 Rectangle {
96 anchors.fill:parent
97 color: "lightgrey"
98@@ -347,11 +329,7 @@
99 }
100 removable: true
101 onItemRemoved: {
102- var location = locationModel.get(index)
103- // clone location obj
104- location = JSON.parse(JSON.stringify(location));
105- locationsRemoved.append(location)
106- locationModel.remove(index)
107+ deleteLocation(index);
108 }
109 }
110 footer: ListItem.Standard {
111
112=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py'
113--- tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2014-09-04 16:21:49 +0000
114+++ tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2014-09-20 12:10:04 +0000
115@@ -307,25 +307,6 @@
116 tabObjects = lambda: len(self.main_view.select_many('LocationTab'))
117 self.assertThat(tabObjects, Eventually(Equals(tabsSumStart)))
118
119- def test_del_add_bug(self):
120- """Tests if removing and add a location in one action works
121- https://bugs.launchpad.net/ubuntu-weather-app/+bug/1230297"""
122- # remove a location
123- self._remove_location(stay=True)
124-
125- # add a location
126- self._add_location("Cairo")
127-
128- # back to locations, wait till data is loaded
129- self.main_view.wait_for_activity_to_finish()
130-
131- # count the tabs
132- tabObjects = self.main_view.select_many('LocationTab')
133- self.assertThat(lambda: len(tabObjects), Eventually(Equals(2)))
134- self.assertThat(
135- self.main_view.select_single('LocationTab', index=1).title,
136- Eventually(Equals("Cairo")))
137-
138 @skip("skipped because of Bug #1279073")
139 def test_open_location_manager_keyboard(self):
140 if self.platform_model != "Desktop":

Subscribers

People subscribed via source and target branches