Update the views and the event list when adding/removing a calendar.

bug 285014, r=shaver
This commit is contained in:
mvl%exedo.nl 2005-05-11 14:52:00 +00:00
Родитель 3a36e278af
Коммит 8a2e1e6063
3 изменённых файлов: 75 добавлений и 19 удалений

Просмотреть файл

@ -140,6 +140,17 @@ function CalendarWindow( )
var savedThis = this;
var calendarObserver = {
QueryInterface: function (aIID) {
if (!aIID.equals(Components.interfaces.nsISupports) &&
!aIID.equals(Components.interfaces.calICompositeObserver) &&
!aIID.equals(Components.interfaces.calIObserver))
{
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
},
mInBatch: false,
onStartBatch: function() {
@ -166,7 +177,17 @@ function CalendarWindow( )
calendarWindow.currentView.refreshEvents();
},
onAlarm: function(aAlarmItem) {},
onError: function(aMessage) {}
onError: function(aMessage) {},
onCalendarAdded: function(aDeletedItem) {
if (!this.mInBatch)
calendarWindow.currentView.refreshEvents();
},
onCalendarRemoved: function(aDeletedItem) {
if (!this.mInBatch)
calendarWindow.currentView.refreshEvents();
},
onDefaultCalendarChanged: function(aNewDefaultCalendar) {}
}
var ccalendar = getDisplayComposite();
ccalendar.addObserver(calendarObserver);

Просмотреть файл

@ -138,6 +138,7 @@ var unifinderObserver = {
QueryInterface: function (aIID) {
if (!aIID.equals(Components.interfaces.nsISupports) &&
!aIID.equals(Components.interfaces.calICompositeObserver) &&
!aIID.equals(Components.interfaces.calIObserver))
{
throw Components.results.NS_ERROR_NO_INTERFACE;
@ -170,7 +171,17 @@ var unifinderObserver = {
refreshEventTree();
},
onAlarm: function(aAlarmItem) {},
onError: function(aMessage) {}
onError: function(aMessage) {},
onCalendarAdded: function(aDeletedItem) {
if (!this.mInBatch)
refreshEventTree();
},
onCalendarRemoved: function(aDeletedItem) {
if (!this.mInBatch)
refreshEventTree();
},
onDefaultCalendarChanged: function(aNewDefaultCalendar) {}
};

Просмотреть файл

@ -59,33 +59,57 @@ var gTaskArray = new Array();
var unifinderToDoDataSourceObserver =
{
onStartBatch: function () { },
onEndBatch: function () {
mInBatch: false,
QueryInterface: function (aIID) {
if (!aIID.equals(Components.interfaces.nsISupports) &&
!aIID.equals(Components.interfaces.calICompositeObserver) &&
!aIID.equals(Components.interfaces.calIObserver))
{
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
},
onStartBatch: function() {
this.mInBatch = true;
},
onEndBatch: function() {
this.mInBatch = false;
toDoUnifinderRefresh();
},
onLoad: function () {
toDoUnifinderRefresh();
onLoad: function() {
if (!this.mInBatch)
refreshEventTree();
},
onAddItem: function (aItem) {
if (aItem instanceof Components.interfaces.calITodo)
onAddItem: function(aItem) {
if (aItem instanceof Components.interfaces.calITodo &&
!this.mInBatch)
toDoUnifinderRefresh();
},
onModifyItem: function (aNewItem, aOldItem) {
if (aNewItem instanceof Components.interfaces.calITodo)
onModifyItem: function(aNewItem, aOldItem) {
if (aNewItem instanceof Components.interfaces.calITodo &&
!this.mInBatch)
toDoUnifinderRefresh();
},
onDeleteItem: function (aItem) {
if (aItem instanceof Components.interfaces.calITodo)
onDeleteItem: function(aDeletedItem) {
if (aDeletedItem instanceof Components.interfaces.calITodo &&
!this.mInBatch)
toDoUnifinderRefresh();
},
onAlarm: function(aAlarmItem) {},
onError: function(aMessage) {},
onAlarm: function (aAlarmItem) { },
onError: function (aErrNo, aMessage) { }
onCalendarAdded: function(aDeletedItem) {
if (!this.mInBatch)
toDoUnifinderRefresh();
},
onCalendarRemoved: function(aDeletedItem) {
if (!this.mInBatch)
toDoUnifinderRefresh();
},
onDefaultCalendarChanged: function(aNewDefaultCalendar) {}
};
/**