← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~fboucault/ubuntu-calendar-app/startup_time into lp:ubuntu-calendar-app

 

Florian Boucault has proposed merging lp:~fboucault/ubuntu-calendar-app/startup_time into lp:ubuntu-calendar-app.

Commit message:
Various startup time fixes (totalling around 1.7s saves on krillin):
- Made lunar.js a library: faster and lighter
- Much lighter MonthComponentDelegate (used in YearView)
- Upgraded imports that were forgotten to UITK 1.3 and QtQuick 2.4
- Delayed loading of months other than the one visible
- Delayed loading of years other than the one visible
- Load bottom edge asynchronously including its compilation

Requested reviews:
  Ubuntu Calendar Developers (ubuntu-calendar-dev)

For more details, see:
https://code.launchpad.net/~fboucault/ubuntu-calendar-app/startup_time/+merge/302163

Various startup time fixes (totalling around 1.7s saves on krillin):
- Made lunar.js a library: faster and lighter
- Much lighter MonthComponentDelegate (used in YearView)
- Upgraded imports that were forgotten to UITK 1.3 and QtQuick 2.4
- Delayed loading of months other than the one visible
- Delayed loading of years other than the one visible
- Load bottom edge asynchronously including its compilation
-- 
Your team Ubuntu Calendar Developers is requested to review the proposed merge of lp:~fboucault/ubuntu-calendar-app/startup_time into lp:ubuntu-calendar-app.
=== modified file '3rd-party/lunar.js'
--- 3rd-party/lunar.js	2015-11-23 09:21:05 +0000
+++ 3rd-party/lunar.js	2016-08-05 15:58:58 +0000
@@ -8,6 +8,8 @@
 * @农历转公历:calendar.lunar2solar(1987,09,10); //[you can ignore params of prefix 0]
 * http://blog.jjonline.cn/userInterFace/173.html
 */
