← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~gary-wzl77/ubuntu-calendar-app/optimization_tab_change into lp:ubuntu-calendar-app

 

Gary.Wang has proposed merging lp:~gary-wzl77/ubuntu-calendar-app/optimization_tab_change into lp:ubuntu-calendar-app.

Commit message:
Tab change will cause dynamic creation(Qt.ResolvedUrl) for qml object back and forth.Using Qt.CreateComponent for dynamic creation for the first time and reuse existing obj without re-creating.

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

For more details, see:
https://code.launchpad.net/~gary-wzl77/ubuntu-calendar-app/optimization_tab_change/+merge/268873

Tab change will cause dynamic creation(Qt.ResolvedUrl) for qml object back and forth.Using Qt.CreateComponent for dynamic creation for the first time and reuse existing obj without re-creating.
-- 
Your team Ubuntu Calendar Developers is requested to review the proposed merge of lp:~gary-wzl77/ubuntu-calendar-app/optimization_tab_change into lp:ubuntu-calendar-app.
=== modified file 'ContactChoicePopup.qml'
--- ContactChoicePopup.qml	2014-09-20 10:45:35 +0000
+++ ContactChoicePopup.qml	2015-08-24 05:15:53 +0000
@@ -94,7 +94,7 @@
             objectName: "contactPopoverList"
             width: parent.width
             model: contactModel
