~pkunal-parmar/ubuntu-calendar-app/Minor-Performance

« back to all changes in this revision

Viewing changes to AllDayEventComponent.qml

  • Committer: Tarmac
  • Author(s): Kunal Parmar
  • Date: 2014-04-05 07:13:14 UTC
  • mfrom: (233.1.7 ubuntu-calendar-app)
  • Revision ID: tarmac-20140405071314-nbn1c35k6p3c7cq2
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. Fixes: https://bugs.launchpad.net/bugs/1301910.

Approved by Mihir Soni, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import Ubuntu.Components.Popups 0.1
4
4
 
5
5
import "dateExt.js" as DateExt
6
 
import "GlobalEventModel.js" as GlobalModel
7
6
import "ViewType.js" as ViewType
8
7
 
9
8
Rectangle{
11
10
 
12
11
    property var allDayEvents;
13
12
    property var startDay: DateExt.today();
 
13
    property var model;
14
14
 
15
15
    property int type: ViewType.ViewTypeWeek
16
16
 
20
20
 
21
21
    function getAllDayEvents(startDate, endDate) {
22
22
        var map = {};
23
 
        var itemIds = GlobalModel.globalModel().itemIds(startDate, endDate);
24
 
        for(var i = 0 ; i < itemIds.length ; ++i) {
25
 
            var eventId = itemIds[(i)];
26
 
            var event = GlobalModel.globalModel().item(eventId);            
 
23
        var items = model.getItems(startDate,endDate);
 
24
        for(var i = 0 ; i < items.length ; ++i) {
 
25
            var event = items[(i)];
27
26
            if( event && event.allDay ) {
28
27
                var key  = Qt.formatDateTime(event.startDateTime, "dd-MMM-yyyy");
29
28
                if( !(key in map)) {
44
43
        allDayEvents = getAllDayEvents(sd,ed);
45
44
    }
46
45
 
47
 
    Component.onCompleted: {
48
 
        var model = GlobalModel.globalModel();
49
 
        model.reloaded.connect(root.createAllDayEvents);
50
 
    }
51
 
 
52
 
    onStartDayChanged: {
53
 
        createAllDayEvents();
54
 
    }
55
 
 
56
46
    Row {
57
47
        width: parent.width
58
48
        anchors.verticalCenter: parent.verticalCenter
81
71
                            if( allDayLabel.events.length > 1 ) {
82
72
                                PopupUtils.open(popoverComponent, root,{"events": allDayLabel.events})
83
73
                            } else {
84
 
                                pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":allDayLabel.events[0]});
 
74
                                pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":allDayLabel.events[0],"model": model});
85
75
                            }
86
76
                        }
87
77
                    }
148
138
                        anchors.fill: parent
149
139
                        onClicked: {
150
140
                            popover.hide();
151
 
                            pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":modelData});
 
141
                            pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":modelData,"model": model});
152
142
                        }
153
143
                    }
154
144
                }