← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

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

 

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

Commit message:
Remove recurrence rule for non-repeating event.

Requested reviews:
  Alan Pope  (popey)
Related bugs:
  Bug #1440583 in Ubuntu Calendar App: "calendar-app is generating invalid RECUR values in RRULE property"
  https://bugs.launchpad.net/ubuntu-calendar-app/+bug/1440583

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

Remove recurrence rule for non-repeating event.
-- 
Your team Ubuntu Calendar Developers is subscribed to branch lp:ubuntu-calendar-app.
=== modified file 'EventDetails.qml'
--- EventDetails.qml	2015-06-27 17:52:44 +0000
+++ EventDetails.qml	2015-07-12 03:29:02 +0000
@@ -72,6 +72,9 @@
             if(event.recurrence.recurrenceRules[0] !== undefined){
                 var rule =  event.recurrence.recurrenceRules[0];
                 repeatLabel.text = eventUtils.getRecurrenceString(rule)
+            } else {
+                //For event occurs once, event.recurrence.recurrenceRules == []
+                repeatLabel.text = Defines.recurrenceLabel[0];
             }
         }
     }

=== modified file 'EventRepetition.qml'
--- EventRepetition.qml	2015-04-05 09:46:59 +0000
+++ EventRepetition.qml	2015-07-12 03:29:02 +0000
@@ -29,8 +29,7 @@
     id: repetition
 
     property var weekDays : [];
-    property var rule
-    property var date
+    property var eventRoot;
     property var isEdit
 
     visible: false
@@ -51,6 +50,7 @@
     Component.onCompleted: {
         //Fill Date & limitcount if any
         var index = 0;
+        var rule = eventRoot.rule;
         if(rule !== null && rule !== undefined){
             index =  rule.frequency ;
             if(index > 0 )
@@ -87,7 +87,6 @@
                     index = Recurrence.Yearly
                     break;
                 }
-
             }
         }
         recurrenceOption.selectedIndex = index;
@@ -98,7 +97,13 @@
         iconName: "back"
         onTriggered: {
             var recurrenceRule = Defines.recurrenceValue[ recurrenceOption.selectedIndex ];
+
             if (recurrenceRule !== RecurrenceRule.Invalid) {
+                if (eventRoot.rule === null || eventRoot.rule === undefined ){
+                    eventRoot.rule = Qt.createQmlObject("import QtOrganizer 5.0; RecurrenceRule {}", eventRoot.event.recurrence,"EventRepetition.qml");
+                }
+
+                var rule = eventRoot.rule;
                 rule.frequency = recurrenceRule;
                 switch(recurrenceOption.selectedIndex){
                 case 1: //daily
@@ -109,11 +114,11 @@
                     rule.daysOfWeek = eventUtils.getDaysOfWeek(recurrenceOption.selectedIndex, weekDays );
                     break;
                 case 6: //monthly
-                    rule.daysOfMonth = [date.getDate()];
+                    rule.daysOfMonth = [eventRoot.date.getDate()];
                     break;
                 case 7: //yearly
-                    rule.monthsOfYear = [date.getMonth()];
-                    rule.daysOfMonth = [date.getDate()];
+                    rule.monthsOfYear = [eventRoot.date.getMonth()];
+                    rule.daysOfMonth = [eventRoot.date.getDate()];
                     break;
                 case 0: //once
                 default:
@@ -134,7 +139,7 @@
                 }
             }
             else {
-                rule.frequency = 0
+                eventRoot.rule = null;
             }
             pop()
         }
@@ -202,7 +207,7 @@
                                 (checked) ? weekDays.push(index) : weekDays.splice(weekDays.indexOf(index),1);
                         }
                         checked:{
-                            (weekDays.length === 0 && index === date.getDay() && isEdit === false) ? true : false;
+                            (weekDays.length === 0 && index === eventRoot.date.getDay() && isEdit === false) ? true : false;
                         }
 
                     }

=== modified file 'MonthComponent.qml'
--- MonthComponent.qml	2015-06-11 14:07:51 +0000
+++ MonthComponent.qml	2015-07-12 03:29:02 +0000
@@ -30,6 +30,7 @@
 
     property var currentMonth;
     property var isYearView;
+    property bool showWeekNumber:true;
 
     property string dayLabelFontSize: "medium"
     property string dateLabelFontSize: "large"
@@ -123,7 +124,10 @@
         id: column
 
         anchors {
-            fill: parent
+            left: weekNumLoader.right;
+            right: parent.right;
+            top: parent.top;
+            bottom: parent.bottom;
             topMargin: units.gu(1.5)
             bottomMargin: units.gu(1)
         }
@@ -191,6 +195,60 @@
         }
     }
 
