Bug 472300 - Consolidation of the Multiday-view and month-view;r=philipp
authorBerend Cornelius [:berend] <berend.cornelius@sun.com>
Wed, 07 Jan 2009 19:21:48 +0100
changeset 1573 6e86173f86911a8745e3f1856da32435b2097cc4
parent 1572 9f801d1c8b30078bd43636aea1a317f9a79e6a72
child 1574 9c788dc9e472056faeb2a0de6ffee80c69097e4f
push idunknown
push userunknown
push dateunknown
reviewersphilipp
bugs472300
Bug 472300 - Consolidation of the Multiday-view and month-view;r=philipp
calendar/base/content/calendar-base-view.xml
calendar/base/content/calendar-month-view.xml
calendar/base/content/calendar-multiday-view.xml
--- a/calendar/base/content/calendar-base-view.xml
+++ b/calendar/base/content/calendar-base-view.xml
@@ -56,39 +56,252 @@
       <field name="mDisplayDaysOff">true</field>
       <field name="mDaysOffArray">[0,6]</field>
       <field name="mTimezone">null</field>
       <field name="mFlashingEvents">new Object()</field>
       <field name="mSelectedItems">[]</field>
       <field name="mBatchCount">0</field>
       <field name="mLongWeekdayTotalPixels">-1</field>
       <field name="mResizeHandler">null</field>