-            height: units.gu(30)
+            height: units.gu(15)
             clip: true
             delegate: Standard{
                 objectName: "contactPopoverList%1".arg(index)

=== modified file 'EventBubble.qml'
--- EventBubble.qml	2015-01-22 19:34:59 +0000
+++ EventBubble.qml	2015-08-24 05:15:53 +0000
@@ -221,8 +221,8 @@
         anchors.fill: parent
         drag.target: isLiveEditing ? infoBubble : null
         drag.axis: Drag.YAxis
-        drag.minimumY: flickable.y
-        drag.maximumY: flickable.contentHeight - infoBubble.height
+        drag.minimumY: flickable === null? 0: flickable.y
+        drag.maximumY: flickable === null? 0 :flickable.contentHeight - infoBubble.height
         onReleased: parent.Drag.drop()
         onClicked: {
             if( isLiveEditing ) {

=== modified file 'EventListModel.qml'
--- EventListModel.qml	2015-08-02 03:59:08 +0000
+++ EventListModel.qml	2015-08-24 05:15:53 +0000
@@ -44,7 +44,7 @@
         var newObject = Qt.createQmlObject("import QtQuick 2.3; Timer {interval: 1000; running: true; repeat: false;}",
             eventModel, "EventListMode.qml");
         newObject.onTriggered.connect( function(){
-            var items = getItems(eventModel.startPeriod, eventModel.endPeriod);
+            var items = itemsByTimePeriod(eventModel.startPeriod, eventModel.endPeriod);
             if( isLoading == true && items.length === 0) {
                 isLoading = false;
                 modelChanged();
@@ -53,7 +53,6 @@
         });
     }
 
-
     onModelChanged: {
         isLoading = false
         if(listeners === undefined){

=== modified file 'NewEvent.qml'
--- NewEvent.qml	2015-08-04 02:18:52 +0000
+++ NewEvent.qml	2015-08-24 05:15:53 +0000
@@ -255,6 +255,7 @@
 
             model.saveItem(event);
             pageStack.pop();
+
             root.eventAdded(event);
         }
     }

=== modified file 'YearView.qml'
--- YearView.qml	2015-02-18 19:27:20 +0000
+++ YearView.qml	2015-08-24 05:15:53 +0000
@@ -29,6 +29,12 @@
 
     Keys.forwardTo: [yearPathView]
 
+    function refreshCurrentYear(year) {
+        currentYear = year;
+        var yearViewDelegate = yearPathView.currentItem.item;
+        yearViewDelegate.refresh();
+    }
+
     Action {
         id: calendarTodayAction
         objectName:"todaybutton"
@@ -85,7 +91,7 @@
 
                     scrollMonth: 0;
                     isCurrentItem: index == yearPathView.currentIndex
-                    year: (yearViewPage.currentYear + yearPathView.indexType(index))
+                    year: (currentYear + yearPathView.indexType(index))
 
                     anchors.fill: parent
                 }

=== modified file 'YearViewDelegate.qml'
--- YearViewDelegate.qml	2014-11-29 09:40:53 +0000
+++ YearViewDelegate.qml	2015-08-24 05:15:53 +0000
@@ -18,6 +18,19 @@
     model: 12 /* months in a year */
 
     onYearChanged: {
+        refresh();
+    }
+
+    //scroll in case content height changed
+    onHeightChanged: {
+        yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
+    }
+
+    Component.onCompleted: {
+        yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
+    }
+
+    function refresh() {
         scrollMonth = 0;
         var today = new Date();
         if(year == today.getFullYear()) {
@@ -26,15 +39,6 @@
         yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
     }
 
-    //scroll in case content height changed
-    onHeightChanged: {
-        yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
-    }
-
-    Component.onCompleted: {
-        yearView.positionViewAtIndex(scrollMonth, GridView.Beginning);
-    }
-
     Connections{
         target: yearPathView
         onScrollUp: {

=== modified file 'calendar.qml'
--- calendar.qml	2015-06-11 12:29:28 +0000
+++ calendar.qml	2015-08-24 05:15:53 +0000
@@ -211,7 +211,7 @@
 
         Tabs{
             id: tabs
-            Keys.forwardTo: [tabs.currentPage.item]
+            Keys.forwardTo: [tabs.currentPage]
 
             property var currentDay: DateExt.today();
 
@@ -341,156 +341,139 @@
                 }
             }
 
+            onSelectedTabChanged: {
+                switch (tabs.selectedTab) {
+                case yearTab:{
+                    if (yearTab.page === null) {
+                        var yearViewCom = Qt.createComponent("YearView.qml");
+                        if (yearViewCom.status === Component.Ready) {
+                            var yearViewObj = yearViewCom.createObject(mainView);
+
+                            yearViewObj.monthSelected.connect(function (date){
+                                var now = DateExt.today();
+                                if( date.getMonth() === now.getMonth()
+                                        && date.getFullYear() === now.getFullYear()) {
+                                    tabs.currentDay = now;
+                                } else {
+                                    tabs.currentDay = date.midnight();
+                                }
+                                tabs.selectedTabIndex = monthTab.index;
+                            })
+
+                            yearTab.page = yearViewObj;
+                        }
+                    } else {
+                        yearTab.page.refreshCurrentYear(DateExt.today().getFullYear());
+                    }
+                } break;
+                case monthTab: {
+                    if (monthTab.page === null) {
+                        var monthViewCom = Qt.createComponent("MonthView.qml");
+                        if (monthViewCom.status === Component.Ready) {
+                            var monthViewObj = monthViewCom.createObject(mainView);
+
+                            monthViewObj.dateSelected.connect(function (date) {
+                                tabs.currentDay = date;
+                                tabs.selectedTabIndex = dayTab.index;
+                            })
+
+                            monthTab.page = monthViewObj;
+                        }
+                    } else {
+                        monthTab.page.currentMonth = tabs.currentDay.midnight();
+                    }
+                } break;
+                case weekTab: {
+                    if (weekTab.page === null) {
+                        var weekViewCom = Qt.createComponent("WeekView.qml");
+                        if (weekViewCom.status === Component.Ready) {
+                            var weekViewObj = weekViewCom.createObject(mainView);
+
+                            weekViewObj.isCurrentPage = Qt.binding(function() { return tabs.selectedTab == weekTab })
+                            weekViewObj.onDayStartChanged.connect(function (){
+                                tabs.currentDay = weekViewObj.dayStart;
+                            });
+                            weekViewObj.dateSelected.connect(function (date){
+                                tabs.currentDay = date;
+                                tabs.selectedTabIndex = dayTab.index;
+                            });
+
+                            weekTab.page = weekViewObj;
+                        }
+                    } else {
+                        weekTab.page.dayStart = tabs.currentDay;
+                    }
+                } break;
+                case dayTab: {
+                    if (dayTab.page === null) {
+                        var dayViewCom = Qt.createComponent("DayView.qml");
+                        if (dayViewCom.status === Component.Ready) {
+                            var dayViewObj = dayViewCom.createObject(mainView);
+
+                            dayViewObj.isCurrentPage= Qt.binding(function() { return tabs.selectedTab == dayTab })
+                            dayViewObj.onCurrentDayChanged.connect(function (){
+                                tabs.currentDay = dayViewObj.currentDay;
+                            });
+                            dayViewObj.dateSelected.connect(function (date) {
+                                tabs.currentDay = date;
+                            });
+
+                            dayTab.page  =dayViewObj;
+                        }
+                    } else {
+                        dayTab.page.currentDay = tabs.currentDay;
+                    }
+                } break;
+                case agendaTab: {
+                    var agendaViewCom = Qt.createComponent("AgendaView.qml");
+                    if (agendaViewCom.status === Component.Ready) {
+                        var agendaViewObj = agendaViewCom.createObject(mainView);
+
+                        agendaViewObj.dateSelected.connect(function (date){
+                            tabs.currentDay = date;
+                            tabs.selectedTabIndex = dayTab.index;
+                        })
+                        agendaTab.page = agendaViewObj;
+                    }
+                } break;
+                default:
+                    break;
+                }
+            }
+
             Tab{
                 id: yearTab
                 objectName: "yearTab"
                 title: i18n.tr("Year")
-                page: Loader{
-                    id: yearViewLoader
-                    objectName: "yearViewLoader"
-                    source: tabs.selectedTab == yearTab ? Qt.resolvedUrl("YearView.qml"):""
-                    onLoaded: {
-                        item.currentYear = tabs.currentDay.getFullYear();
-                    }
-
-                    anchors{
-                        left: parent.left
-                        right: parent.right
-                        bottom: parent.bottom
-                    }
-
-                    Connections{
-                        target: yearViewLoader.item
-                        onMonthSelected: {
-                            var now = DateExt.today();
-                            if( date.getMonth() === now.getMonth()
-                                    && date.getFullYear() === now.getFullYear()) {
-                                tabs.currentDay = now;
-                            } else {
-                                tabs.currentDay = date.midnight();
-                            }
-                            tabs.selectedTabIndex = monthTab.index;
-                        }
-                    }
-                }
+                page: null
             }
 
             Tab{
                 id: monthTab
                 objectName: "monthTab"
                 title: i18n.tr("Month")
-                page: Loader{
-                    id: monthViewLoader
-                    objectName: "monthViewLoader"
-                    source: tabs.selectedTab == monthTab ? Qt.resolvedUrl("MonthView.qml"):""
-                    onLoaded: {
-                        item.currentMonth = tabs.currentDay.midnight();
-                    }
-
-                    anchors{
-                        left: parent.left
-                        right: parent.right
-                        bottom: parent.bottom
-                    }
-
-                    Connections{
-                        target: monthViewLoader.item
-                        onDateSelected: {
-                            tabs.currentDay = date;
-                            tabs.selectedTabIndex = dayTab.index;
-                        }
-                    }
-                }
+                page: null
             }
 
             Tab{
                 id: weekTab
                 objectName: "weekTab"
                 title: i18n.tr("Week")
-                page: Loader{
-                    id: weekViewLoader
-                    objectName: "weekViewLoader"
-                    source: tabs.selectedTab == weekTab ? Qt.resolvedUrl("WeekView.qml"):""
-                    onLoaded: {
-                        item.isCurrentPage= Qt.binding(function() { return tabs.selectedTab == weekTab })
-                        item.dayStart = tabs.currentDay;
-                    }
-
-                    anchors{
-                        left: parent.left
-                        right: parent.right
-                        bottom: parent.bottom
-                    }
-
-                    Connections{
-                        target: weekViewLoader.item
-                        onDayStartChanged: {
-                            tabs.currentDay = weekViewLoader.item.dayStart;
-                        }
-
-                        onDateSelected: {
-                            tabs.currentDay = date;
-                            tabs.selectedTabIndex = dayTab.index;
-                        }
-                    }
-                }
+                page: null
             }
 
             Tab{
                 id: dayTab
                 objectName: "dayTab"
                 title: i18n.tr("Day")
-                page: Loader{
-                    id: dayViewLoader
-                    objectName: "dayViewLoader"
-                    source: tabs.selectedTab == dayTab ? Qt.resolvedUrl("DayView.qml"):""
-                    onLoaded: {
-                        item.isCurrentPage= Qt.binding(function() { return tabs.selectedTab == dayTab })
-                        item.currentDay = tabs.currentDay;
-                    }
-
-                    anchors{
-                        left: parent.left
-                        right: parent.right
-                        bottom: parent.bottom
-                    }
-
-                    Connections{
-                        target: dayViewLoader.item
-                        onCurrentDayChanged: {
-                            tabs.currentDay = dayViewLoader.item.currentDay;
-                        }
-
-                        onDateSelected: {
-                            tabs.currentDay = date;
-                        }
-                    }
-                }
+                page: null
             }
 
             Tab {
                 id: agendaTab
                 objectName: "agendaTab"
                 title: i18n.tr("Agenda")
-                page: Loader {
-                    id: agendaViewLoader
-                    objectName: "agendaViewLoader"
-                    source: tabs.selectedTab == agendaTab ? Qt.resolvedUrl("AgendaView.qml"):""
-
-                    anchors{
-                        left: parent.left
-                        right: parent.right
-                        bottom: parent.bottom
-                    }
-
-                    Connections{
-                        target: agendaViewLoader.item
-                        onDateSelected: {
-                            tabs.currentDay = date;
-                            tabs.selectedTabIndex = dayTab.index;
-                        }
-                    }
-                }
+                page: null
             }
         }
     }

=== modified file 'po/com.ubuntu.calendar.pot'
--- po/com.ubuntu.calendar.pot	2015-08-04 02:18:52 +0000
+++ po/com.ubuntu.calendar.pot	2015-08-24 05:15:53 +0000
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-08-04 10:18+0800\n"
+"POT-Creation-Date: 2015-08-24 13:07+0800\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -19,7 +19,7 @@
 "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
 
 #: ../AgendaView.qml:51 ../DayView.qml:40 ../MonthView.qml:37
-#: ../WeekView.qml:42 ../YearView.qml:36
+#: ../WeekView.qml:42 ../YearView.qml:42
 msgid "Today"
 msgstr ""
 
@@ -136,7 +136,7 @@
 msgid "Delete"
 msgstr ""
 
-#: ../EditEventConfirmationDialog.qml:29 ../NewEvent.qml:324
+#: ../EditEventConfirmationDialog.qml:29 ../NewEvent.qml:325
 msgid "Edit Event"
 msgstr ""
 
@@ -154,7 +154,7 @@
 msgid "Edit this"
 msgstr ""
 
-#: ../EventActions.qml:50 ../NewEvent.qml:324
+#: ../EventActions.qml:50 ../NewEvent.qml:325
 msgid "New Event"
 msgstr ""
 
@@ -165,7 +165,7 @@
 msgid "%1 <b>%2</b>"
 msgstr ""
 
-#: ../EventDetails.qml:43 ../NewEvent.qml:435
+#: ../EventDetails.qml:43 ../NewEvent.qml:436
 msgid "Event Details"
 msgstr ""
 
@@ -189,11 +189,11 @@
 msgid "Edit"
 msgstr ""
 
-#: ../EventDetails.qml:354 ../NewEvent.qml:537
+#: ../EventDetails.qml:354 ../NewEvent.qml:538
 msgid "Guests"
 msgstr ""
 
-#: ../EventDetails.qml:397 ../EventReminder.qml:35 ../NewEvent.qml:634
+#: ../EventDetails.qml:397 ../EventReminder.qml:35 ../NewEvent.qml:635
 msgid "Reminder"
 msgstr ""
 
@@ -216,7 +216,7 @@
 #. TRANSLATORS: this refers to how often a recurrent event repeats
 #. and it is shown as the header of the option selector to choose
 #. its repetition
-#: ../EventRepetition.qml:242 ../NewEvent.qml:618
+#: ../EventRepetition.qml:242 ../NewEvent.qml:619
 msgid "Repeats"
 msgstr ""
 
@@ -267,43 +267,43 @@
 msgid "End time can't be before start time"
 msgstr ""
 
-#: ../NewEvent.qml:334
+#: ../NewEvent.qml:335
 msgid "Error"
 msgstr ""
 
-#: ../NewEvent.qml:336
+#: ../NewEvent.qml:337
 msgid "OK"
 msgstr ""
 
-#: ../NewEvent.qml:389
+#: ../NewEvent.qml:390
 msgid "From"
 msgstr ""
 
-#: ../NewEvent.qml:402
+#: ../NewEvent.qml:403
 msgid "To"
 msgstr ""
 
-#: ../NewEvent.qml:419
+#: ../NewEvent.qml:420
 msgid "All day event"
 msgstr ""
 
-#: ../NewEvent.qml:448
+#: ../NewEvent.qml:449
 msgid "Event Name"
 msgstr ""
 
-#: ../NewEvent.qml:466
+#: ../NewEvent.qml:467
 msgid "Description"
 msgstr ""
 
-#: ../NewEvent.qml:484
+#: ../NewEvent.qml:485
 msgid "Location"
 msgstr ""
 
-#: ../NewEvent.qml:499 com.ubuntu.calendar_calendar.desktop.in.in.h:1
+#: ../NewEvent.qml:500 com.ubuntu.calendar_calendar.desktop.in.in.h:1
 msgid "Calendar"
 msgstr ""
 
-#: ../NewEvent.qml:541
+#: ../NewEvent.qml:542
 msgid "Add Guest"
 msgstr ""
 
@@ -404,7 +404,7 @@
 msgid "All Day"
 msgstr ""
 
-#: ../YearView.qml:54
+#: ../YearView.qml:60
 #, qt-format
 msgid "Year %1"
 msgstr ""
@@ -416,23 +416,23 @@
 "about them"
 msgstr ""
 
-#: ../calendar.qml:347
+#: ../calendar.qml:447
 msgid "Year"
 msgstr ""
 
-#: ../calendar.qml:381
+#: ../calendar.qml:454
 msgid "Month"
 msgstr ""
 
-#: ../calendar.qml:409
+#: ../calendar.qml:461
 msgid "Week"
 msgstr ""
 
-#: ../calendar.qml:442
+#: ../calendar.qml:468
 msgid "Day"
 msgstr ""
 
-#: ../calendar.qml:474
+#: ../calendar.qml:475
 msgid "Agenda"
 msgstr ""
 


Follow ups