← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~pkunal-parmar/ubuntu-calendar-app/DefCalendar into lp:ubuntu-calendar-app

 

Kunal Parmar has proposed merging lp:~pkunal-parmar/ubuntu-calendar-app/DefCalendar into lp:ubuntu-calendar-app.

Commit message:
resolves Bug #1369543

Requested reviews:
  Ubuntu Calendar Developers (ubuntu-calendar-dev)
Related bugs:
  Bug #1369543 in Ubuntu Calendar App: "[Calendar] New event defaults to "Personal" calendar even if it is not used"
  https://bugs.launchpad.net/ubuntu-calendar-app/+bug/1369543

For more details, see:
https://code.launchpad.net/~pkunal-parmar/ubuntu-calendar-app/DefCalendar/+merge/264990

resolves Bug #1369543
-- 
Your team Ubuntu Calendar Developers is requested to review the proposed merge of lp:~pkunal-parmar/ubuntu-calendar-app/DefCalendar into lp:ubuntu-calendar-app.
=== modified file 'EventListModel.qml'
--- EventListModel.qml	2015-05-14 13:03:02 +0000
+++ EventListModel.qml	2015-07-16 13:51:18 +0000
@@ -77,6 +77,31 @@
         return cals;
 	}
 
+    function getDefaultCollection() {
+        var userDefCalFound = false;
+        var cals = getCollections();
+         for(var i = 0 ; i < cals.length ; ++i) {
+            var cal = cals[i]
+            var val = cal.extendedMetaData("X-CAL-DEFAULT-CALENDAR")
+            if( val ) {
+                return cal;
+            }
+        }
+
+        return defaultCollection();
+    }
+
+    function setDefaultCollection( collectionId ) {
+        var cals = getCollections();
+         for(var i = 0 ; i < cals.length ; ++i) {
+             var cal = cals[i]
+             cal.setExtendedMetaData("X-CAL-DEFAULT-CALENDAR", false);
+             if( cal.collectionId === collectionId) {
+                cal.setExtendedMetaData("X-CAL-DEFAULT-CALENDAR", true);
+             }
+        }
+    }
+
     onStartPeriodChanged: {
         isLoading = true
     }

=== modified file 'NewEvent.qml'
--- NewEvent.qml	2015-06-27 17:52:44 +0000
+++ NewEvent.qml	2015-07-16 13:51:18 +0000
@@ -136,7 +136,7 @@
         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);
+        selectCalendar(model.getDefaultCollection().collectionId);
     }
 
     //Editing Event
@@ -185,6 +185,7 @@
 
         selectCalendar(e.collectionId);
     }
+
     //Save the new or Existing event
     function saveToQtPim() {
         internal.clearFocus()
@@ -242,6 +243,7 @@
                 event.setDetail(audibleReminder);
             }
             event.collectionId = calendarsOption.model[calendarsOption.selectedIndex].collectionId;
+            model.setDefaultCollection(event.collectionId);
 
             var comment = event.detail(Detail.Comment);
             if(comment && comment.comment === "X-CAL-DEFAULT-EVENT") {


Follow ups