+      <field name="mOperationListener"><![CDATA[
+      ({
+          calView: this,
 
+          onOperationComplete:
+          function onOperationComplete(aCalendar, aStatus, aOperationType,
+                                       aId, aDetail) {
+              // Fire event
+              this.calView.fireEvent('viewloaded', aOperationType);
+
+              // signal that the current operation finished.
+              this.calView.mRefreshPending = null;
+
+              // immediately start the next job on the queue.
+              this.calView.popRefreshQueue();
+          },
+
+          onGetResult:
+          function onGetResult(aCalendar, aStatus, aItemType, aDetail,
+                               aCount, aItems) {
+              if (!Components.isSuccessCode(aStatus)) {
+                  return;
+              }
+              let items = aItems.filter(function(x) !isToDo(x) ||
+                                (x.entryDate && x.dueDate));
+
+              for each (let item in items) {
+                  this.calView.doAddItem(item);
+              }
+          }
+      })
+      ]]></field>
+
+      <field name="mObserver"><![CDATA[
+        // the calIObserver, calICompositeObserver, and calIAlarmServiceObserver
+        ({
+            QueryInterface: function QueryInterface(aIID) {
+                return cal.doQueryInterface(this, null, aIID,
+                                    [Components.interfaces.calIObserver,
+                                     Components.interfaces.calIAlarmServiceObserver,
+                                     Components.interfaces.calICompositeObserver,
+                                     Components.interfaces.nsISupports]);
+            },
+
+            calView: this,
+
+            onStartBatch: function onStartBatch() {
+                this.calView.mBatchCount++;
+            },
+            onEndBatch: function onEndBatch() {
+                this.calView.mBatchCount--;
+                if (this.calView.mBatchCount == 0) {
+                    this.calView.refresh();
+                }
+            },
+
+            onLoad: function onLoad() {
+                this.calView.refresh();
+            },
+
+            onAddItem: function onAddItem(aItem) {
+                if (this.calView.mBatchCount) {
+                    return;
+                }
+
+                if (isToDo(aItem)) {
+                    if (!aItem.entryDate || !aItem.dueDate) {
+                        return;
+                    }
+                    if(!this.calView.mTasksInView){
+                        return;
+                    }
+                    if (aItem.isCompleted && !this.calView.mShowCompleted) {
+                        return;
+                    }
+                }
+
+                let occs = aItem.getOccurrencesBetween(this.calView.startDate,
+                                                       this.calView.queryEndDate,
+                                                       {});
+                for each (let occ in occs) {
+                    this.calView.doAddItem(occ);
+                }
+                return;
+            },
+
+            onModifyItem: function onModifyItem(aNewItem, aOldItem) {
+                if (this.calView.mBatchCount) {
+                    return;
+                }
+
+                if (isToDo(aNewItem) && isToDo(aOldItem) &&
+                    !this.calView.mTasksInView) {
+                    return;
+                }
+                let occs;
+
+                if (!isToDo(aOldItem) ||
+                    (aOldItem.entryDate && aOldItem.dueDate)) {
+                    occs = aOldItem.getOccurrencesBetween(this.calView.startDate,
+                                                          this.calView.queryEndDate,
+                                                          {});
+                    for each (let occ in occs) {
+                        this.calView.doDeleteItem(occ);
+                    }
+                }
+                if (isToDo(aNewItem)) {
+                    if (!aNewItem.entryDate || !aNewItem.dueDate || !this.calView.mTasksInView) {
+                        return;
+                    }
+                    if (aNewItem.isCompleted && !this.calView.mShowCompleted) {
+                        return;
+                    }
+                }
+
+                occs = aNewItem.getOccurrencesBetween(this.calView.startDate,
+                                                      this.calView.queryEndDate,
+                                                      {});
+                for each (let occ in occs) {
+                    this.calView.doAddItem(occ);
+                }
+            },
+
+            onDeleteItem: function onDeleteItem(aItem) {
+                if (this.calView.mBatchCount) {
+                    return;
+                }
+
+                if (isToDo(aItem)) {
+                    if (!this.calView.mTasksInView) {
+                        return;
+                    }
+                    if (!aItem.entryDate || !aItem.dueDate) {
+                        return;
+                    }
+                    if (aItem.isCompleted && !this.calView.mShowCompleted) {
+                        return;
+                    }
+                }
+
+                let occs = aItem.getOccurrencesBetween(this.calView.startDate,
+                                                       this.calView.queryEndDate,
+                                                       {});
+                for each (let occ in occs) {
+                    this.calView.doDeleteItem(occ);
+                }
+            },
+
+            onError: function onError(aCalendar, aErrNo, aMessage) { },
+
+            onPropertyChanged: function(aCalendar, aName, aValue, aOldValue) {
+                switch (aName) {
+                    case "suppressAlarms":
+                        if (!getPrefSafe("calendar.alarms.indicator.show", true) ||
+                            aCalendar.getProperty("capabilities.alarms.popup.supported") === false ) {
+                            break;
+                        }
+                        // else fall through
+                    case "readOnly":
+                    case "disabled":
+                        // XXXvv we can be smarter about how we handle this stuff
+                        this.calView.refresh();
+                        break;
+                }
+            },
+
+            onPropertyDeleting: function(aCalendar, aName) {
+                // Values are not important here yet.
+                this.onPropertyChanged(aCalendar, aName, null, null);
+            },
+
+            //
+            // calIAlarmServiceObserver stuff
+            //
+            onAlarm: function onAlarm(aAlarmItem) {
+                this.calView.flashAlarm(aAlarmItem, false);
+            },
+
+            onRemoveAlarmsByItem: function onRemoveAlarmsByItem(aItem) {
+                // Stop the flashing for the item.
+                this.calView.flashAlarm(aItem, true);
+            },
+
+            onRemoveAlarmsByCalendar: function onRemoveAlarmsByCalendar(aCalendar) {
+                // Stop the flashing for all items of this calendar
+                for each (let item in this.calView.mFlashingEvents) {
+                    if (item.calendar.id == aCalendar.id) {
+                        this.calView.flashAlarm(item, true);
+                    }
+                }
+            },
+
+            //
+            // calICompositeObserver stuff
+            // XXXvv we can be smarter about how we handle this stuff
+            //
+            onCalendarAdded: function onCalendarAdded(aCalendar) {
+                if (!aCalendar.getProperty("disabled")) {
+                    this.calView.refresh();
+                }
+            },
+
+            onCalendarRemoved: function onCalendarRemoved(aCalendar) {
+                if (!aCalendar.getProperty("disabled")) {
+                    this.calView.refresh();
+                }
+            },
+
+            onDefaultCalendarChanged:
+            function onDefaultCalendarChanged(aNewDefaultCalendar) {
+                // don't care, for now
+            }
+        })
+      ]]></field>
 
       <constructor><![CDATA[
         this.mTimezone = calendarDefaultTimezone();
         let alarmService = Components.classes['@mozilla.org/calendar/alarm-service;1']
                            .getService(Components.interfaces.calIAlarmService);
         alarmService.addObserver(this.mObserver);
         let self = this;
         this.mResizeHandler = function resizeHandler() {
          self.onResize(self); };
         this.viewBroadcaster.addEventListener(this.getAttribute("type") + "viewresized", this.mResizeHandler, true);
-
       ]]></constructor>
 
       <destructor><![CDATA[
         if (this.mCalendar) {
             this.mCalendar.removeObserver(this.mObserver);
         }
         let alarmService = Components.classes['@mozilla.org/calendar/alarm-service;1']
                            .getService(Components.interfaces.calIAlarmService);
         alarmService.removeObserver(this.mObserver);
         this.viewBroadcaster.removeEventListener(this.getAttribute("type") + "viewresized", this.mResizeHandler, true);
       ]]></destructor>