+.pragma library
+
 var calendar = {
  
  /**

=== modified file 'AllDayEventComponent.qml'
--- AllDayEventComponent.qml	2016-03-09 01:49:02 +0000
+++ AllDayEventComponent.qml	2016-08-05 15:58:58 +0000
@@ -17,7 +17,7 @@
  */
 import QtQuick 2.4
 import Ubuntu.Components 1.3
-import Ubuntu.Components.Popups 1.0
+import Ubuntu.Components.Popups 1.3
 import QtOrganizer 5.0
 
 import "dateExt.js" as DateExt

=== modified file 'ColorPickerDialog.qml'
--- ColorPickerDialog.qml	2016-01-29 14:47:31 +0000
+++ ColorPickerDialog.qml	2016-08-05 15:58:58 +0000
@@ -17,7 +17,7 @@
  */
 import QtQuick 2.4
 import Ubuntu.Components 1.3
-import Ubuntu.Components.Popups 1.0
+import Ubuntu.Components.Popups 1.3
 
 Dialog {
     id: root

=== modified file 'ContactChoicePopup.qml'
--- ContactChoicePopup.qml	2016-02-04 13:37:00 +0000
+++ ContactChoicePopup.qml	2016-08-05 15:58:58 +0000
@@ -18,8 +18,8 @@
 import QtQuick 2.4
 import Ubuntu.Components 1.3
 import Ubuntu.Components.Popups 1.3
-import Ubuntu.Components.ListItems 1.0
-import Ubuntu.Components.Themes.Ambiance 1.0
+import Ubuntu.Components.ListItems 1.3
+import Ubuntu.Components.Themes.Ambiance 1.3
 import QtOrganizer 5.0
 import QtContacts 5.0
 

=== modified file 'DeleteConfirmationDialog.qml'
--- DeleteConfirmationDialog.qml	2016-01-29 14:47:31 +0000
+++ DeleteConfirmationDialog.qml	2016-08-05 15:58:58 +0000
@@ -17,7 +17,7 @@
  */
 import QtQuick 2.4
 import Ubuntu.Components 1.3
-import Ubuntu.Components.Popups 1.0
+import Ubuntu.Components.Popups 1.3
 
 Dialog {
     id: dialogue

=== modified file 'EditEventConfirmationDialog.qml'
--- EditEventConfirmationDialog.qml	2016-01-29 14:47:31 +0000
+++ EditEventConfirmationDialog.qml	2016-08-05 15:58:58 +0000
@@ -17,7 +17,7 @@
  */
 import QtQuick 2.4
 import Ubuntu.Components 1.3
-import Ubuntu.Components.Popups 1.0
+import Ubuntu.Components.Popups 1.3
 
 Dialog {
     id: dialogue

=== modified file 'EventRepetition.qml'
--- EventRepetition.qml	2016-04-05 12:36:41 +0000
+++ EventRepetition.qml	2016-08-05 15:58:58 +0000
@@ -19,8 +19,8 @@
 import QtQuick 2.4
 import QtOrganizer 5.0
 import Ubuntu.Components 1.3
-import Ubuntu.Components.ListItems 1.0 as ListItem
-import Ubuntu.Components.Pickers 1.0
+import Ubuntu.Components.ListItems 1.3 as ListItem
+import Ubuntu.Components.Pickers 1.3
 import QtOrganizer 5.0
 import "Defines.js" as Defines
 import "Recurrence.js" as Recurrence

=== modified file 'MonthComponent.qml'
--- MonthComponent.qml	2016-04-28 20:19:03 +0000
+++ MonthComponent.qml	2016-08-05 15:58:58 +0000
@@ -67,6 +67,7 @@
         property int monthStartMonth: monthStart.getMonth()
         property int monthStartYear: monthStart.getFullYear()
         readonly property int daysInStartMonth: Date.daysInMonth(monthStartYear, monthStartMonth)
+        readonly property int daysInCurrentMonth: Date.daysInMonth(root.currentYear, root.currentMonth)
 
         //check if current month is start month
         property bool isCurMonthStartMonth: root.currentMonth === monthStartMonth &&
@@ -214,6 +215,15 @@
             return monthGrid.childAt(clickPosition.x, clickPosition.y)
         }
 
+        function getIndexOfChild(object, child) {
+            for (var i = 0; i <= object.children.length; i++) {
+                if (object.children[i] === child) {
+                    return i;
+                }
+            }
+            return -1;
+        }
+
         anchors {
             fill: column
             topMargin: monthGrid.y
@@ -221,12 +231,14 @@
 
         onPressAndHold: {
             var dayItem = getItemAt(mouse.x, mouse.y)
-            var selectedDate = new Date(dayItem.delegateDate.getTime());
+            var index = getIndexOfChild(monthGrid, dayItem);
+            var selectedDate = intern.monthStart.addDays(index);
             pageStack.push(Qt.resolvedUrl("NewEvent.qml"), {"date":selectedDate, "model":eventModel});
         }
         onClicked: {
             var dayItem = getItemAt(mouse.x, mouse.y)
-            var selectedDate = new Date(dayItem.delegateDate.getTime());
+            var index = getIndexOfChild(monthGrid, dayItem);
+            var selectedDate = intern.monthStart.addDays(index);
             if (root.isYearView) {
                 //If yearView is clicked then open selected MonthView
                 root.monthSelected(selectedDate);
@@ -365,15 +377,35 @@
     Component {
         id: monthWithoutEventsDelegate
 
-        MonthComponentDateDelegate {
-            property var delegateDate: intern.monthStart.addDays(index)
-
-            date: delegateDate.getDate()
-            isCurrentMonth: delegateDate.getMonth() === root.currentMonth
-
-            isToday: intern.todayDate == date && intern.isCurMonthTodayMonth
+        Text {
             width: monthGrid.dayWidth
             height: monthGrid.dayHeight
+            horizontalAlignment: Text.AlignHCenter
+            verticalAlignment: Text.AlignVCenter
+            color: {
+                var day = intern.monthStartDate + index;
+                if ( intern.monthStartDate >= 7 ) {
+                    if ( day <= intern.daysInStartMonth ) {
+                        text = day;
+                        return "#AEA79F";
+                    } else {
+                        day = day - intern.daysInStartMonth;
+                    }
+                }
+
+                if ( day <= intern.daysInCurrentMonth ) {
+                    text = day;
+                    if ( intern.todayDate == day && intern.isCurMonthTodayMonth ) {
+                        return "white";
+                    } else {
+                        return "#5D5D5D";
+                    }
+                } else {
+                    day = day - intern.daysInCurrentMonth;
+                    text = day;
+                    return "#AEA79F";
+                }
+            }
         }
     }
 }

=== removed file 'MonthComponentDateDelegate.qml'
--- MonthComponentDateDelegate.qml	2016-03-02 19:55:52 +0000
+++ MonthComponentDateDelegate.qml	1970-01-01 00:00:00 +0000
@@ -1,33 +0,0 @@
-import QtQuick 2.4
-import Ubuntu.Components 1.3
-
-Item{
-    id: dateRootItem
-
-    property int date;
-    property bool isCurrentMonth;
-    property bool isToday;
-    property alias fontSize: dateLabel.font.pixelSize
-    property bool isSelected: false
-
-    Text {
-        id: dateLabel
-        anchors.centerIn: parent
-        text: date
-        color: {
-            if( isCurrentMonth ) {
-                if( isToday || isSelected ) {
-                    "white"
-                } else {
-                    "#5D5D5D"
-                }
-            } else {
-                if(isSelected) {
-                    "white"
-                } else {
-                    "#AEA79F"
-                }
-            }
-        }
-    }
-}

=== modified file 'MonthView.qml'
--- MonthView.qml	2016-07-06 20:17:44 +0000
+++ MonthView.qml	2016-08-05 15:58:58 +0000
@@ -31,7 +31,9 @@
                                                          anchorDate.getMonth(),
                                                          1,
                                                          0, 0, 0)
-    readonly property var currentDate: monthViewPath.currentItem.indexDate
+    readonly property var currentDate: monthViewPath.currentItem.item ?
+                                           monthViewPath.currentItem.item.indexDate
+                                         : null
 
     property var selectedDay;
     property bool displayLunarCalendar: false
@@ -90,41 +92,58 @@
             bottomMargin: monthViewPage.bottomEdgeHeight
         }
 
-        delegate: MonthWithEventsComponent {
-            id: monthDelegate
-
-            property var indexDate: firstDayOfAnchorDate.addMonths(monthViewPath.loopCurrentIndex + monthViewPath.indexType(index))
-
-            currentMonth: indexDate.getMonth()
-            currentYear: indexDate.getFullYear()
-            displayLunarCalendar: monthViewPage.displayLunarCalendar
-
-            autoUpdate: monthViewPage.tabSelected && monthViewPage.active && PathView.isCurrentItem
-            modelFilter: eventModel.filter
-            width: parent.width - units.gu(4)
-            height: parent.height
-            isCurrentItem: PathView.isCurrentItem
-            isActive: !monthViewPath.moving && !monthViewPath.flicking
-            displayWeekNumber: mainView.displayWeekNumber
-            isYearView: false
-
-            onDateSelected: {
-                monthViewPage.dateSelected(date);
-            }
-
-            // make sure that the model is updated after create a new event if it is marked as auto-update false
-            Connections {
-                target: monthViewPage
-                onActiveChanged: {
-                    if (monthViewPage.active) {
-                        monthDelegate.update()
-                    }
-                }
-                onEventSaved: {
-                    monthDelegate.update()
-                }
-                onEventDeleted: {
-                    monthDelegate.update()
+        property bool loadNonVisibleDelegate: false
+
+        Timer {
+            running: true
+            onTriggered: monthViewPath.loadNonVisibleDelegate = true
+            interval: 1
+        }
+
+        delegate: Loader {
+            id: delegateLoader
+
+            asynchronous: true
+            width: PathView.view.width
+            height: PathView.view.height
+            active: monthViewPath.loadNonVisibleDelegate || (index === monthViewPath.currentIndex)
+
+            sourceComponent: MonthWithEventsComponent {
+                id: monthDelegate
+
+                property var indexDate: firstDayOfAnchorDate.addMonths(monthViewPath.loopCurrentIndex + monthViewPath.indexType(index))
+
+                currentMonth: indexDate.getMonth()
+                currentYear: indexDate.getFullYear()
+                displayLunarCalendar: monthViewPage.displayLunarCalendar
+
+                autoUpdate: monthViewPage.tabSelected && monthViewPage.active && PathView.isCurrentItem
+                modelFilter: eventModel.filter
+                width: parent.width - units.gu(4)
+                height: parent.height
+                isCurrentItem: PathView.isCurrentItem
+                isActive: !monthViewPath.moving && !monthViewPath.flicking
+                displayWeekNumber: mainView.displayWeekNumber
+                isYearView: false
+
+                onDateSelected: {
+                    monthViewPage.dateSelected(date);
+                }
+
+                // make sure that the model is updated after create a new event if it is marked as auto-update false
+                Connections {
+                    target: monthViewPage
+                    onActiveChanged: {
+                        if (monthViewPage.active) {
+                            monthDelegate.update()
+                        }
+                    }
+                    onEventSaved: {
+                        monthDelegate.update()
+                    }
+                    onEventDeleted: {
+                        monthDelegate.update()
+                    }
                 }
             }
         }

=== modified file 'NewEvent.qml'
--- NewEvent.qml	2016-07-05 20:46:44 +0000
+++ NewEvent.qml	2016-08-05 15:58:58 +0000
@@ -19,10 +19,10 @@
 import QtQuick 2.4
 import QtOrganizer 5.0
 import Ubuntu.Components 1.3
-import Ubuntu.Components.Popups 1.0
-import Ubuntu.Components.ListItems 1.0 as ListItems
-import Ubuntu.Components.Themes.Ambiance 1.0
-import Ubuntu.Components.Pickers 1.0
+import Ubuntu.Components.Popups 1.3
+import Ubuntu.Components.ListItems 1.3 as ListItems
+import Ubuntu.Components.Themes.Ambiance 1.3
+import Ubuntu.Components.Pickers 1.3
 import QtOrganizer 5.0
 import "Defines.js" as Defines
 import "dateExt.js" as DateExt

=== modified file 'NewEventBottomEdge.qml'
--- NewEventBottomEdge.qml	2016-05-16 13:22:52 +0000
+++ NewEventBottomEdge.qml	2016-08-05 15:58:58 +0000
@@ -73,37 +73,51 @@
 
     onCollapseCompleted: {
         if (bottomEdge._realPage) {
-            bottomEdge._realPage.destroy()
-            bottomEdge._realPage = null
-            _realPage = editorPageBottomEdge.createObject(null)
+            createPage()
         }
     }
 
     Component.onCompleted:  {
         if (eventModel)
-            _realPage = editorPageBottomEdge.createObject(null)
+            createPage()
     }
 
     onEventModelChanged: {
         if (eventModel)
-            _realPage = editorPageBottomEdge.createObject(null)
-    }
-
-    Component {
-        id: editorPageBottomEdge
-        NewEvent {
-            id: newEventPage
-
-            implicitWidth: bottomEdge.width
-            implicitHeight: bottomEdge.height
-            reminderValue: bottomEdge.reminderValue
-            model: bottomEdge.eventModel
-            date: bottomEdge.date
-            enabled: bottomEdge.status === BottomEdge.Committed
-            active: bottomEdge.status === BottomEdge.Committed
-            visible: (bottomEdge.status !== BottomEdge.Hidden)
+            createPage()
+    }
+
+    function createPage() {
+        editorPageLoader.active = false;
+        editorPageLoader.active = true;
+    }
+
+    Loader {
+        id: editorPageLoader
+        active: false
+        asynchronous: true
+        onStatusChanged: {
+            if (status == Loader.Null) {
+                bottomEdge._realPage = null;
+            } else if (status == Loader.Ready) {
+                bottomEdge._realPage = item;
+            }
+        }
+        Component.onCompleted: setSource("NewEvent.qml", {
+                                             "implicitWidth": Qt.binding(function() { return bottomEdge.width } ),
+                                             "implicitHeight": Qt.binding(function() { return bottomEdge.height } ),
+                                             "reminderValue": Qt.binding(function() { return bottomEdge.reminderValue } ),
+                                             "model": Qt.binding(function() { return bottomEdge.eventModel } ),
+                                             "date": Qt.binding(function() { return bottomEdge.date } ),
+                                             "enabled": Qt.binding(function() { return bottomEdge.status === BottomEdge.Committed } ),
+                                             "active": Qt.binding(function() { return bottomEdge.status === BottomEdge.Committed } ),
+                                             "visible": Qt.binding(function() { return (bottomEdge.status !== BottomEdge.Hidden) } ),
+                                             "bottomEdgePageStack": Qt.binding(function() { return bottomEdge.pageStack } ),
+                                         })
+
+        Connections {
+            target: editorPageLoader.item ? editorPageLoader.item : null
             onCanceled: bottomEdge.collapse()
-            bottomEdgePageStack: bottomEdge.pageStack
             onEventSaved: {
                 bottomEdge.collapse()
                 bottomEdge.eventSaved(event)
@@ -113,11 +127,4 @@
             }
         }
     }
-
-    Component.onDestruction: {
-        if (bottomEdge._realPage) {
-            bottomEdge._realPage.destroy()
-            bottomEdge._realPage = null
-        }
-    }
 }

=== modified file 'NewEventTimePicker.qml'
--- NewEventTimePicker.qml	2016-03-22 20:09:08 +0000
+++ NewEventTimePicker.qml	2016-08-05 15:58:58 +0000
@@ -1,7 +1,7 @@
 import QtQuick 2.4
-import Ubuntu.Components.ListItems 1.0 as ListItem
-import Ubuntu.Components.Themes.Ambiance 1.0
-import Ubuntu.Components.Pickers 1.0
+import Ubuntu.Components.ListItems 1.3 as ListItem
+import Ubuntu.Components.Themes.Ambiance 1.3
+import Ubuntu.Components.Pickers 1.3
 
 Column {
     id: dateTimeInput

=== modified file 'OnlineAccountsDummy.qml'
--- OnlineAccountsDummy.qml	2015-03-28 11:31:47 +0000
+++ OnlineAccountsDummy.qml	2016-08-05 15:58:58 +0000
@@ -14,7 +14,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-import QtQuick 2.2
+import QtQuick 2.4
 
 Item {
     id: root

=== modified file 'Scroller.qml'
--- Scroller.qml	2016-01-29 14:47:31 +0000
+++ Scroller.qml	2016-08-05 15:58:58 +0000
@@ -18,7 +18,7 @@
 
 import QtQuick 2.4
 import Ubuntu.Components 1.3
-import Ubuntu.Components.ListItems 1.0 as ListItems
+import Ubuntu.Components.ListItems 1.3 as ListItems
 
 Item {
     id: root

=== modified file 'TimeLineBaseComponent.qml'
--- TimeLineBaseComponent.qml	2016-07-05 19:40:11 +0000
+++ TimeLineBaseComponent.qml	2016-08-05 15:58:58 +0000
@@ -18,7 +18,7 @@
 
 import QtQuick 2.4
 import Ubuntu.Components 1.3
-import Ubuntu.Components.Popups 1.0
+import Ubuntu.Components.Popups 1.3
 import QtOrganizer 5.0
 
 import "dateExt.js" as DateExt

=== modified file 'YearView.qml'
--- YearView.qml	2016-03-14 16:22:46 +0000
+++ YearView.qml	2016-08-05 15:58:58 +0000
@@ -110,12 +110,21 @@
             bottomMargin: yearViewPage.bottomEdgeHeight
         }
 
+        property bool loadNonVisibleDelegate: false
+
+        Timer {
+            running: true
+            onTriggered: yearPathView.loadNonVisibleDelegate = true
+            interval: 1
+        }
+
         delegate: Loader {
             id: delegateLoader
 
             asynchronous: true
             width: PathView.view.width
             height: PathView.view.height
+            active: yearPathView.loadNonVisibleDelegate || (index === yearPathView.currentIndex)
 
             sourceComponent: YearViewDelegate {
                 visible: delegateLoader.status === Loader.Ready

=== modified file 'calendar.qml'
--- calendar.qml	2016-07-06 21:29:27 +0000
+++ calendar.qml	2016-08-05 15:58:58 +0000
@@ -17,7 +17,7 @@
  */
 import QtQuick 2.4
 import Ubuntu.Components 1.3
-import Ubuntu.Components.Popups 1.0
+import Ubuntu.Components.Popups 1.3
 import QtOrganizer 5.0
 import Qt.labs.settings 1.0
 


Follow ups