Merge lp:~neokore/ubuntu-weather-app/ChooseAddLocationComponent into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Raúl Yeguas
Status: Merged
Approved by: Martin Borho
Approved revision: 8
Merged at revision: 8
Proposed branch: lp:~neokore/ubuntu-weather-app/ChooseAddLocationComponent
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 365 lines (+223/-55)
3 files modified
components/AddLocationDialog.qml (+115/-0)
components/CurrentWeather.qml (+5/-16)
weather.qml (+103/-39)
To merge this branch: bzr merge lp:~neokore/ubuntu-weather-app/ChooseAddLocationComponent
Reviewer Review Type Date Requested Status
Martin Borho Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
David Planella Needs Fixing
Review via email: mp+159856@code.launchpad.net

Commit message

First version for location manager.

Description of the change

First version for location manager.

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: Needs Fixing (continuous-integration)
Revision history for this message
David Planella (dpm) wrote :

Hi Raúl,

Thanks a lot for your branch. I've noticed the diff contains unresolved merge conflicts that need to be resolved before the merge proposal can be accepted (see the ubuntu-weather-app.qml file).

Do you think you could fix them and commit the changes to your branch? This way the merge proposal will be updated with your fixes.

Thanks!

review: Needs Fixing
8. By Raúl Yeguas

Resolved conflicts for merging.

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
Martin Borho (martin-borho) wrote :

Looks good!

@Raúl: Do you have already started with the API integration? I would like to do that tommorrow, plus the storage part, if it's ok?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'components/AddLocationDialog.qml'
2--- components/AddLocationDialog.qml 1970-01-01 00:00:00 +0000
3+++ components/AddLocationDialog.qml 2013-04-19 19:18:34 +0000
4@@ -0,0 +1,115 @@
5+import QtQuick 2.0
6+import Ubuntu.Components 0.1
7+import Ubuntu.Components.Popups 0.1
8+
9+// Dialog for adding a new location
10+Component {
11+ id: addLocationDialog
12+ Dialog {
13+ id: addLocationDialogue
14+ property string cityCode: ''
15+ height: units.gu(10)
16+ title: i18n.tr("Add location")
17+ text: i18n.tr("Write a city name o pick it by GPS location")
18+
19+ onCityCodeChanged: {
20+ PopupUtils.close(addLocationDialogue);
21+ addLocationAction.cityCode = cityCode;
22+ }
23+
24+ Row{
25+ TextField {
26+ id: locationString
27+ width: units.gu(25)
28+ placeholderText: i18n.tr("Enter a city name")
29+ }
30+ Button {
31+ id: locationSearchButton
32+
33+ width: units.gu(5)
34+ iconSource: "../resources/images/search_icon.png"
35+
36+ onClicked: {
37+ // Load cities from API search
38+ var cities = [{"id":"100000","name":"Madrid"}, {"id":"200000","name":"Seville"}, {"id":"300000","name":"Barcelona"}, {"id":"400000","name":"Valencia"},{"id":"500000","name":"Jaen"}];
39+ createCityList(cities);
40+ }
41+ }
42+ }
43+
44+ Button {
45+ id: locationGPSButton
46+ text: i18n.tr("Get by GPS location")
47+ onClicked: {
48+ // Load cities from API search
49+ var cities = [{"id":"100000","name":"Madrid"}, {"id":"200000","name":"Seville"}, {"id":"300000","name":"Barcelona"}, {"id":"400000","name":"Valencia"},{"id":"500000","name":"Jaen"}];
50+ createCityList(cities);
51+ }
52+ }
53+
54+ Button {
55+ id: locationCancelButton
56+ text: i18n.tr("Cancel")
57+ color: "#C00000"
58+ onClicked: PopupUtils.close(addLocationDialogue)
59+ }
60+
61+ // This rectangle is a workaround to keep enough height in the dialog
62+ Rectangle {
63+ width: units.gu(30)
64+ height: units.gu(20)
65+ color: "transparent"
66+ }
67+
68+ Item {
69+ id: locationResultBox
70+ anchors {
71+ top: locationCancelButton.bottom
72+ topMargin: units.gu(2)
73+ }
74+ }
75+
76+ // Function to show a list of cities in addCityAction
77+ function createCityList(cities) {
78+ if(resultList){
79+ resultList.destroy();
80+ }
81+
82+ var list = 'import QtQuick 2.0; \
83+ import Ubuntu.Components 0.1; \
84+ import Ubuntu.Components.ListItems 0.1 as ListItem; \
85+ Rectangle { \
86+ id: cityList; \
87+ width: units.gu(30); \
88+ height: units.gu(20); \
89+ color: "transparent"; \
90+ ListView { \
91+ id: listView; \
92+ clip: true; \
93+ anchors.fill: parent; \
94+ model: ListModel { \
95+ ';
96+ for (var i in cities) {
97+ list += 'ListElement { \
98+ label:\''+cities[i]["name"]+'\'; \
99+ code:\''+cities[i]["id"]+'\'; \
100+ }';
101+ };
102+ list += ' \
103+ } \
104+ delegate: ListItem.Standard { \
105+ text: i18n.tr(label); \
106+ progression: true; \
107+ onClicked: { addLocationDialogue.cityCode = code;} \
108+ } \
109+ } \
110+ Scrollbar { \
111+ flickableItem: listView; \
112+ align: Qt.AlignTrailing; \
113+ } \
114+ } \
115+ ';
116+ resultList = Qt.createQmlObject(list,locationResultBox,'results');
117+ }
118+ }
119+}
120
121=== modified file 'components/CurrentWeather.qml'
122--- components/CurrentWeather.qml 2013-03-09 15:34:59 +0000
123+++ components/CurrentWeather.qml 2013-04-19 19:18:34 +0000
124@@ -10,24 +10,13 @@
125 property int currentTemp
126 property int minTemp
127 property int maxTemp
128- property bool metric
129+ property bool metric: true
130+ property string scale: (metric) ? "C" : "F"
131
132 width: parent.width
133 height: childrenRect.height+units.gu(10)
134 anchors.horizontalCenter: parent.horizontalCenter
135
136- Component.onCompleted: {
137- if(currentWeather.metric){
138- tempCurrent.text = tempCurrent.text + ("C");
139- tempMin.text = tempMin.text + ("C");
140- tempMax.text = tempMax.text + ("C");
141- }else{
142- tempCurrent.text = tempCurrent.text + ("F");
143- tempMax.text = tempMax.text + ("F");
144- tempMin.text = tempMin.text + ("F");
145- }
146- }
147-
148 Image {
149 id: image1
150 width: units.gu(30)
151@@ -65,7 +54,7 @@
152
153 Label {
154 id: tempMax
155- text: maxTemp+"°"
156+ text: maxTemp+"°"+currentWeather.scale
157 anchors.horizontalCenter: parent.horizontalCenter
158 font.pixelSize: FontUtils.sizeToPixels("medium")
159 horizontalAlignment: Text.AlignHCenter
160@@ -76,7 +65,7 @@
161 width: units.gu(17)
162 height: units.gu(10)
163 id: tempCurrent
164- text: currentTemp+String("°")
165+ text: currentTemp+String("°")+currentWeather.scale
166 style: Text.Normal
167 font.bold: false
168 font.family: "Ubuntu"
169@@ -104,7 +93,7 @@
170
171 Label {
172 id: tempMin
173- text: minTemp+"°"
174+ text: minTemp+"°"+currentWeather.scale
175 horizontalAlignment: Text.AlignHCenter
176 anchors.horizontalCenter: parent.horizontalCenter
177 font.pixelSize: FontUtils.sizeToPixels("medium")
178
179=== added file 'resources/images/add_icon@8.png'
180Binary files resources/images/add_icon@8.png 1970-01-01 00:00:00 +0000 and resources/images/add_icon@8.png 2013-04-19 19:18:34 +0000 differ
181=== added file 'resources/images/remove_icon@8.png'
182Binary files resources/images/remove_icon@8.png 1970-01-01 00:00:00 +0000 and resources/images/remove_icon@8.png 2013-04-19 19:18:34 +0000 differ
183=== added file 'resources/images/search_icon@8.png'
184Binary files resources/images/search_icon@8.png 1970-01-01 00:00:00 +0000 and resources/images/search_icon@8.png 2013-04-19 19:18:34 +0000 differ
185=== renamed file 'ubuntu-weather-app.qml' => 'weather.qml'
186--- ubuntu-weather-app.qml 2013-04-11 20:37:30 +0000
187+++ weather.qml 2013-04-19 19:18:34 +0000
188@@ -1,21 +1,22 @@
189 import QtQuick 2.0
190 import Ubuntu.Components 0.1
191+import Ubuntu.Components.Popups 0.1
192 import "components" as Components
193 import "components/WeatherApi.js" as Api
194
195-/*!
196- \brief MainView with Tabs element.
197- First Tab has a single Label and
198- second Tab has a single ToolbarAction.
199-*/
200-
201 MainView {
202 // objectName for functional testing purposes (autopilot-qt5)
203 objectName: "weather"
204- applicationName: "ubuntu-weather-app"
205+ id: mainView
206
207 width: units.gu(50)
208 height: units.gu(75)
209+
210+ property var resultList: null
211+
212+ Components.AddLocationDialog {
213+ id: addLocationDialog
214+ }
215
216 Components.Storage{
217 id: storage
218@@ -25,14 +26,49 @@
219 id: tabs
220 anchors.fill: parent
221
222- // First tab begins here
223+ // Location 1
224 Tab {
225- objectName: "Tab1"
226-
227- title: i18n.tr("Weather")
228-
229- // Tab content begins here
230+ id: location1
231+ objectName: "City1"
232+
233+ title: i18n.tr("London")
234+
235+ // Menu for options
236 page: Page {
237+
238+ tools: ToolbarActions {
239+ Action {
240+ id: addLocationAction
241+ property string cityCode: ''
242+ objectName: "action"
243+
244+ iconSource: Qt.resolvedUrl("resources/images/add_icon.png")
245+ text: i18n.tr("Add")
246+
247+ onTriggered: {
248+ PopupUtils.open(addLocationDialog, location1);
249+ }
250+
251+ onCityCodeChanged: {
252+ // Action for adding a new cityCode
253+ console.log('DEBUG: cityCode has changed to '+cityCode);
254+ }
255+ }
256+
257+ Action {
258+ id: removeLocationAction
259+ property string cityCode: ''
260+ objectName: "action"
261+
262+ iconSource: Qt.resolvedUrl("resources/images/remove_icon.png")
263+ text: i18n.tr("Remove")
264+
265+ onTriggered: {
266+ // Action for removing a weather location
267+ }
268+ }
269+ }
270+
271 Rectangle {
272 id: startPage
273 width: parent.width
274@@ -89,37 +125,65 @@
275 }
276 }
277 }
278-
279- // Second tab begins here
280+
281+ // Location 2
282 Tab {
283- objectName: "Tab2"
284-
285- title: i18n.tr("Optional Screen")
286+ objectName: "City2"
287+
288+ title: i18n.tr("San Francisco")
289+
290 page: Page {
291- anchors.margins: units.gu(2)
292-
293- tools: ToolbarActions {
294- Action {
295- objectName: "action"
296-
297- iconSource: Qt.resolvedUrl("avatar.png")
298- text: i18n.tr("Tap me!")
299-
300- onTriggered: {
301- label.text = i18n.tr("Toolbar tapped")
302+
303+ Rectangle {
304+ id: cityForecast2
305+ width: parent.width
306+ height: parent.height
307+ Flickable {
308+ width: parent.width
309+ height: parent.height
310+ contentHeight: column1.height
311+ Column {
312+ width: parent.width
313+ Components.DateComponent {
314+ dateRelative: "Today"
315+ dateString:"Saturday, 9th February"
316+ borderTopVisible: false
317+ }
318+ Components.CurrentWeather {
319+ condition: 801
320+ currentTemp: 11
321+ minTemp: 8
322+ maxTemp: 17
323+ metric: true
324+ }
325+ Components.DateComponent {
326+ dateRelative: "Tomorrow"
327+ dateString:"Sunday, 10th February"
328+ }
329+ Components.DayWeatherComponent {
330+ temperature: 18
331+ temperatureMin: 10
332+ condition: 801
333+ }
334+ Components.DateComponent {
335+ dateString:"Monday, 11th February"
336+ }
337+ Components.DayWeatherComponent {
338+ temperature: 20
339+ temperatureMin: 10
340+ condition: 801
341+ }
342+ Components.DateComponent {
343+ dateString:"Tuesday, 12th February"
344+ }
345+ Components.DayWeatherComponent {
346+ temperature: 20
347+ temperatureMin: 11
348+ condition: 801
349+ }
350 }
351 }
352 }
353-
354- Column {
355- anchors.centerIn: parent
356- Label {
357- id: label
358- objectName: "label"
359-
360- text: i18n.tr("Swipe from bottom to up to reveal the toolbar.")
361- }
362- }
363 }
364 }
365 }

Subscribers

People subscribed via source and target branches