+
       <property name="viewBroadcaster" readonly="true"
                 onget="return document.getElementById('calendarviewBroadcaster')"/>
 
       <property name="labeldaybox" readonly="true"
                 onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'labeldaybox')"/>
 
       <property name="displayDaysOff"
                 onget="return this.mDisplayDaysOff;"
@@ -118,16 +331,76 @@
               this.mCalendar.removeObserver(this.mObserver);
           this.mCalendar = val;
           this.mCalendar.addObserver(this.mObserver);
           this.refresh();
           return val;
         ]]></setter>
       </property>
 
+      <method name="popRefreshQueue">
+        <body><![CDATA[
+          let pendingRefresh = this.mRefreshPending;
+          if (pendingRefresh) {
+              if (calInstanceOf(pendingRefresh, Components.interfaces.calIOperation)) {
+                  this.mRefreshPending = null;
+                  pendingRefresh.cancel(null);
+              } else {
+                  if(this.mRefreshQueue.length > 0) {
+                      this.relayout();
+                  }
+                  return;
+              }
+          }
+
+          let refreshJob = this.mRefreshQueue.pop();
+          if (!refreshJob) {
+            return;
+          }
+
+          if (!this.startDate || !this.endDate) {
+            return;
+          }
+
+          // recreate our columns
+          this.relayout();
+
+          if (!this.mCalendar) {
+              return;
+          }
+
+          // start our items query; for a disjoint date range
+          // we get all the items, and just filter out the ones we don't
+          // care about in addItem
+
+          let filter = this.mCalendar.ITEM_FILTER_CLASS_OCCURRENCES;
+          if (this.mShowCompleted) {
+              filter |= this.mCalendar.ITEM_FILTER_COMPLETED_ALL;
+          } else {
+              filter |= this.mCalendar.ITEM_FILTER_COMPLETED_NO;
+          }
+
+          if(this.mTasksInView) {
+              filter |= this.mCalendar.ITEM_FILTER_TYPE_ALL;
+          } else {
+              filter |= this.mCalendar.ITEM_FILTER_TYPE_EVENT;
+          }
+
+          this.mRefreshPending = true;
+          pendingRefresh = this.mCalendar.getItems(filter,
+                                                   0,
+                                                   this.startDate,
+                                                   this.queryEndDate,
+                                                   this.mOperationListener);
+          if (pendingRefresh && pendingRefresh.isPending) { // support for calIOperation
+              this.mRefreshPending = pendingRefresh;
+          }
+        ]]></body>
+      </method>
+
       <!-- This function guarantees that the
        labels are clipped in the instance that the overflow occurrs,
        avoiding horizontal scrollbars from showing up for a short period. -->
       <method name="adjustWeekdayLength">
         <parameter name="forceShortName"/>
         <body><![CDATA[
           let useShortNames = false;
           let labeldayboxkids = this.labeldaybox.childNodes;
@@ -224,16 +497,17 @@
               }
               this.mLongWeekdayTotalPixels = (maxDayWidth * this.labeldaybox.childNodes.length) + 10;
           }
           return this.mLongWeekdayTotalPixels;
         ]]></body>
       </method>
     </implementation>
   </binding>
+
   <binding id="calendar-day-label" extends="xul:box">
     <content flex="1" pack="center">
       <xul:label anonid="longWeekdayName" class="calendar-day-label-name" xbl:inherits="selected"/>
       <xul:label anonid="shortWeekdayName" class="calendar-day-label-name" hidden="true" xbl:inherits="selected"/>
     </content>
     <implementation>
       <field name="mWeekday">-1</field>
       <field name="longWeekdayPixels">0</field>
@@ -246,16 +520,17 @@
         <getter>return this.mWeekday;</getter>
         <setter><![CDATA[
           this.mWeekday = val % 7;
           this.longName.value = getDateFormatter().dayName(val);
           this.shortName.value = getDateFormatter().shortDayName(val);
           return this.mWeekday;
         ]]></setter>
       </property>
+
       <property name="date">
         <getter><![CDATA[
           return this.mDate;
         ]]></getter>
         <setter><![CDATA[
           this.mDate = val;
           this.shortName.setAttribute("value", getDateFormatter().shortDayName(val.weekday) + " " +
                                                getDateFormatter().formatDateWithoutYear(val));
--- a/calendar/base/content/calendar-month-view.xml
+++ b/calendar/base/content/calendar-month-view.xml
@@ -22,16 +22,17 @@
    -
    - Contributor(s):
    -   Vladimir Vukicevic <vladimir@pobox.com>
    -   Stefan Sitter <ssitter@googlemail.com>
    -   Clint Talbert <cmtalbert@myfastmail.com>
    -   Michael B├╝ttner <michael.buettner@sun.com>
    -   Philipp Kewisch <mozilla@kewis.ch>
    -   Markus Adrario <MarkusAdrario@web.de>
+   -   Berend Cornelius <berend.cornelius@sun.com>
    -
    - Alternatively, the contents of this file may be used under the terms of
    - either the GNU General Public License Version 2 or later (the "GPL"), or
    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    - in which case the provisions of the GPL or the LGPL are applicable instead
    - of those above. If you wish to allow use of your version of this file only
    - under the terms of either the GPL or the LGPL, and not to allow others to
    - use your version of this file under the terms of the MPL, indicate your
@@ -716,68 +717,16 @@
       <!-- private properties and methods -->
 
       <property name="monthgrid" readonly="true"
                 onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'monthgrid');"/>
 
       <property name="monthgridrows" readonly="true"
                 onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'monthgridrows');"/>
 
-      <method name="popRefreshQueue">
-        <body><![CDATA[
-          var pendingRefresh = this.mRefreshPending;
-          if (pendingRefresh) {
-              if (calInstanceOf(pendingRefresh, Components.interfaces.calIOperation)) {
-                  this.mRefreshPending = null;
-                  pendingRefresh.cancel(null);
-              } else {
-                  if(this.mRefreshQueue.length > 0) {
-                      this.relayout();
-                  }
-                  return;
-              }
-          }
-
-          var refreshJob = this.mRefreshQueue.pop();
-          if (!refreshJob) {
-            return;
-          }
-
-          if (!this.startDate || !this.endDate)
-            return;
-
-          this.relayout();
-
-          if (!this.mCalendar)
-            return;
-
-          var filter = this.mCalendar.ITEM_FILTER_CLASS_OCCURRENCES;
-          if (this.showCompleted) {
-            filter |= this.mCalendar.ITEM_FILTER_COMPLETED_ALL;
-          } else {
-            filter |= this.mCalendar.ITEM_FILTER_COMPLETED_NO;
-          }
-
-          if (this.mTasksInView)
-            filter |= this.mCalendar.ITEM_FILTER_TYPE_ALL; 
-          else
-            filter |= this.mCalendar.ITEM_FILTER_TYPE_EVENT;
-
-          this.mRefreshPending = true;
-          pendingRefresh = this.mCalendar.getItems(filter,
-                                                   0,
-                                                   this.startDate,
-                                                   this.queryEndDate,
-                                                   this.mOperationListener);
-          if (pendingRefresh && pendingRefresh.isPending) { // support for calIOperation
-              this.mRefreshPending = pendingRefresh;
-          }
-        ]]></body>
-      </method>
-
       <method name="relayout">
         <body><![CDATA[
           if (this.mSelectedItems.length) {
             this.mSelectedItems = [];
           }
 	  
           // Clear out the old selection, since it won't be valid after relayout
           if (this.mSelectedDayBox) {
@@ -1015,217 +964,16 @@
           // If a deleted event was selected, we need to announce that the
           // selection changed.
           if (oldLength != this.mSelectedItems.length) {
               this.fireEvent("itemselect", this.mSelectedItems);
           }
         ]]></body>
       </method>
 
-      <!-- our private observers and listeners -->
-
-      <field name="mOperationListener"><![CDATA[
-        ({
-          calView: this,
-
-          QueryInterface: function (aIID) {
-            if (!aIID.equals(Components.interfaces.calIOperationListener) &&
-                !aIID.equals(Components.interfaces.nsISupports)) {
-              throw Components.results.NS_ERROR_NO_INTERFACE;
-            }
-
-            return this;
-          },
-  
-          onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
-            // Fire viewloaded event
-            this.calView.fireEvent('viewloaded', aOperationType);
-          
-            // signal that the current operation finished.
-            this.calView.mRefreshPending = null;
-
-            // immediately start the next job on the queue.
-            this.calView.popRefreshQueue();
-          },
-          onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
-            if (!Components.isSuccessCode(aStatus))
-              return;
-  
-            for each (var item in aItems) {
-              this.calView.doAddItem(item);
-            }
-          }
-        })
-      ]]></field>
-
-      <field name="mObserver"><![CDATA[
-        // the calIObserver, calICompositeObserver, calIAlarmServiceObserver
-        ({
-          calView: this,
-
-          QueryInterface: function (aIID) {
-            if (!aIID.equals(Components.interfaces.calIObserver) &&
-                !aIID.equals(Components.interfaces.calICompositeObserver) &&
-                !aIID.equals(Components.interfaces.calIAlarmServiceObserver) &&
-                !aIID.equals(Components.interfaces.nsISupports)) {
-              throw Components.results.NS_ERROR_NO_INTERFACE;
-            }
-
-            return this;
-          },
-
-          onStartBatch: function() {
-            this.calView.mBatchCount++;
-          },
-          onEndBatch: function() {
-            this.calView.mBatchCount--;
-            if (this.calView.mBatchCount == 0) {
-              this.calView.refresh();
-            }
-          },
-          onLoad: function() {
-            this.calView.refresh();
-          },
-          onAddItem: function (aItem) {
-            if (this.calView.mBatchCount) {
-                return;
-            }
-
-            if (isToDo(aItem)) {
-              if (!this.calView.mTasksInView) {
-                return;
-              }
-              if (aItem.isCompleted && !this.calView.mShowCompleted) {
-                return;
-              }
-            }
-
-            var occs = aItem.getOccurrencesBetween(this.calView.startDate,
-                                                   this.calView.queryEndDate,
-                                                   {});
-            for each (var occ in occs)
-              this.calView.doAddItem(occ);
-          },
-          onModifyItem: function (aNewItem, aOldItem) {
-
-            if (this.calView.mBatchCount) {
-                return;
-            }
-
-            if (isToDo(aNewItem) && isToDo(aOldItem) &&
-                !this.calView.mTasksInView) {
-                return;
-            }
-
-            var occs;
-            occs = aOldItem.getOccurrencesBetween(this.calView.startDate,
-                                                  this.calView.queryEndDate,
-                                                  {});
-            for each (var occ in occs)
-              this.calView.doDeleteItem(occ);
-
-            if (isToDo(aNewItem)) {
-              if (!this.calView.mTasksInView) {
-                return;
-              }
-              if (aNewItem.isCompleted && !this.calView.mShowCompleted) {
-                return;
-              }
-            }
-            occs = aNewItem.getOccurrencesBetween(this.calView.startDate,
-                                                  this.calView.queryEndDate,
-                                                  {});
-            for each (var occ in occs)
-              this.calView.doAddItem(occ);
-          },
-          onDeleteItem: function (aItem) {
-            if (this.calView.mBatchCount) {
-                return;
-            }
-
-            if (isToDo(aItem)) {
-              if (!this.calView.mTasksInView) {
-                return;
-              }
-              if (aItem.isCompleted && !this.calView.mShowCompleted) {
-                return;
-              }
-            }
-
-            var occs = aItem.getOccurrencesBetween(this.calView.startDate,
-                                                   this.calView.queryEndDate,
-                                                   {});
-            for each (var occ in occs) {
-              this.calView.doDeleteItem(occ);
-            }
-          },
-          onError: function (aCalendar, aErrNo, aMessage) { },
-
-          onPropertyChanged: function(aCalendar, aName, aValue, aOldValue) {
-              switch (aName) {
-                  case "suppressAlarms":
-                      if (!getPrefSafe("calendar.alarms.indicator.show", true) ||
-                          aCalendar.getProperty("capabilities.alarms.popup.supported") === false ) {
-                          break;
-                      }
-                      // else fall through
-                  case "readOnly":
-                  case "disabled":
-                      // XXXvv we can be smarter about how we handle this stuff
-                      this.calView.refresh();
-                      break;
-              }
-          },
-          onPropertyDeleting: function(aCalendar, aName) {
-            this.onPropertyChanged(aCalendar, aName, null, null);
-          },
-
-          //
-          // calIAlarmServiceObserver stuff
-          //
-          onAlarm: function onAlarm(aAlarmItem) {
-            this.calView.flashAlarm(aAlarmItem, false);
-          },
-
-          onRemoveAlarmsByItem: function onRemoveAlarmsByItem(aItem) {
-              // Stop the flashing for the item.
-              this.calView.flashAlarm(aItem, true);
-          },
-
-          onRemoveAlarmsByCalendar: function onRemoveAlarmsByCalendar(aCalendar) {
-              // Stop the flashing for all items of this calendar
-              for each (var item in this.calView.mFlashingEvents) {
-                  if (item.calendar.id == aCalendar.id) {
-                      this.calView.flashAlarm(item, true);
-                  }
-              }
-          },
-
-          //
-          // calICompositeObserver stuff
-          // XXXvv we can be smarter about how we handle this stuff
-          //
-          onCalendarAdded: function (aCalendar) {
-            if (!aCalendar.getProperty("disabled")) {
-                this.calView.refresh();
-            }
-          },
-
-          onCalendarRemoved: function (aCalendar) {
-            if (!aCalendar.getProperty("disabled")) {
-                this.calView.refresh();
-            }
-          },
-
-          onDefaultCalendarChanged: function (aNewDefaultCalendar) {
-                // don't care, for now
-          }
-        })
-      ]]></field>
-
       <method name="flashAlarm">
         <parameter name="aAlarmItem"/>
         <parameter name="aStop"/>
         <body><![CDATA[
           var showIndicator = getPrefSafe("calendar.alarms.indicator.show", true);
           var totaltime = getPrefSafe("calendar.alarms.indicator.totaltime", 3600);
 
           if (!aStop && (!showIndicator || totaltime < 1)) {
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -2198,235 +2198,16 @@
       <field name="mSelectedDayCol">null</field>
       <field name="mSelectedDay">null</field>
       <field name="mStartMin">0*60</field>
       <field name="mEndMin">24*60</field>
       <field name="mDayStartMin">0</field>
       <field name="mDayEndMin">0</field>
       <field name="mVisibleMinutes">9*60</field>
 
-      <field name="mObserver"><![CDATA[
-        // the calIObserver, calICompositeObserver, and calIAlarmServiceObserver
-        ({
-            QueryInterface: function QueryInterface(aIID) {
-                if (!aIID.equals(Components.interfaces.calIObserver) &&
-                    !aIID.equals(Components.interfaces.calIAlarmServiceObserver) &&
-                    !aIID.equals(Components.interfaces.calICompositeObserver) &&
-                    !aIID.equals(Components.interfaces.nsISupports)) {
-                    throw Components.results.NS_ERROR_NO_INTERFACE;
-                }
-
-                return this;
-            },
-
-            calView: this,
-
-            onStartBatch: function onStartBatch() {
-                this.calView.mBatchCount++;
-            },
-            onEndBatch: function onEndBatch() {
-                this.calView.mBatchCount--;
-                if (this.calView.mBatchCount == 0) {
-                    this.calView.refresh();
-                }
-            },
-            onLoad: function onLoad() {
-                this.calView.refresh();
-            },
-            onAddItem: function onAddItem(aItem) {
-                if (this.calView.mBatchCount) {
-                    return;
-                }
-
-                if (isToDo(aItem)) {
-                    if (!aItem.entryDate || !aItem.dueDate) {
-                        return;
-                    }
-                    if(!this.calView.mTasksInView){
-                        return;
-                    }
-                    if (aItem.isCompleted && !this.calView.mShowCompleted) {
-                        return;
-                    }
-                }
-
-                var occs = aItem.getOccurrencesBetween(this.calView.startDate,
-                                                       this.calView.queryEndDate,
-                                                       {});
-                //dump ("occs: " + occs.length + "\n");
-                for each (var occ in occs) {
-                    this.calView.doAddEvent(occ);
-                }
-
-                return;
-            },
-            onModifyItem: function onModifyItem(aNewItem, aOldItem) {
-                if (this.calView.mBatchCount) {
-                    return;
-                }
-
-                if (isToDo(aNewItem) && isToDo(aOldItem) &&
-                    !this.calView.mTasksInView)
-                    return;
-
-                var occs;
-
-                if (!isToDo(aOldItem) ||
-                    (aOldItem.entryDate && aOldItem.dueDate)) {
-                    occs = aOldItem.getOccurrencesBetween(this.calView.startDate,
-                                                          this.calView.queryEndDate,
-                                                          {});
-                    for each (var occ in occs) {
-                        this.calView.doDeleteEvent(occ);
-                    }
-                }
-                if (isToDo(aNewItem)) {
-                    if (!aNewItem.entryDate || !aNewItem.dueDate || !this.calView.mTasksInView) {
-                        return;
-                    }
-                    if (aNewItem.isCompleted && !this.calView.mShowCompleted) {
-                        return;
-                    }
-                }
-
-                occs = aNewItem.getOccurrencesBetween(this.calView.startDate,
-                                                      this.calView.queryEndDate,
-                                                      {});
-                for each (var occ in occs) {
-                    this.calView.doAddEvent(occ);
-                }
-            },
-            onDeleteItem: function onDeleteItem(aItem) {
-                if (this.calView.mBatchCount) {
-                    return;
-                }
-
-                if (isToDo(aItem)) {
-                    if (!this.calView.mTasksInView) {
-                        return;
-                    }
-                    if (!aItem.entryDate || !aItem.dueDate) {
-                        return;
-                    }
-                    if (aItem.isCompleted && !this.calView.mShowCompleted) {
-                        return;
-                    }
-                }
-
-                var occs = aItem.getOccurrencesBetween(this.calView.startDate,
-                                                       this.calView.queryEndDate,
-                                                       {});
-                for each (var occ in occs) {
-                    this.calView.doDeleteEvent(occ);
-                }
-            },
-            onError: function onError(aCalendar, aErrNo, aMessage) { },
-
-            onPropertyChanged: function(aCalendar, aName, aValue, aOldValue) {
-                switch (aName) {
-                    case "suppressAlarms":
-                        if (!getPrefSafe("calendar.alarms.indicator.show", true) ||
-                            aCalendar.getProperty("capabilities.alarms.popup.supported") === false ) {
-                            break;
-                        }
-                        // else fall through
-                    case "readOnly":
-                    case "disabled":
-                        // XXXvv we can be smarter about how we handle this stuff
-                        this.calView.refresh();
-                        break;
-                }
-            },
-
-            onPropertyDeleting: function(aCalendar, aName) {
-                // Values are not important here yet.
-                this.onPropertyChanged(aCalendar, aName, null, null);
-            },
-
-            //
-            // calIAlarmServiceObserver stuff
-            //
-            onAlarm: function onAlarm(aAlarmItem) {
-                this.calView.flashAlarm(aAlarmItem, false);
-            },
-
-            onRemoveAlarmsByItem: function onRemoveAlarmsByItem(aItem) {
-                // Stop the flashing for the item.
-                this.calView.flashAlarm(aItem, true);
-            },
-
-            onRemoveAlarmsByCalendar: function onRemoveAlarmsByCalendar(aCalendar) {
-                // Stop the flashing for all items of this calendar
-                for each (var item in this.calView.mFlashingEvents) {
-                    if (item.calendar.id == aCalendar.id) {
-                        this.calView.flashAlarm(item, true);
-                    }
-                }
-            },
-
-            //
-            // calICompositeObserver stuff
-            // XXXvv we can be smarter about how we handle this stuff
-            //
-            onCalendarAdded: function onCalendarAdded(aCalendar) {
-                if (!aCalendar.getProperty("disabled")) {
-                    this.calView.refresh();
-                }
-            },
-
-            onCalendarRemoved: function onCalendarRemoved(aCalendar) {
-                if (!aCalendar.getProperty("disabled")) {
-                    this.calView.refresh();
-                }
-            },
-
-            onDefaultCalendarChanged:
-            function onDefaultCalendarChanged(aNewDefaultCalendar) {
-                // don't care, for now
-            }
-        })
-      ]]></field>
-
-      <field name="mOperationListener"><![CDATA[
-      ({
-          calView: this,
-
-          onOperationComplete:
-          function onOperationComplete(aCalendar, aStatus, aOperationType,
-                                       aId, aDetail) {
-              // Fire event
-              this.calView.fireEvent('viewloaded', aOperationType);
-
-              // signal that the current operation finished.
-              this.calView.mRefreshPending = null;
-
-              // immediately start the next job on the queue.
-              this.calView.popRefreshQueue();
-          },
-          onGetResult:
-          function onGetResult(aCalendar, aStatus, aItemType, aDetail,
-                               aCount, aItems) {
-              if (!Components.isSuccessCode(aStatus))
-                  return;
-
-              function hasGoodDates(item) {
-                  if (isToDo(item) && (!item.entryDate || !item.dueDate)) {
-                      return false;
-                  }
-                  return true;
-              }
-              aItems = aItems.filter(hasGoodDates);
-
-              for each (var item in aItems) {
-                  this.calView.doAddEvent(item);
-              }
-          }
-      })
-      ]]></field>
-
       <method name="flashAlarm">
         <parameter name="aAlarmItem"/>
         <parameter name="aStop"/>
         <body><![CDATA[
           var showIndicator = getPrefSafe("calendar.alarms.indicator.show", true);
           var totaltime = getPrefSafe("calendar.alarms.indicator.totaltime", 3600);
 
           if (!aStop && (!showIndicator || totaltime < 1)) {
@@ -2944,74 +2725,16 @@
           var box = document.getAnonymousElementByAttribute(this, "anonid", "labeldaybox");
           setAttributeToChildren(this.labeldaybox, "orient", otherorient);
 
           // Refresh
           this.refresh();
         ]]></body>
       </method>
 
-
-      <method name="popRefreshQueue">
-        <body><![CDATA[
-          var pendingRefresh = this.mRefreshPending;
-          if (pendingRefresh) {
-              if (calInstanceOf(pendingRefresh, Components.interfaces.calIOperation)) {
-                  this.mRefreshPending = null;
-                  pendingRefresh.cancel(null);
-              } else {
-                  if(this.mRefreshQueue.length > 0) {
-                      this.relayout();
-                  }
-                  return;
-              }
-          }
-
-          var refreshJob = this.mRefreshQueue.pop();
-          if (!refreshJob) {
-            return;
-          }
-
-          if (!this.startDate || !this.endDate)
-            return;
-
-          // recreate our columns
-          this.relayout();
-
-          if (!this.mCalendar)
-              return;
-
-          // start our items query; for a disjoint date range
-          // we get all the items, and just filter out the ones we don't
-          // care about in addItem
-
-          var filter = this.mCalendar.ITEM_FILTER_CLASS_OCCURRENCES;
-          if (this.mShowCompleted) {
-            filter |= this.mCalendar.ITEM_FILTER_COMPLETED_ALL;
-          } else {
-            filter |= this.mCalendar.ITEM_FILTER_COMPLETED_NO;
-          }
-
-          if(this.mTasksInView)
-            filter |= this.mCalendar.ITEM_FILTER_TYPE_ALL;
-          else
-            filter |= this.mCalendar.ITEM_FILTER_TYPE_EVENT;
-
-          this.mRefreshPending = true;
-          pendingRefresh = this.mCalendar.getItems(filter,
-                                                   0,
-                                                   this.startDate,
-                                                   this.queryEndDate,
-                                                   this.mOperationListener);
-          if (pendingRefresh && pendingRefresh.isPending) { // support for calIOperation
-              this.mRefreshPending = pendingRefresh;
-          }
-        ]]></body>
-      </method>
-
       <method name="relayout">
         <body><![CDATA[
           var orient = this.getAttribute("orient");
           if (!orient) orient = "horizontal";
           var otherorient = getOtherOrientation(orient);
 
           var computedDateList;
           if (this.mDateList) {
@@ -3289,20 +3012,20 @@
               endDate && endDate.isDate) {
               // If this is an all day event, then the header with allday
               // events could possibly get a scrollbar. Readjust them.
               this.adjustScrollBarSpacers();
           }
         ]]></body>
       </method>
 
-      <method name="doAddEvent">
+      <method name="doAddItem">
         <parameter name="aEvent"/>
         <body><![CDATA[
-          //dump ("++ doAddevent\n");
+          //dump ("++ doAddItem\n");
           var cols = this.findColumnsForItem(aEvent);
           if (!cols.length)
               return;
 
           for each (col in cols) {
               var column = col.column;
               var header = col.header;
 
@@ -3313,17 +3036,17 @@
                   column.addEvent(aEvent);
               }
           }
 
           this.adjustScrollbarSpacersForAlldayEvents(aEvent);
         ]]></body>
       </method>
 
-      <method name="doDeleteEvent">
+      <method name="doDeleteItem">
         <parameter name="aEvent"/>
         <body><![CDATA[
           var cols = this.findColumnsForItem(aEvent);
           if (!cols.length)
               return;
 
           for each (col in cols) {
               var column = col.column;