Merge lp:~pkunal-parmar/ubuntu-calendar-app/LoaderPage into lp:ubuntu-calendar-app
- LoaderPage
- Merge into trunk
Proposed by
Kunal Parmar
Status: | Merged |
---|---|
Approved by: | Mihir Soni |
Approved revision: | 242 |
Merged at revision: | 244 |
Proposed branch: | lp:~pkunal-parmar/ubuntu-calendar-app/LoaderPage |
Merge into: | lp:ubuntu-calendar-app |
Diff against target: |
379 lines (+140/-119) 3 files modified
TimeLineHeader.qml (+3/-24) calendar.qml (+136/-95) tests/autopilot/calendar_app/tests/test_calendar.py (+1/-0) |
To merge this branch: | bzr merge lp:~pkunal-parmar/ubuntu-calendar-app/LoaderPage |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mihir Soni | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Review via email: mp+215536@code.launchpad.net |
Commit message
Using Loader to load only required page.
Description of the change
Using Loader to load only required page.
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
Mihir Soni (mihirsoni) wrote : | # |
Looks good to me, I guess you would be required for merging from trunk.
Rest changes looks fine and works.
thank you.
review:
Approve
Revision history for this message
Kunal Parmar (pkunal-parmar) wrote : | # |
Thanks, merge latest trunk
Revision history for this message
Mihir Soni (mihirsoni) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'TimeLineHeader.qml' |
2 | --- TimeLineHeader.qml 2014-03-26 19:06:27 +0000 |
3 | +++ TimeLineHeader.qml 2014-04-12 04:07:28 +0000 |
4 | @@ -45,33 +45,12 @@ |
5 | } |
6 | |
7 | function getStartDate() { |
8 | + var indexType = header.indexType(index); |
9 | switch(type) { |
10 | case ViewType.ViewTypeWeek: |
11 | - return getDateForWeek(); |
12 | + return date.addDays(7*indexType); |
13 | case ViewType.ViewTypeDay: |
14 | - return getDateForDay(); |
15 | - } |
16 | - } |
17 | - |
18 | - function getDateForDay() { |
19 | - switch( header.indexType(index)) { |
20 | - case 0: |
21 | - return date; |
22 | - case -1: |
23 | - return date.addDays(-1); |
24 | - case 1: |
25 | - return date.addDays(1); |
26 | - } |
27 | - } |
28 | - |
29 | - function getDateForWeek() { |
30 | - switch( header.indexType(index)) { |
31 | - case 0: |
32 | - return date; |
33 | - case -1: |
34 | - return date.addDays(-7); |
35 | - case 1: |
36 | - return date.addDays(7); |
37 | + return date.addDays(1*indexType); |
38 | } |
39 | } |
40 | } |
41 | |
42 | === modified file 'calendar.qml' |
43 | --- calendar.qml 2014-04-11 00:21:42 +0000 |
44 | +++ calendar.qml 2014-04-12 04:07:28 +0000 |
45 | @@ -53,7 +53,7 @@ |
46 | width: units.gu(100) |
47 | height: units.gu(80) |
48 | focus: true |
49 | - Keys.forwardTo: [yearView,monthView,weekView,dayView,pageStack.currentPage,tabPage] |
50 | + Keys.forwardTo: [pageStack.currentPage] |
51 | |
52 | headerColor: "#266249" |
53 | backgroundColor: "#478158" |
54 | @@ -63,10 +63,27 @@ |
55 | PageStack { |
56 | id: pageStack |
57 | |
58 | - Component.onCompleted: push(tabPage) |
59 | - |
60 | - Page{ |
61 | - id: tabPage |
62 | + Component.onCompleted: push(tabs) |
63 | + |
64 | + // This is for wait that the app is load when newEvent is invoked by argument |
65 | + Timer { |
66 | + id: timer |
67 | + interval: 200; running: false; repeat: false |
68 | + onTriggered: { |
69 | + tabs.newEvent(); |
70 | + } |
71 | + } |
72 | + |
73 | + EventListModel{ |
74 | + id: eventModel |
75 | + //This model is just for newevent |
76 | + //so we dont need any update |
77 | + autoUpdate: false |
78 | + } |
79 | + |
80 | + Tabs{ |
81 | + id: tabs |
82 | + Keys.forwardTo: [tabs.currentPage.item] |
83 | |
84 | property var currentDay: DateExt.today(); |
85 | |
86 | @@ -75,21 +92,6 @@ |
87 | property int starttime: -1; |
88 | property int endtime: -1; |
89 | |
90 | - onCurrentDayChanged: { |
91 | - if( yearView.currentYear !== currentDay.getFullYear() ) { |
92 | - yearView.currentYear = tabPage.currentDay.getFullYear(); |
93 | - } |
94 | - |
95 | - if( monthView.currentMonth !== undefined && !monthView.currentMonth.isSameDay(currentDay)) |
96 | - monthView.currentMonth = currentDay.midnight(); |
97 | - |
98 | - if( !dayView.currentDay.isSameDay(currentDay)) |
99 | - dayView.currentDay = currentDay |
100 | - |
101 | - if( !weekView.dayStart.isSameDay(currentDay)) |
102 | - weekView.dayStart = currentDay |
103 | - } |
104 | - |
105 | function newEvent() { |
106 | var startDate = new Date(); |
107 | var endDate = new Date(); |
108 | @@ -125,13 +127,13 @@ |
109 | var difference = endTime - startTime; |
110 | |
111 | if (difference > month) |
112 | - return 0; // Year view |
113 | + return yearTab.index; // Year view |
114 | else if (difference > 7 * day) |
115 | - return 1; // Month view} |
116 | + return monthTab.index; // Month view} |
117 | else if (difference > day) |
118 | - return 2; // Week view |
119 | + return weekTab.index; // Week view |
120 | else |
121 | - return 3; // Day view |
122 | + return dayTab.index; // Day view |
123 | } |
124 | |
125 | // This function parse the argument |
126 | @@ -153,14 +155,14 @@ |
127 | // If an url has been set |
128 | if (args.defaultArgument.at(0)) { |
129 | parseArguments(args.defaultArgument.at(0)) |
130 | - tabPage.currentDay = new Date() |
131 | + tabs.currentDay = new Date() |
132 | // If newevent has been called on startup |
133 | if (newevent) { |
134 | timer.running = true; |
135 | } |
136 | else if (starttime !== -1) { // If no newevent has been setted, but starttime |
137 | var startTime = parseInt(starttime); |
138 | - tabPage.currentDay = new Date(startTime); |
139 | + tabs.currentDay = new Date(startTime); |
140 | |
141 | // If also endtime has been settend |
142 | if (endtime !== -1) { |
143 | @@ -183,22 +185,6 @@ |
144 | } |
145 | } // End of Component.onCompleted: |
146 | |
147 | - // This is for wait that the app is load when newEvent is invoked by argument |
148 | - Timer { |
149 | - id: timer |
150 | - interval: 200; running: false; repeat: false |
151 | - onTriggered: { |
152 | - tabPage.newEvent(); |
153 | - } |
154 | - } |
155 | - |
156 | - EventListModel{ |
157 | - id: eventModel |
158 | - //This model is just for newevent |
159 | - //so we dont need any update |
160 | - autoUpdate: false |
161 | - } |
162 | - |
163 | ToolbarItems { |
164 | id: commonToolBar |
165 | |
166 | @@ -208,7 +194,11 @@ |
167 | iconSource: Qt.resolvedUrl("calendar-today.svg"); |
168 | text: i18n.tr("Today"); |
169 | onTriggered: { |
170 | - tabPage.currentDay = (new Date()).midnight(); |
171 | + tabs.currentDay = (new Date()).midnight(); |
172 | + if(yearViewLoader.item ) yearViewLoader.item.currentYear = tabs.currentDay.getFullYear(); |
173 | + if(monthViewLoader.item ) monthViewLoader.item.currentMonth = tabs.currentDay.midnight(); |
174 | + if(weekViewLoader.item ) weekViewLoader.item.dayStart = tabs.currentDay; |
175 | + if(dayViewLoader.item ) dayViewLoader.item.currentDay = tabs.currentDay; |
176 | } |
177 | } |
178 | } |
179 | @@ -218,7 +208,7 @@ |
180 | iconSource: Qt.resolvedUrl("new-event.svg"); |
181 | text: i18n.tr("New Event"); |
182 | onTriggered: { |
183 | - pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"date":tabPage.currentDay,"model":eventModel}); |
184 | + pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"date":tabs.currentDay,"model":eventModel}); |
185 | } |
186 | } |
187 | } |
188 | @@ -246,78 +236,129 @@ |
189 | } |
190 | } |
191 | |
192 | - Tabs{ |
193 | - id: tabs |
194 | - |
195 | - Tab{ |
196 | - id: yearTab |
197 | - objectName: "yearTab" |
198 | - title: i18n.tr("Year") |
199 | - page: YearView{ |
200 | - id: yearView |
201 | - objectName: "yearPage" |
202 | - tools: commonToolBar |
203 | - anchors.fill: parent |
204 | + Tab{ |
205 | + id: yearTab |
206 | + objectName: "yearTab" |
207 | + title: i18n.tr("Year") |
208 | + page: Loader{ |
209 | + id: yearViewLoader |
210 | + objectName: "yearViewLoader" |
211 | + source: tabs.selectedTab == yearTab ? Qt.resolvedUrl("YearView.qml"):"" |
212 | + onLoaded: { |
213 | + item.tools = Qt.binding(function() { return commonToolBar }) |
214 | + item.currentYear = tabs.currentDay.getFullYear(); |
215 | + } |
216 | + |
217 | + anchors{ |
218 | + left: parent.left |
219 | + right: parent.right |
220 | + bottom: parent.bottom |
221 | + } |
222 | + |
223 | + Connections{ |
224 | + target: yearViewLoader.item |
225 | onMonthSelected: { |
226 | - tabs.selectedTabIndex = 1 |
227 | var now = DateExt.today(); |
228 | if( date.getMonth() === now.getMonth() |
229 | && date.getFullYear() === now.getFullYear()) { |
230 | - monthView.currentMonth = now |
231 | + tabs.currentDay = now; |
232 | } else { |
233 | - monthView.currentMonth = date.midnight(); |
234 | + tabs.currentDay = date.midnight(); |
235 | } |
236 | + tabs.selectedTabIndex = monthTab.index; |
237 | } |
238 | } |
239 | } |
240 | - Tab { |
241 | - id: monthTab |
242 | - objectName: "monthTab" |
243 | - title: i18n.tr("Month") |
244 | - page: MonthView{ |
245 | - anchors.fill: parent |
246 | - tools: commonToolBar |
247 | - id: monthView |
248 | - |
249 | + } |
250 | + |
251 | + Tab{ |
252 | + id: monthTab |
253 | + objectName: "monthTab" |
254 | + title: i18n.tr("Month") |
255 | + page: Loader{ |
256 | + id: monthViewLoader |
257 | + objectName: "monthViewLoader" |
258 | + source: tabs.selectedTab == monthTab ? Qt.resolvedUrl("MonthView.qml"):"" |
259 | + onLoaded: { |
260 | + item.tools = Qt.binding(function() { return commonToolBar }) |
261 | + item.currentMonth = tabs.currentDay.midnight(); |
262 | + print("onLoaded:"+ tabs.currentDay); |
263 | + } |
264 | + |
265 | + anchors{ |
266 | + left: parent.left |
267 | + right: parent.right |
268 | + bottom: parent.bottom |
269 | + } |
270 | + |
271 | + Connections{ |
272 | + target: monthViewLoader.item |
273 | onDateSelected: { |
274 | - tabs.selectedTabIndex = 3 |
275 | - tabPage.currentDay = date; |
276 | + tabs.currentDay = date; |
277 | + tabs.selectedTabIndex = dayTab.index; |
278 | } |
279 | } |
280 | } |
281 | - Tab{ |
282 | - id: weekTab |
283 | - objectName: "weekTab" |
284 | - title: i18n.tr("Week") |
285 | - page: WeekView{ |
286 | - id: weekView |
287 | - anchors.fill: parent |
288 | - tools: commonToolBar |
289 | - isCurrentPage: tabs.selectedTab == weekTab |
290 | - |
291 | + } |
292 | + |
293 | + Tab{ |
294 | + id: weekTab |
295 | + objectName: "weekTab" |
296 | + title: i18n.tr("Week") |
297 | + page: Loader{ |
298 | + id: weekViewLoader |
299 | + objectName: "weekViewLoader" |
300 | + source: tabs.selectedTab == weekTab ? Qt.resolvedUrl("WeekView.qml"):"" |
301 | + onLoaded: { |
302 | + item.tools = Qt.binding(function() { return commonToolBar }) |
303 | + item.isCurrentPage= Qt.binding(function() { return tabs.selectedTab == weekTab }) |
304 | + item.dayStart = tabs.currentDay; |
305 | + } |
306 | + |
307 | + anchors{ |
308 | + left: parent.left |
309 | + right: parent.right |
310 | + bottom: parent.bottom |
311 | + } |
312 | + |
313 | + Connections{ |
314 | + target: weekViewLoader.item |
315 | onDayStartChanged: { |
316 | - tabPage.currentDay = dayStart; |
317 | + tabs.currentDay = weekViewLoader.item.dayStart; |
318 | } |
319 | |
320 | onDateSelected: { |
321 | - tabs.selectedTabIndex = 3; |
322 | - tabPage.currentDay = date; |
323 | + tabs.currentDay = date; |
324 | + tabs.selectedTabIndex = dayTab.index; |
325 | } |
326 | } |
327 | } |
328 | - |
329 | - Tab{ |
330 | - id: dayTab |
331 | - objectName: "dayTab" |
332 | - title: i18n.tr("Day") |
333 | - page: DayView{ |
334 | - id: dayView |
335 | - anchors.fill: parent |
336 | - tools: commonToolBar |
337 | - isCurrentPage: tabs.selectedTab == dayTab |
338 | - |
339 | + } |
340 | + |
341 | + Tab{ |
342 | + id: dayTab |
343 | + objectName: "dayTab" |
344 | + title: i18n.tr("Day") |
345 | + page: Loader{ |
346 | + id: dayViewLoader |
347 | + objectName: "dayViewLoader" |
348 | + source: tabs.selectedTab == dayTab ? Qt.resolvedUrl("DayView.qml"):"" |
349 | + onLoaded: { |
350 | + item.tools = Qt.binding(function() { return commonToolBar }) |
351 | + item.isCurrentPage= Qt.binding(function() { return tabs.selectedTab == dayTab }) |
352 | + item.currentDay = tabs.currentDay; |
353 | + } |
354 | + |
355 | + anchors{ |
356 | + left: parent.left |
357 | + right: parent.right |
358 | + bottom: parent.bottom |
359 | + } |
360 | + |
361 | + Connections{ |
362 | + target: dayViewLoader.item |
363 | onCurrentDayChanged: { |
364 | - tabPage.currentDay = currentDay; |
365 | + tabs.currentDay = dayViewLoader.item.currentDay; |
366 | } |
367 | } |
368 | } |
369 | |
370 | === modified file 'tests/autopilot/calendar_app/tests/test_calendar.py' |
371 | --- tests/autopilot/calendar_app/tests/test_calendar.py 2014-03-20 03:02:48 +0000 |
372 | +++ tests/autopilot/calendar_app/tests/test_calendar.py 2014-04-12 04:07:28 +0000 |
373 | @@ -92,5 +92,6 @@ |
374 | |
375 | #verify that the event has been created in timeline |
376 | self.main_view.open_toolbar().click_button("todaybutton") |
377 | + self.main_view.switch_to_tab("dayTab") |
378 | self.assertThat(self.main_view.get_num_events, |
379 | Eventually(NotEquals(num_events))) |
PASSED: Continuous integration, rev:242 91.189. 93.70:8080/ job/ubuntu- calendar- app-ci/ 387/ 91.189. 93.70:8080/ job/generic- mediumtests- trusty/ 2068 91.189. 93.70:8080/ job/ubuntu- calendar- app-raring- amd64-ci/ 387 91.189. 93.70:8080/ job/ubuntu- calendar- app-saucy- amd64-ci/ 387 91.189. 93.70:8080/ job/ubuntu- calendar- app-trusty- amd64-ci/ 221
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/ubuntu- calendar- app-ci/ 387/rebuild
http://