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

Proposed by Kunal Parmar
Status: Merged
Approved by: Mihir Soni
Approved revision: 524
Merged at revision: 526
Proposed branch: lp:~pkunal-parmar/ubuntu-calendar-app/YearMonthPerformance
Merge into: lp:ubuntu-calendar-app
Diff against target: 372 lines (+209/-95)
6 files modified
MonthComponent.qml (+3/-1)
MonthComponentDateDelegate.qml.moved (+72/-0)
MonthView.qml (+23/-12)
YearView.qml (+14/-81)
YearViewDelegate.qml (+96/-0)
tests/autopilot/calendar_app/__init__.py (+1/-1)
To merge this branch: bzr merge lp:~pkunal-parmar/ubuntu-calendar-app/YearMonthPerformance
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Mihir Soni Approve
Review via email: mp+239261@code.launchpad.net

Commit message

Loading some components using Loader asynchronous to improve Yearview and MonthView performance

Description of the change

Loading some components using Loader asynchronous to improve Yearview and MonthView performance

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
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 and has improved yearview loading by few seconds.
Wonderful !!

review: Approve
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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
524. By Kunal Parmar

temp

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'MonthComponent.qml'
--- MonthComponent.qml 2014-10-22 13:41:52 +0000
+++ MonthComponent.qml 2014-10-23 12:51:37 +0000
@@ -24,6 +24,8 @@
24 id: root24 id: root
25 objectName: "MonthComponent"25 objectName: "MonthComponent"
2626
27 property bool isCurrentItem;
28
27 property bool showEvents: false29 property bool showEvents: false
2830
29 property var currentMonth;31 property var currentMonth;
@@ -66,7 +68,7 @@
66 EventListModel {68 EventListModel {
67 id: mainModel69 id: mainModel
68 startPeriod: intern.monthStart.midnight();70 startPeriod: intern.monthStart.midnight();
69 endPeriod: intern.monthStart.addDays((monthGrid.weekCount*7)-1).endOfDay()71 endPeriod: intern.monthStart.addDays((/*monthGrid.weekCount*/ 6 * 7)-1).endOfDay()
70 filter: eventModel.filter72 filter: eventModel.filter
71 onModelChanged: {73 onModelChanged: {
72 intern.eventStatus = Qt.binding(function() { return mainModel.containsItems(startPeriod,endPeriod,24*60*60)});74 intern.eventStatus = Qt.binding(function() { return mainModel.containsItems(startPeriod,endPeriod,24*60*60)});
7375
=== added file 'MonthComponentDateDelegate.qml.moved'
--- MonthComponentDateDelegate.qml.moved 1970-01-01 00:00:00 +0000
+++ MonthComponentDateDelegate.qml.moved 2014-10-23 12:51:37 +0000
@@ -0,0 +1,72 @@
1import QtQuick 2.0
2import Ubuntu.Components 1.1
3
4Item{
5 id: dateRootItem
6
7 property int date;
8 property bool isCurrentMonth;
9 property bool isToday
10
11 Loader {
12 width: parent.width < parent.height ? parent.width : parent.height
13 height: width
14 anchors.centerIn: parent
15 sourceComponent: isToday && isCurrentMonth ? highLightComp : undefined
16 }
17
18 Label {
19 id: dateLabel
20 anchors.centerIn: parent
21 width: parent.width
22 text: date
23 horizontalAlignment: Text.AlignHCenter
24 fontSize: root.dateLabelFontSize
25 color: {
26 if( isCurrentMonth ) {
27 if(isToday) {
28 "white"
29 } else {
30 "#5D5D5D"
31 }
32 } else {
33 "#AEA79F"
34 }
35 }
36 }
37
38 Loader{
39 property bool shouldLoad: showEvents
40 && intern.eventStatus !== undefined
41 && intern.eventStatus[index] !== undefined
42 &&intern.eventStatus[index]
43 sourceComponent: shouldLoad ? eventIndicatorComp : undefined
44 anchors.top: dateLabel.bottom
45 anchors.horizontalCenter: dateLabel.horizontalCenter
46 }
47
48 MouseArea {
49 anchors.fill: parent
50 onPressAndHold: {
51 var selectedDate = new Date();
52 selectedDate.setFullYear(intern.monthStartYear)
53 selectedDate.setMonth(intern.monthStartMonth + 1)
54 selectedDate.setDate(date)
55 selectedDate.setMinutes(60, 0, 0)
56 pageStack.push(Qt.resolvedUrl("NewEvent.qml"), {"date":selectedDate, "model":eventModel});
57 }
58 onClicked: {
59 var selectedDate = new Date(intern.monthStartYear,
60 intern.monthStartMonth,
61 intern.monthStartDate + index, 0, 0, 0, 0)
62 //If monthView is clicked then open selected DayView
63 if ( isYearView === false ) {
64 root.dateSelected(selectedDate);
65 }
66 //If yearView is clicked then open selected MonthView
67 else {
68 root.monthSelected(selectedDate);
69 }
70 }
71 }
72}
073
=== modified file 'MonthView.qml'
--- MonthView.qml 2014-10-02 13:44:25 +0000
+++ MonthView.qml 2014-10-23 12:51:37 +0000
@@ -89,21 +89,32 @@
89 return new Date(date.getFullYear(), date.getMonth() + month, 1, 0, 0, 0);89 return new Date(date.getFullYear(), date.getMonth() + month, 1, 0, 0, 0);
90 }90 }
9191
92 delegate: MonthComponent {92 delegate: Loader {
93 property bool isCurrentItem: index === monthViewPath.currentIndex
94
95 showEvents: true
96
97 width: parent.width - units.gu(4)93 width: parent.width - units.gu(4)
98 height: parent.height94 height: parent.height
9995
100 currentMonth: monthViewPath.addMonth(monthViewPath.startMonth,96 sourceComponent: delegateComponent
101 monthViewPath.indexType(index));97 asynchronous: index !== monthViewPath.currentIndex
10298
103 isYearView: false99 Component {
104100 id: delegateComponent
105 onDateSelected: {101
106 monthViewPage.dateSelected(date);102 MonthComponent {
103 isCurrentItem: index === monthViewPath.currentIndex
104
105 showEvents: true
106
107 anchors.fill: parent
108
109 currentMonth: monthViewPath.addMonth(monthViewPath.startMonth,
110 monthViewPath.indexType(index));
111
112 isYearView: false
113
114 onDateSelected: {
115 monthViewPage.dateSelected(date);
116 }
117 }
107 }118 }
108 }119 }
109 }120 }
110121
=== modified file 'YearView.qml'
--- YearView.qml 2014-10-02 13:44:25 +0000
+++ YearView.qml 2014-10-23 12:51:37 +0000
@@ -62,92 +62,25 @@
62 currentYear = currentYear - 1;62 currentYear = currentYear - 1;
63 }63 }
6464
65 delegate: GridView{65 delegate: Loader {
66 id: yearView
67 clip: true
68 focus: index == yearPathView.currentIndex
69
70 property int scrollMonth: 0;
71 property bool isCurrentItem: index == yearPathView.currentIndex
72 property int year: (yearViewPage.currentYear + yearPathView.indexType(index))
73
74 width: parent.width66 width: parent.width
75 height: parent.height67 height: parent.height
76 anchors.top: parent.top68 anchors.top: parent.top
7769
78 readonly property int minCellWidth: units.gu(30)70 asynchronous: index !== yearPathView.currentIndex
79 cellWidth: Math.floor(Math.min.apply(Math, [3, 4].map(function(n)71 sourceComponent: delegateComponent
80 { return ((width / n >= minCellWidth) ? width / n : width / 2) })))72
8173 Component{
82 cellHeight: cellWidth * 1.474 id: delegateComponent
8375
84 model: 12 /* months in a year */76 YearViewDelegate{
8577 focus: index == yearPathView.currentIndex
86 onYearChanged: {78
87 scrollMonth = 0;79 scrollMonth: 0;
88 var today = new Date();80 isCurrentItem: index == yearPathView.currentIndex
89 if(year == today.getFullYear()) {81 year: (yearViewPage.currentYear + yearPathView.indexType(index))
90 scrollMonth = today.getMonth();82
91 }
92 yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
93 }
94
95 //scroll in case content height changed
96 onHeightChanged: {
97 yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
98 }
99
100 Component.onCompleted: {
101 yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
102 }
103
104 Connections{
105 target: yearPathView
106 onScrollUp: {
107 scrollMonth -= 2;
108 if(scrollMonth < 0) {
109 scrollMonth = 0;
110 }
111 yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
112 }
113
114 onScrollDown: {
115 scrollMonth += 2;
116 var visibleMonths = yearView.height / cellHeight;
117 if( scrollMonth >= (11 - visibleMonths)) {
118 scrollMonth = (11 - visibleMonths);
119 }
120 yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
121 }
122 }
123
124 delegate: Item {
125 width: yearView.cellWidth
126 height: yearView.cellHeight
127
128 UbuntuShape {
129 anchors.fill: parent83 anchors.fill: parent
130 anchors.margins: units.gu(0.5)
131 radius: "medium"
132
133 MonthComponent {
134 id: monthComponent
135 objectName: "monthComponent" + index
136 showEvents: false
137 currentMonth: new Date(yearView.year, index, 1, 0, 0, 0, 0)
138
139 isYearView: true
140 anchors.fill: parent
141
142 dayLabelFontSize:"x-small"
143 dateLabelFontSize: "medium"
144 monthLabelFontSize: "medium"
145 yearLabelFontSize: "small"
146
147 onMonthSelected: {
148 yearViewPage.monthSelected(date);
149 }
150 }
151 }84 }
152 }85 }
153 }86 }
15487
=== added file 'YearViewDelegate.qml'
--- YearViewDelegate.qml 1970-01-01 00:00:00 +0000
+++ YearViewDelegate.qml 2014-10-23 12:51:37 +0000
@@ -0,0 +1,96 @@
1import QtQuick 2.0
2import Ubuntu.Components 1.1
3
4GridView{
5 id: yearView
6 clip: true
7
8 property int scrollMonth;
9 property bool isCurrentItem;
10 property int year;
11
12 readonly property int minCellWidth: units.gu(30)
13 cellWidth: Math.floor(Math.min.apply(Math, [3, 4].map(function(n)
14 { return ((width / n >= minCellWidth) ? width / n : width / 2) })))
15
16 cellHeight: cellWidth * 1.4
17
18 model: 12 /* months in a year */
19
20 onYearChanged: {
21 scrollMonth = 0;
22 var today = new Date();
23 if(year == today.getFullYear()) {
24 scrollMonth = today.getMonth();
25 }
26 yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
27 }
28
29 //scroll in case content height changed
30 onHeightChanged: {
31 yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
32 }
33
34 Component.onCompleted: {
35 yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
36 }
37
38 Connections{
39 target: yearPathView
40 onScrollUp: {
41 scrollMonth -= 2;
42 if(scrollMonth < 0) {
43 scrollMonth = 0;
44 }
45 yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
46 }
47
48 onScrollDown: {
49 scrollMonth += 2;
50 var visibleMonths = yearView.height / cellHeight;
51 if( scrollMonth >= (11 - visibleMonths)) {
52 scrollMonth = (11 - visibleMonths);
53 }
54 yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
55 }
56 }
57
58 delegate: Loader {
59 width: yearView.cellWidth
60 height: yearView.cellHeight
61
62 sourceComponent: delegateComponent
63 asynchronous: !yearView.focus
64
65 Component {
66 id: delegateComponent
67
68 UbuntuShape {
69 anchors.fill: parent
70 anchors.margins: units.gu(0.5)
71 radius: "medium"
72
73 MonthComponent {
74 id: monthComponent
75 objectName: "monthComponent" + index
76 showEvents: false
77 currentMonth: new Date(yearView.year, index, 1, 0, 0, 0, 0)
78
79 isCurrentItem: yearView.focus
80
81 isYearView: true
82 anchors.fill: parent
83
84 dayLabelFontSize:"x-small"
85 dateLabelFontSize: "medium"
86 monthLabelFontSize: "medium"
87 yearLabelFontSize: "small"
88
89 onMonthSelected: {
90 yearViewPage.monthSelected(date);
91 }
92 }
93 }
94 }
95 }
96}
097
=== modified file 'tests/autopilot/calendar_app/__init__.py'
--- tests/autopilot/calendar_app/__init__.py 2014-10-22 19:06:26 +0000
+++ tests/autopilot/calendar_app/__init__.py 2014-10-23 12:51:37 +0000
@@ -299,7 +299,7 @@
299 path_view_base = self.select_single(299 path_view_base = self.select_single(
300 'PathViewBase', objectName='yearPathView')300 'PathViewBase', objectName='yearPathView')
301 return path_view_base.select_single(301 return path_view_base.select_single(
302 ubuntuuitoolkit.QQuickGridView, isCurrentItem=True)302 "YearViewDelegate", isCurrentItem=True)
303303
304 def _find_month_component(self, grid, index):304 def _find_month_component(self, grid, index):
305 try:305 try:

Subscribers

People subscribed via source and target branches

to status/vote changes: