Merge lp:~pkunal-parmar/ubuntu-calendar-app/EventView-Perf into lp:ubuntu-calendar-app

Proposed by Kunal Parmar on 2014-04-05
Status: Merged
Approved by: Mihir Soni on 2014-04-05
Approved revision: 240
Merged at revision: 235
Proposed branch: lp:~pkunal-parmar/ubuntu-calendar-app/EventView-Perf
Merge into: lp:ubuntu-calendar-app
Diff against target: 492 lines (+68/-105)
9 files modified
AllDayEventComponent.qml (+6/-16)
EventDetails.qml (+4/-4)
EventListModel.qml (+16/-6)
GlobalEventModel.js (+0/-9)
NewEvent.qml (+2/-4)
TimeLineBase.qml (+11/-24)
TimeLineBaseComponent.qml (+16/-0)
WeekView.qml (+4/-22)
calendar.qml (+9/-20)
To merge this branch: bzr merge lp:~pkunal-parmar/ubuntu-calendar-app/EventView-Perf
Reviewer Review Type Date Requested Status
Mihir Soni 2014-04-05 Approve on 2014-04-05
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2014-04-05
Review via email: mp+214369@code.launchpad.net

Commit message

fixes Bug #1301910

Now removing Global model and as suggested by renato, creating model for individual view and performing operation in scope of Organizer Model's thread.

Description of the change

fixes Bug #1301910

Now removing Global model and as suggested by renato, creating model for individual view and performing operation in scope of Organizer Model's thread.

To post a comment you must log in.
235. By Kunal Parmar on 2014-04-05

removed unnecessary print

236. By Kunal Parmar on 2014-04-05

commented out code removed

237. By Kunal Parmar on 2014-04-05

unnecessary import removed

Kunal Parmar (pkunal-parmar) wrote :
Mihir Soni (mihirsoni) wrote :

Kunal ,

it looks good to me and now it more smoother in transition.

off the topic, We have to change this architecture in all the places, like creating new event, editing & updating new event ?

Because after importing your branch, i tried to edit my event and try to save it , it gives me following console ouput.

TypeError: Cannot call method 'saveItem' of undefined

review: Needs Information
238. By Kunal Parmar on 2014-04-05

Edit case handled

Kunal Parmar (pkunal-parmar) wrote :

> Kunal ,
>
> it looks good to me and now it more smoother in transition.
>
> off the topic, We have to change this architecture in all the places, like
> creating new event, editing & updating new event ?
>
> Because after importing your branch, i tried to edit my event and try to save
> it , it gives me following console ouput.
>
> TypeError: Cannot call method 'saveItem' of undefined

Indeed, model was not set in edit case.
Other case should work, let me know if you face issue.

239. By Kunal Parmar on 2014-04-05

Command line argument case handled

240. By Kunal Parmar on 2014-04-05

AllDay event handled

Mihir Soni (mihirsoni) wrote :

Hi Kunal,

I am not sure is it my system fault or not ,

but i see little delay in getting reload the view , I have captured the video if you see i have created event with recurrence of daily :-

if you see when i switch days it is taking some delays to display the same event.

https://www.youtube.com/watch?v=0QJPfGHv-BQ&feature=youtu.be

review: Needs Information
Kunal Parmar (pkunal-parmar) wrote :

If you are talking about delay in model refresh, then it not in our hand, as we are rendering event bubble async when model data is available.

As such I dont see any lag in GUI.

Mihir Soni (mihirsoni) wrote :

Okay kunal, got it.

Thanks i tested it apart from this everything looks good and works good.

Thanks a lot for your MR.

review: Approve
Kunal Parmar (pkunal-parmar) wrote :

ok, great, I am going to propose some more merge, that should help at certain extend to resolve that problem.
I guess as both day and week view is now trying to set date, EDS model is getting confused and rejects some requests. That's just my guess.

Mihir Soni (mihirsoni) wrote :

Thanks kunal,

Could you look at the Bug #1302439 ?

Are you able to reproduce it ?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'AllDayEventComponent.qml'
2--- AllDayEventComponent.qml 2014-03-19 00:32:29 +0000
3+++ AllDayEventComponent.qml 2014-04-05 06:36:44 +0000
4@@ -3,7 +3,6 @@
5 import Ubuntu.Components.Popups 0.1
6
7 import "dateExt.js" as DateExt
8-import "GlobalEventModel.js" as GlobalModel
9 import "ViewType.js" as ViewType
10
11 Rectangle{
12@@ -11,6 +10,7 @@
13
14 property var allDayEvents;
15 property var startDay: DateExt.today();
16+ property var model;
17
18 property int type: ViewType.ViewTypeWeek
19
20@@ -20,10 +20,9 @@
21
22 function getAllDayEvents(startDate, endDate) {
23 var map = {};
24- var itemIds = GlobalModel.globalModel().itemIds(startDate, endDate);
25- for(var i = 0 ; i < itemIds.length ; ++i) {
26- var eventId = itemIds[(i)];
27- var event = GlobalModel.globalModel().item(eventId);
28+ var items = model.getItems(startDate,endDate);
29+ for(var i = 0 ; i < items.length ; ++i) {
30+ var event = items[(i)];
31 if( event && event.allDay ) {
32 var key = Qt.formatDateTime(event.startDateTime, "dd-MMM-yyyy");
33 if( !(key in map)) {
34@@ -44,15 +43,6 @@
35 allDayEvents = getAllDayEvents(sd,ed);
36 }
37
38- Component.onCompleted: {
39- var model = GlobalModel.globalModel();
40- model.reloaded.connect(root.createAllDayEvents);
41- }
42-
43- onStartDayChanged: {
44- createAllDayEvents();
45- }
46-
47 Row {
48 width: parent.width
49 anchors.verticalCenter: parent.verticalCenter
50@@ -81,7 +71,7 @@
51 if( allDayLabel.events.length > 1 ) {
52 PopupUtils.open(popoverComponent, root,{"events": allDayLabel.events})
53 } else {
54- pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":allDayLabel.events[0]});
55+ pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":allDayLabel.events[0],"model": model});
56 }
57 }
58 }
59@@ -148,7 +138,7 @@
60 anchors.fill: parent
61 onClicked: {
62 popover.hide();
63- pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":modelData});
64+ pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":modelData,"model": model});
65 }
66 }
67 }
68
69=== modified file 'EventDetails.qml'
70--- EventDetails.qml 2014-04-04 02:27:33 +0000
71+++ EventDetails.qml 2014-04-05 06:36:44 +0000
72@@ -5,7 +5,6 @@
73 import Ubuntu.Components.Themes.Ambiance 0.1
74 import QtOrganizer 5.0
75
76-import "GlobalEventModel.js" as GlobalModel
77 import "Defines.js" as Defines
78
79 Page {
80@@ -14,6 +13,8 @@
81 property var event;
82 property string headerColor :"black"
83 property string detailColor :"grey"
84+ property var model;
85+
86 anchors.fill: parent
87 Component.onCompleted: {
88 if( pageStack.header )
89@@ -101,8 +102,7 @@
90 text: i18n.tr("Delete");
91 iconSource: "image://theme/delete,edit-delete-symbolic"
92 onTriggered: {
93- var eventModel = GlobalModel.globalModel();
94- eventModel.removeItem(event);
95+ model.removeItem(event);
96 pageStack.pop();
97 }
98 }
99@@ -113,7 +113,7 @@
100 text: i18n.tr("Edit");
101 iconSource: Qt.resolvedUrl("edit.svg");
102 onTriggered: {
103- pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"event":event});
104+ pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"event":event,"model":model});
105 }
106 }
107 }
108
109=== modified file 'EventListModel.qml'
110--- EventListModel.qml 2014-02-26 13:42:20 +0000
111+++ EventListModel.qml 2014-04-05 06:36:44 +0000
112@@ -1,16 +1,26 @@
113 import QtQuick 2.0
114-import "dateExt.js" as DateExt
115-
116 import QtOrganizer 5.0
117
118 OrganizerModel {
119 id: eventModel
120 manager:"eds"
121- autoUpdate: false
122-
123- signal reloaded
124+
125+ property var listeners:[];
126+
127+ function addModelChangeListener(listener){
128+ listeners.push(listener);
129+ }
130+
131+ function getItems(startDate, endDate){
132+ return itemsByTimePeriod(startDate,endDate);
133+ }
134
135 onModelChanged: {
136- reloaded();
137+ if(listeners === undefined){
138+ return;
139+ }
140+ for(var i=0; i < listeners.length ;++i){
141+ (listeners[i])();
142+ }
143 }
144 }
145
146=== removed file 'GlobalEventModel.js'
147--- GlobalEventModel.js 2014-01-31 03:20:40 +0000
148+++ GlobalEventModel.js 1970-01-01 00:00:00 +0000
149@@ -1,9 +0,0 @@
150-.pragma library
151-
152-var model;
153-function globalModel() {
154- if( !model) {
155- model = Qt.createQmlObject('import QtQuick 2.0; EventListModel {}', Qt.application, 'EventListModel.globalModel()')
156- }
157- return model;
158-}
159
160=== modified file 'NewEvent.qml'
161--- NewEvent.qml 2014-03-27 14:54:30 +0000
162+++ NewEvent.qml 2014-04-05 06:36:44 +0000
163@@ -6,7 +6,6 @@
164 import Ubuntu.Components.Themes.Ambiance 0.1
165 import QtOrganizer 5.0
166
167-import "GlobalEventModel.js" as GlobalModel
168 import "Defines.js" as Defines
169
170 Page {
171@@ -14,6 +13,7 @@
172 property var date: new Date();
173
174 property var event:null;
175+ property var model;
176
177 property var startDate;
178 property var endDate;
179@@ -35,7 +35,6 @@
180 endDate = new Date(date)
181 endDate.setMinutes( endDate.getMinutes() + 30)
182 }
183- internal.eventModel = GlobalModel.globalModel();
184
185 if(event === null){
186 isEdit =false;
187@@ -154,7 +153,7 @@
188 event.setDetail(audibleReminder);
189 }
190
191- internal.eventModel.saveItem(event);
192+ model.saveItem(event);
193 pageStack.pop();
194 }
195 }
196@@ -426,7 +425,6 @@
197
198 QtObject {
199 id: internal
200- property var eventModel;
201
202 function clearFocus() {
203 Qt.inputMethod.hide()
204
205=== modified file 'TimeLineBase.qml'
206--- TimeLineBase.qml 2014-03-26 14:39:17 +0000
207+++ TimeLineBase.qml 2014-04-05 06:36:44 +0000
208@@ -1,7 +1,6 @@
209 import QtQuick 2.0
210 import Ubuntu.Components 0.1
211 import "dateExt.js" as DateExt
212-import "GlobalEventModel.js" as GlobalModel
213
214 Item {
215 id: bubbleOverLay
216@@ -10,49 +9,38 @@
217 property var day;
218 property int hourHeight: units.gu(10)
219
220- Component.onCompleted: {
221- intern.model = GlobalModel.globalModel();
222- intern.model.reloaded.connect(bubbleOverLay.createEvents);
223- }
224-
225- onDayChanged: {
226- if( intern.model)
227- bubbleOverLay.createEvents();
228- }
229+ property var model;
230
231 TimeSeparator{
232 id: separator
233 objectName: "separator"
234 width: bubbleOverLay.width
235+ visible: false
236 z:1
237 }
238
239 QtObject {
240 id: intern
241 property var now : new Date();
242- property var model;
243 }
244
245 function showEventDetails(event) {
246- pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":event});
247+ pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":event,"model":model});
248 }
249
250 function createEvents() {
251 if(!bubbleOverLay || bubbleOverLay == undefined) {
252 return;
253 }
254-
255- bubbleOverLay.destroyAllChildren();
256+ destroyAllChildren();
257
258 var startDate = new Date(day).midnight();
259-
260 var endDate = new Date(day).endOfDay();
261
262- var itemIds = intern.model.itemIds(startDate,endDate);
263- for(var i = 0 ; i < itemIds.length ; ++i) {
264- var eventId = itemIds[(i)];
265- var event = intern.model.item(eventId);
266- if( event ) {
267+ var items = model.getItems(startDate,endDate);
268+ for(var i = 0 ; i < items.length ; ++i) {
269+ var event = items[i];
270+ if(event.allDay === false) {
271 bubbleOverLay.createEvent(event,event.startDateTime.getHours());
272 }
273 }
274@@ -64,10 +52,8 @@
275
276 function destroyAllChildren() {
277 for( var i = children.length - 1; i >= 0; --i ) {
278- if( children[i].objectName === "separator") {
279- children[i].visible = false;
280- } else {
281- children[i].visible = false;
282+ children[i].visible = false;
283+ if( children[i].objectName !== "separator") {
284 children[i].destroy();
285 }
286 }
287@@ -75,6 +61,7 @@
288
289 function createEvent( event ,hour) {
290 var eventBubble = delegate.createObject(bubbleOverLay);
291+
292 eventBubble.clicked.connect( bubbleOverLay.showEventDetails );
293
294 var yPos = (( event.startDateTime.getMinutes() * hourHeight) / 60) + hour * hourHeight
295
296=== modified file 'TimeLineBaseComponent.qml'
297--- TimeLineBaseComponent.qml 2014-03-26 14:29:37 +0000
298+++ TimeLineBaseComponent.qml 2014-04-05 06:36:44 +0000
299@@ -27,6 +27,13 @@
300 }
301 }
302
303+ EventListModel {
304+ id: mainModel
305+ startPeriod: startDay.midnight();
306+ endPeriod: type == ViewType.ViewTypeWeek ? startPeriod.addDays(7).endOfDay(): startPeriod.endOfDay()
307+ }
308+
309+
310 Column {
311 anchors.top: parent.top
312
313@@ -37,6 +44,10 @@
314 id: allDayContainer
315 type: root.type
316 startDay: root.startDay
317+ model: mainModel
318+ Component.onCompleted: {
319+ model.addModelChangeListener(createAllDayEvents);
320+ }
321 }
322
323 Flickable{
324@@ -75,6 +86,11 @@
325 height: parent.height
326 delegate: comp
327 day: startDay.addDays(index)
328+
329+ model: mainModel
330+ Component.onCompleted: {
331+ model.addModelChangeListener(createEvents);
332+ }
333 }
334 }
335 }
336
337=== modified file 'WeekView.qml'
338--- WeekView.qml 2014-03-26 19:06:27 +0000
339+++ WeekView.qml 2014-04-05 06:36:44 +0000
340@@ -29,7 +29,7 @@
341 id: weekHeader
342 objectName: "weekHeader"
343 type: ViewType.ViewTypeWeek
344- date: weekViewPath.weekStart
345+ date: firstDay
346
347 onDateSelected: {
348 root.dateSelected(date);
349@@ -39,9 +39,6 @@
350 PathViewBase{
351 id: weekViewPath
352
353- property var visibleWeek: dayStart.weekStart(Qt.locale().firstDayOfWeek);
354- property var weekStart: weekViewPath.visibleWeek
355-
356 width: parent.width
357 height: root.height - weekViewPath.y
358
359@@ -59,13 +56,11 @@
360 }
361
362 function nextWeek() {
363- var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);
364- dayStart = weekStartDay.addDays(7);
365+ dayStart = firstDay.addDays(7);
366 }
367
368 function previousWeek(){
369- var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);
370- dayStart = weekStartDay.addDays(-7);
371+ dayStart = firstDay.addDays(-7);
372 }
373
374 delegate: TimeLineBaseComponent {
375@@ -76,7 +71,7 @@
376 width: parent.width
377 height: parent.height
378
379- startDay: getWeekStart();
380+ startDay: firstDay.addDays( weekViewPath.indexType(index) * 7)
381
382 Connections{
383 target: root
384@@ -102,19 +97,6 @@
385 value: contentY
386 when: timeLineView.PathView.isCurrentItem
387 }
388-
389- function getWeekStart() {
390- switch( weekViewPath.indexType(index)) {
391- case 0:
392- return weekViewPath.weekStart;
393- case -1:
394- var weekStartDay= weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
395- return weekStartDay.addDays(-7);
396- case 1:
397- var weekStartDay = weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
398- return weekStartDay.addDays(7);
399- }
400- }
401 }
402 }
403 }
404
405=== modified file 'calendar.qml'
406--- calendar.qml 2014-04-04 02:38:06 +0000
407+++ calendar.qml 2014-04-05 06:36:44 +0000
408@@ -3,7 +3,6 @@
409 import Ubuntu.Components.Popups 0.1
410
411 import "dateExt.js" as DateExt
412-import "GlobalEventModel.js" as GlobalModel
413
414 MainView {
415 id: mainView
416@@ -68,7 +67,6 @@
417 id: tabPage
418
419 property var currentDay: DateExt.today();
420- property var globalModel;
421
422 // Arguments on startup
423 property bool newevent: false;
424@@ -88,18 +86,6 @@
425
426 if( !weekView.dayStart.isSameDay(currentDay))
427 weekView.dayStart = currentDay
428-
429- setStartEndDateToModel();
430- }
431-
432- function setStartEndDateToModel() {
433- if(globalModel) {
434- globalModel.startPeriod = new Date(currentDay.getFullYear(),0,1,0,0,0,0);
435- globalModel.endPeriod = new Date(currentDay.getFullYear(),11,31,0,0,0,0);
436- // only enable auto update after set the date interval
437- globalModel.autoUpdate = true
438- globalModel.update()
439- }
440 }
441
442 function newEvent() {
443@@ -124,7 +110,7 @@
444 endDate = new Date(endTime);
445 }
446 }
447- pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"startDate": startDate, "endDate": endDate});
448+ pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"startDate": startDate, "endDate": endDate, "model":eventModel});
449 }
450
451 // This function calculate the difference between --endtime and --starttime and choose the better view
452@@ -159,7 +145,6 @@
453
454 if (endtimepattern.test(url))
455 endtime = url.match(/endtime=(\d+)/)[0].replace("endtime=", '');
456-
457 }
458
459 Component.onCompleted: {
460@@ -194,9 +179,6 @@
461 else {
462 tabs.selectedTabIndex= 1;
463 }
464-
465- globalModel = GlobalModel.globalModel();
466- setStartEndDateToModel();
467 } // End of Component.onCompleted:
468
469 // This is for wait that the app is load when newEvent is invoked by argument
470@@ -210,6 +192,13 @@
471 }
472 }
473
474+ EventListModel{
475+ id: eventModel
476+ //This model is just for newevent
477+ //so we dont need any update
478+ autoUpdate: false
479+ }
480+
481 ToolbarItems {
482 id: commonToolBar
483
484@@ -229,7 +218,7 @@
485 iconSource: Qt.resolvedUrl("new-event.svg");
486 text: i18n.tr("New Event");
487 onTriggered: {
488- pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"date":tabPage.currentDay});
489+ pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"date":tabPage.currentDay,"model":eventModel});
490 }
491 }
492 }

Subscribers

People subscribed via source and target branches

to status/vote changes: