Renato Araujo Oliveira Filho has proposed merging lp:~renatofilho/ubuntu-calendar-app/optimize into lp:ubuntu-calendar-app.
Commit message: Optimize MonthComponent Requested reviews: Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot): continuous-integration Ubuntu Calendar Developers (ubuntu-calendar-dev) For more details, see: https://code.launchpad.net/~renatofilho/ubuntu-calendar-app/optimize/+merge/254398 -- Your team Ubuntu Calendar Developers is requested to review the proposed merge of lp:~renatofilho/ubuntu-calendar-app/optimize into lp:ubuntu-calendar-app.
=== modified file 'MonthComponent.qml' --- MonthComponent.qml 2015-11-23 07:15:20 +0000 +++ MonthComponent.qml 2016-01-12 18:02:54 +0000 @@ -17,6 +17,7 @@ */ import QtQuick 2.3 import Ubuntu.Components 1.1 +import QtOrganizer 5.0 import "dateExt.js" as DateExt import "colorUtils.js" as Color @@ -45,37 +46,51 @@ signal dateSelected(var date); signal dateHighlighted(var date); - //creatng timer only if we need to show events in month - Loader { - id: timerLoader - sourceComponent: showEvents ? timerComp : undefined - } - - // Timer to delay creation of Model, There seems some problem fetching events if we create Model immediatly - Component { - id: timerComp - Timer{ - interval: 200; running: true; repeat: false - onTriggered: { - modelLoader.sourceComponent = modelComponent - } - } - } - - Loader{ - id: modelLoader - } - - Component{ - id: modelComponent - EventListModel { - id: mainModel - startPeriod: intern.monthStart.midnight(); - endPeriod: intern.monthStart.addDays((/*monthGrid.rows * cols */ 42 )-1).endOfDay() - filter: eventModel.filter - onModelChanged: { - intern.eventStatus = Qt.binding(function() { return mainModel.containsItems(startPeriod, endPeriod, 86400/*24*60*60*/)}); - } + // optimize painter + layer.enabled: true + + Timer { + id: modelIsDirty + + interval: 500 + repeat: false + onTriggered: if(showEvents) mainModel.update() + } + + onCurrentMonthChanged: { + intern.selectedIndex = -1; + modelIsDirty.start() + } + + onSelectedDayChanged: { + if( isCurrentItem ) { + intern.selectedIndex = intern.findSelectedDayIndex(); + } + } + + + InvalidFilter { + id: invalidFilter + } + + EventListModel { + id: mainModel + + autoUpdate: false + startPeriod: intern.monthStart.midnight(); + endPeriod: intern.monthStart.addDays((/*monthGrid.rows * cols */ 42 )-1).endOfDay() + filter: showEvents ? eventModel.filter : invalidFilter + fetchHint: FetchHint { + detailTypesHint: [ Detail.EventTime, + Detail.JournalTime, + Detail.TodoTime + ] + } + + onModelChanged: { + intern.eventStatus = mainModel.containsItems(mainModel.startPeriod, + mainModel.endPeriod, + 86400/*24*60*60*/); } } @@ -132,16 +147,6 @@ } } - onSelectedDayChanged: { - if( isCurrentItem ) { - intern.selectedIndex = intern.findSelectedDayIndex(); - } - } - - onCurrentMonthChanged: { - intern.selectedIndex = -1; - } - Column{ id: column === modified file 'MonthComponentDateDelegate.qml' --- MonthComponentDateDelegate.qml 2015-09-05 05:30:23 +0000 +++ MonthComponentDateDelegate.qml 2016-01-12 18:02:54 +0000 @@ -9,20 +9,21 @@ property bool isToday; property bool showEvent; property alias fontSize: dateLabel.font.pixelSize - property bool isSelected: false - Loader { - sourceComponent: (isToday && isCurrentMonth) || isSelected ? highLightComp : undefined + UbuntuShape{ + visible: (isToday && isCurrentMonth) || isSelected + color: isToday && !isSelected ? "#DD4814" : "gray" - onSourceComponentChanged: { - width = Qt.binding( function() { - var width = dateRootItem.height > dateRootItem.width ? dateRootItem.width :dateRootItem.height - return ( width / 1.3 ); - }); - height = Qt.binding ( function() { return width} ); - anchors.centerIn = Qt.binding( function() { return dateLabel}); + Rectangle{ + anchors.fill: parent + anchors.margins: units.gu(0.5) + color: isToday ? "#DD4814" : "darkgray" } + + width: Math.min(parent.height, parent.width) / 1.3 + height: width + anchors.centerIn: dateLabel } Label { @@ -47,46 +48,19 @@ } } - Loader{ - sourceComponent: showEvent ? eventIndicatorComp : undefined - onSourceComponentChanged: { - width = Qt.binding( function() { return units.gu(0.8)}) - height = Qt.binding( function() { return width }) - anchors.horizontalCenter = Qt.binding( function() { return parent.horizontalCenter }) - anchors.top = Qt.binding( function() { return parent.verticalCenter }) - anchors.topMargin = Qt.binding( function() { - var w = (dateRootItem.height > dateRootItem.width ? dateRootItem.width :dateRootItem.height)/1.3 - return (w/2) + units.gu(0.1) - }); - } - } - - Component{ - id: eventIndicatorComp - Rectangle { - anchors.fill: parent - radius: height/2 - color: "black" - } - } - - Component{ - id: highLightComp - UbuntuShape{ - color: { - if( isToday && !isSelected ) { - "#DD4814" - } else { - "gray" - } - } - - Rectangle{ - anchors.fill: parent - anchors.margins: units.gu(0.5) - color: isToday ? "#DD4814" : "darkgray" - } - } + Rectangle { + id: eventIndicator + + width: units.gu(0.8) + height: width + anchors { + horizontalCenter: parent.horizontalCenter + top: parent.verticalCenter + topMargin: ((Math.min(parent.height, dateRootItem.width) / 1.3) / 2) + units.gu(0.1) + } + radius: height/2 + color:"black" + visible: showEvent } MouseArea { === modified file 'YearView.qml' --- YearView.qml 2015-11-23 07:15:20 +0000 +++ YearView.qml 2016-01-12 18:02:54 +0000 @@ -45,6 +45,8 @@ } } + title: i18n.tr("Year %1").arg(currentYear) + head { actions: [ calendarTodayAction, @@ -54,14 +56,10 @@ commonHeaderActions.syncCalendarAction, commonHeaderActions.settingsAction ] - contents: Label { - id:year - objectName:"yearLabel" - fontSize: "x-large" - text: i18n.tr("Year %1").arg(currentYear) - } } + flickable: null + PathViewBase { id: yearPathView objectName: "yearPathView" @@ -77,26 +75,20 @@ } delegate: Loader { - width: parent.width - height: parent.height - anchors.top: parent.top - - asynchronous: index !== yearPathView.currentIndex - sourceComponent: delegateComponent - - Component{ - id: delegateComponent - - YearViewDelegate{ - focus: index == yearPathView.currentIndex - - scrollMonth: 0; - isCurrentItem: index == yearPathView.currentIndex - year: (currentYear + yearPathView.indexType(index)) - - anchors.fill: parent - } - } - } + width: parent.width + height: parent.height + anchors.top: parent.top + + asynchronous: index !== yearPathView.currentIndex + sourceComponent: YearViewDelegate{ + focus: index == yearPathView.currentIndex + + scrollMonth: 0; + isCurrentItem: index == yearPathView.currentIndex + year: (yearViewPage.currentYear + yearPathView.indexType(index)) + + anchors.fill: parent + } + } } } === modified file 'YearViewDelegate.qml' --- YearViewDelegate.qml 2015-11-23 07:15:20 +0000 +++ YearViewDelegate.qml 2016-01-12 18:02:54 +0000 @@ -3,17 +3,21 @@ GridView{ id: yearView - clip: true property int scrollMonth; property bool isCurrentItem; property int year; - + readonly property var currentDate: new Date() + readonly property int currentYear: currentDate.getFullYear() + readonly property int currentMonth: currentDate.getMonth() readonly property int minCellWidth: units.gu(30) + cellWidth: Math.floor(Math.min.apply(Math, [3, 4].map(function(n) { return ((width / n >= minCellWidth) ? width / n : width / 2) }))) cellHeight: cellWidth * 1.4 + clip: true + cacheBuffer: 6 * cellHeight model: 12 /* months in a year */ @@ -32,9 +36,8 @@ function refresh() { scrollMonth = 0; - var today = new Date(); - if(year == today.getFullYear()) { - scrollMonth = today.getMonth(); + if(year == currentYear) { + scrollMonth = currentMonth } yearView.positionViewAtIndex(scrollMonth, GridView.Beginning); } @@ -59,39 +62,37 @@ } } - delegate: Loader { + delegate: Item { width: yearView.cellWidth height: yearView.cellHeight - sourceComponent: delegateComponent - asynchronous: !yearView.focus - - Component { - id: delegateComponent - - Item { - anchors.fill: parent - anchors.margins: units.gu(0.5) - - MonthComponent { - id: monthComponent - objectName: "monthComponent" + index - showEvents: false - currentMonth: new Date(yearView.year, index, 1, 0, 0, 0, 0) - displayWeekNumber: mainView.displayWeekNumber; - isCurrentItem: yearView.focus - - isYearView: true - anchors.fill: parent - - dayLabelFontSize:"x-small" - dateLabelFontSize: "medium" - monthLabelFontSize: "medium" - yearLabelFontSize: "medium" - - onMonthSelected: { - yearViewPage.monthSelected(date); - } + UbuntuShape { + radius: "medium" + anchors { + fill: parent + margins: units.gu(0.5) + } + + MonthComponent { + id: monthComponent + objectName: "monthComponent" + index + + anchors { + margins: units.gu(0.5) + fill: parent + } + + showEvents: false + currentMonth: new Date(yearView.year, index, 1, 0, 0, 0, 0) + isCurrentItem: yearView.focus + isYearView: true + dayLabelFontSize:"x-small" + dateLabelFontSize: "medium" + monthLabelFontSize: "medium" + yearLabelFontSize: "medium" + + onMonthSelected: { + yearViewPage.monthSelected(date); } } } === modified file 'po/com.ubuntu.calendar.pot' --- po/com.ubuntu.calendar.pot 2015-11-23 07:15:20 +0000 +++ po/com.ubuntu.calendar.pot 2016-01-12 18:02:54 +0000 @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-11-23 15:14+0800\n" +"POT-Creation-Date: 2016-01-12 12:03-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <l...@li.org>\n" @@ -263,7 +263,7 @@ msgid "After Date" msgstr "" -#: ../MonthComponent.qml:260 +#: ../MonthComponent.qml:263 msgid "Wk" msgstr "" @@ -416,7 +416,7 @@ msgid "All Day" msgstr "" -#: ../YearView.qml:61 +#: ../YearView.qml:48 #, qt-format msgid "Year %1" msgstr ""
-- Mailing list: https://launchpad.net/~ubuntu-touch-coreapps-reviewers Post to : ubuntu-touch-coreapps-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~ubuntu-touch-coreapps-reviewers More help : https://help.launchpad.net/ListHelp