← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~renatofilho/ubuntu-calendar-app/optimize into lp:ubuntu-calendar-app

 

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 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 'EventBubble.qml'
--- EventBubble.qml	2015-01-22 19:34:59 +0000
+++ EventBubble.qml	2015-03-27 14:12:22 +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 ? flickable.y : 0
+        drag.maximumY: flickable ? flickable.contentHeight - infoBubble.height : 0
         onReleased: parent.Drag.drop()
         onClicked: {
             if( isLiveEditing ) {

=== modified file 'MonthComponent.qml'
--- MonthComponent.qml	2015-03-05 21:59:16 +0000
+++ MonthComponent.qml	2015-03-27 14:12:22 +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
 
@@ -42,40 +43,43 @@
     signal monthSelected(var date);
     signal dateSelected(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*/)});
+    Timer {
+        id: modelIsDirty
+
+        interval: 500
+        repeat: false
+        onTriggered: {
+            if (showEvents) {
+                mainModel.startPeriod = intern.monthStart.midnight();
+                mainModel.endPeriod = intern.monthStart.addDays((/*monthGrid.rows * cols */ 42 )-1).endOfDay()
+                mainModel.filter = eventModel.filter
+            } else {
+                mainModel.filter = invalidFilter
             }
         }
     }
 
+    onCurrentMonthChanged: {
+        modelIsDirty.start()
+    }
+
+    InvalidFilter {
+        id: invalidFilter
+    }
+
+    EventListModel {
+        id: mainModel
+
+        filter: invalidFilter
+        onModelChanged: {
+            // do you really need binding it?? Is this really necessary
+            // I do not see use for that
+            intern.eventStatus = mainModel.containsItems(mainModel.startPeriod,
+                                                         mainModel.endPeriod,
+                                                         86400/*24*60*60*/);
+        }
+    }
+
     QtObject{
         id: intern
 
@@ -219,6 +223,8 @@
             width: parent.dayWidth
             height: parent.dayHeight
             fontSize: intern.dateFontSize
+
+            // is this used outside this file ??
             showEvent : showEvents
                         && intern.eventStatus !== undefined
                         && intern.eventStatus[index] !== undefined

=== modified file 'MonthComponentDateDelegate.qml'
--- MonthComponentDateDelegate.qml	2014-11-29 09:40:53 +0000
+++ MonthComponentDateDelegate.qml	2015-03-27 14:12:22 +0000
@@ -10,13 +10,13 @@
     property bool showEvent;
     property alias fontSize: dateLabel.font.pixelSize
 
-    Loader {
-        sourceComponent: isToday && isCurrentMonth ? highLightComp : undefined
-        onSourceComponentChanged: {
-            width = Qt.binding( function() { return ( dateRootItem.height / 1.5 ); });
-            height = Qt.binding ( function() { return width} );
-            anchors.centerIn = Qt.binding( function() { return dateLabel});
-        }
+    UbuntuShape{
+        color: "#DD4814"
+
+        width: dateRootItem.height / 1.5
+        height: width
+        anchors.centerIn: dateLabel
+        visible: isToday && isCurrentMonth
     }
 
     Label {
@@ -37,29 +37,15 @@
         }
     }
 
-    Loader{
+    Rectangle{
         width: units.gu(1)
         height: width
         anchors.horizontalCenter: parent.horizontalCenter
         anchors.top: dateLabel.bottom
         anchors.topMargin: dateRootItem.height/4
-        sourceComponent: showEvent ? eventIndicatorComp : undefined
-    }
-
-    Component{
-        id: eventIndicatorComp
-        Rectangle {
-            anchors.fill: parent
-            radius: height/2
-            color:"#5E2750"
-        }
-    }
-
-    Component{
-        id: highLightComp
-        UbuntuShape{
-            color: "#DD4814"
-        }
+        radius: height/2
+        color:"#5E2750"
+        visible: showEvent
     }
 
     MouseArea {


References