+    Loader {
+        id: weekNumLoader;
+        anchors.left: parent.left;
+        width: showWeekNumber ? parent.width / 8:0;
+        height: parent.height;
+        visible: showWeekNumber;
+        sourceComponent: showWeekNumber ? weekNumComp : undefined;
+    }
+
+    Component {
+        id: weekNumComp
+
+        Column {
+            id: weekNumColumn;
+
+            anchors {
+                fill: parent
+                topMargin: monthGrid.y + units.gu(1.5)
+                bottomMargin: units.gu(1)
+            }
+
+            Repeater {
+                id: weekNumrepeater;
+                model: 6;
+
+                Label{
+                    id: weekNum
+                    objectName: "weekNum" + index
+                    width: height;
+                    height: weekNumColumn.height / 6;
+                    text: isYearView ? i18n.tr("W") + intern.monthStart.addDays(index * 7).weekNumber(Qt.locale().firstDayOfWeek) :
+                                       i18n.tr("Wk") + intern.monthStart.addDays(index * 7).weekNumber(Qt.locale().firstDayOfWeek)
+                    horizontalAlignment: Text.AlignLeft;
+                    verticalAlignment: Text.AlignVCenter;
+                    font.pixelSize: intern.dayFontSize - 3;
+                    font.bold: true
+                    color: "black"
+
+                    MouseArea {
+                        anchors.fill: parent
+                        onClicked: {
+                            var selectedDate = new Date(intern.monthStart.addDays(index * 7))
+                            if( isYearView ) {
+                                root.monthSelected(selectedDate);
+                            } else {
+                                root.dateSelected(selectedDate);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
     Component{
         id: defaultDateLabelComponent
         MonthComponentDateDelegate{

=== modified file 'NewEvent.qml'
--- NewEvent.qml	2015-06-27 17:52:44 +0000
+++ NewEvent.qml	2015-07-12 03:29:02 +0000
@@ -135,18 +135,17 @@
     function addEvent() {
         event = Qt.createQmlObject("import QtOrganizer 5.0; Event { }", Qt.application,"NewEvent.qml");
         //Create fresh Recurrence Object.
-        rule = Qt.createQmlObject("import QtOrganizer 5.0; RecurrenceRule {}", event.recurrence,"EventRepetition.qml");
         selectCalendar(model.defaultCollection().collectionId);
     }
 
     //Editing Event
     function editEvent(e) {
         //If there is a ReccruenceRule use that , else create fresh Recurrence Object.
-        if(e.itemType === Type.Event){
-            rule = (e.recurrence.recurrenceRules[0] === undefined || e.recurrence.recurrenceRules[0] === null) ?
-                        Qt.createQmlObject("import QtOrganizer 5.0; RecurrenceRule {}", event.recurrence,"EventRepetition.qml")
-                      : e.recurrence.recurrenceRules[0];
+        if(e.itemType === Type.Event && e.recurrence.recurrenceRules[0] !== undefined
+                && e.recurrence.recurrenceRules[0] !== null){
+            rule =  e.recurrence.recurrenceRules[0];
         }
+
         startDate =new Date(e.startDateTime);
         endDate = new Date(e.endDateTime);
 
@@ -225,6 +224,8 @@
             //Set the Rule object to an event
             if(rule !== null && rule !== undefined) {
                 event.recurrence.recurrenceRules = [rule]
+            } else {
+                event.recurrence.recurrenceRules = [];
             }
 
             //remove old reminder value
@@ -611,8 +612,8 @@
                 progression: true
                 visible: event.itemType === Type.Event
                 text: i18n.tr("Repeats")
-                subText: event.itemType === Type.Event ? eventUtils.getRecurrenceString(rule) : ""
-                onClicked: pageStack.push(Qt.resolvedUrl("EventRepetition.qml"),{"rule": rule,"date":date,"isEdit":isEdit});
+                subText: event.itemType === Type.Event ? rule === null ? Defines.recurrenceLabel[0] : eventUtils.getRecurrenceString(rule) : ""
+                onClicked: pageStack.push(Qt.resolvedUrl("EventRepetition.qml"),{"eventRoot": root,"isEdit":isEdit});
             }
 
             ListItem.ThinDivider {

=== modified file 'po/com.ubuntu.calendar.pot'
--- po/com.ubuntu.calendar.pot	2015-06-23 15:59:08 +0000
+++ po/com.ubuntu.calendar.pot	2015-07-12 03:29:02 +0000
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-06-23 23:57+0800\n"
+"POT-Creation-Date: 2015-07-11 19:28+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"
@@ -132,11 +132,11 @@
 msgid "Delete this"
 msgstr ""
 
-#: ../DeleteConfirmationDialog.qml:51 ../EventDetails.qml:188
+#: ../DeleteConfirmationDialog.qml:51 ../NewEvent.qml:68
 msgid "Delete"
 msgstr ""
 
-#: ../EditEventConfirmationDialog.qml:29 ../NewEvent.qml:304
+#: ../EditEventConfirmationDialog.qml:29 ../NewEvent.qml:320
 msgid "Edit Event"
 msgstr ""
 
@@ -154,7 +154,7 @@
 msgid "Edit this"
 msgstr ""
 
-#: ../EventActions.qml:50 ../NewEvent.qml:304
+#: ../EventActions.qml:50 ../NewEvent.qml:320
 msgid "New Event"
 msgstr ""
 
@@ -165,7 +165,7 @@
 msgid "%1 <b>%2</b>"
 msgstr ""
 
-#: ../EventDetails.qml:42 ../NewEvent.qml:415
+#: ../EventDetails.qml:42 ../NewEvent.qml:431
 msgid "Event Details"
 msgstr ""
 
@@ -175,25 +175,25 @@
 msgid "%1 Calendar"
 msgstr ""
 
-#: ../EventDetails.qml:118
+#: ../EventDetails.qml:121
 #, qt-format
 msgid "%1 - %2 (All Day)"
 msgstr ""
 
-#: ../EventDetails.qml:122
+#: ../EventDetails.qml:125
 #, qt-format
 msgid "%1 (All Day)"
 msgstr ""
 
-#: ../EventDetails.qml:201
+#: ../EventDetails.qml:195
 msgid "Edit"
 msgstr ""
 
-#: ../EventDetails.qml:352 ../NewEvent.qml:517
+#: ../EventDetails.qml:346 ../NewEvent.qml:533
 msgid "Guests"
 msgstr ""
 
-#: ../EventDetails.qml:395 ../EventReminder.qml:35 ../NewEvent.qml:614
+#: ../EventDetails.qml:389 ../EventReminder.qml:35 ../NewEvent.qml:630
 msgid "Reminder"
 msgstr ""
 
@@ -201,26 +201,26 @@
 #. and it is shown as the header of the page to choose repetition
 #. and as the header of the list item that shows the repetition
 #. summary in the page that displays the event details
-#: ../EventRepetition.qml:41 ../EventRepetition.qml:150
+#: ../EventRepetition.qml:40 ../EventRepetition.qml:155
 msgid "Repeat"
 msgstr ""
 
-#: ../EventRepetition.qml:169
+#: ../EventRepetition.qml:174
 msgid "Repeats On:"
 msgstr ""
 
-#: ../EventRepetition.qml:214
+#: ../EventRepetition.qml:219
 msgid "Recurring event ends"
 msgstr ""
 
 #. 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:237 ../NewEvent.qml:598
+#: ../EventRepetition.qml:242 ../NewEvent.qml:614
 msgid "Repeats"
 msgstr ""
 
-#: ../EventRepetition.qml:262
+#: ../EventRepetition.qml:267
 msgid "Date"
 msgstr ""
 
@@ -259,51 +259,59 @@
 msgid "After Date"
 msgstr ""
 
-#: ../NewEvent.qml:68
+#: ../MonthComponent.qml:228
+msgid "W"
+msgstr ""
+
+#: ../MonthComponent.qml:229
+msgid "Wk"
+msgstr ""
+
+#: ../NewEvent.qml:84
 msgid "Save"
 msgstr ""
 
-#: ../NewEvent.qml:177
+#: ../NewEvent.qml:191
 msgid "End time can't be before start time"
 msgstr ""
 
-#: ../NewEvent.qml:314
+#: ../NewEvent.qml:330
 msgid "Error"
 msgstr ""
 
-#: ../NewEvent.qml:316
+#: ../NewEvent.qml:332
 msgid "OK"
 msgstr ""
 
-#: ../NewEvent.qml:369
+#: ../NewEvent.qml:385
 msgid "From"
 msgstr ""
 
-#: ../NewEvent.qml:382
+#: ../NewEvent.qml:398
 msgid "To"
 msgstr ""
 
-#: ../NewEvent.qml:399
+#: ../NewEvent.qml:415
 msgid "All day event"
 msgstr ""
 
-#: ../NewEvent.qml:428
+#: ../NewEvent.qml:444
 msgid "Event Name"
 msgstr ""
 
-#: ../NewEvent.qml:446
+#: ../NewEvent.qml:462
 msgid "Description"
 msgstr ""
 
-#: ../NewEvent.qml:464
+#: ../NewEvent.qml:480
 msgid "Location"
 msgstr ""
 
-#: ../NewEvent.qml:479 com.ubuntu.calendar_calendar.desktop.in.in.h:1
+#: ../NewEvent.qml:495 com.ubuntu.calendar_calendar.desktop.in.in.h:1
 msgid "Calendar"
 msgstr ""
 
-#: ../NewEvent.qml:521
+#: ../NewEvent.qml:537
 msgid "Add Guest"
 msgstr ""
 


Follow ups