From 3321bd901f73efefae658fe49a678c3e80a5ac56 Mon Sep 17 00:00:00 2001 From: "mozilla%kewis.ch" Date: Thu, 17 Jan 2008 22:34:40 +0000 Subject: [PATCH] Fix bug 412613 - Select All (Ctrl+A) in Mail mode doesn't work anymore (regression). r=mickey --- calendar/base/content/calendar-common-sets.js | 82 ++++++------------- calendar/base/content/calendar-views.js | 37 +++++++++ calendar/resources/content/calendar.js | 34 -------- 3 files changed, 63 insertions(+), 90 deletions(-) diff --git a/calendar/base/content/calendar-common-sets.js b/calendar/base/content/calendar-common-sets.js index 9d12f1992b8..1418af6ccd1 100644 --- a/calendar/base/content/calendar-common-sets.js +++ b/calendar/base/content/calendar-common-sets.js @@ -94,6 +94,13 @@ var calendarController = { }, isCommandEnabled: function cC_isCommandEnabled(aCommand) { + if (this.defaultController && !this.isCalendarInForeground()) { + // If calendar is not in foreground, let the default controller take + // care. If we don't have a default controller (i.e sunbird), just + // continue. + return this.defaultController.isCommandEnabled(aCommand); + } + switch (aCommand) { case "calendar_new_event_command": return this.writable && this.calendars_support_events; @@ -133,61 +140,34 @@ var calendarController = { case "cmd_paste": return this.writable && canPaste(); case "cmd_undo": - if (this.isCalendarInForeground()) { - goSetMenuValue(aCommand, 'valueDefault'); - if (canUndo()) { - return true; - } - } - break; + goSetMenuValue(aCommand, 'valueDefault'); + return canUndo(); case "cmd_redo": - if (this.isCalendarInForeground()) { - goSetMenuValue(aCommand, 'valueDefault'); - if (canRedo()) { - return true; - } - } - break; - - case "cmd_selectAll": - if (this.isCalendarInForeground()) { - // If there are no events at all, we might want to disable - // this item - return true; - } - break; - - case "button_print": - case "cmd_print": - if (this.isCalendarInForeground()) { - return true; - } - break; + goSetMenuValue(aCommand, 'valueDefault'); + return canRedo(); case "cmd_printpreview": - if (this.isCalendarInForeground()) { - return false; - } - break; + return false; case "button_delete": case "cmd_delete": - if (this.isCalendarInForeground()) { - return this.item_selected; - } - break; + return this.item_selected; } if (aCommand in this.commands) { // All other commands we support should be enabled by default return true; } - - if (this.defaultController) { - return this.defaultController.isCommandEnabled(aCommand); - } return false; }, doCommand: function cC_doCommand(aCommand) { + if (this.defaultController && !this.isCalendarInForeground()) { + // If calendar is not in foreground, let the default controller take + // care. If we don't have a default controller (i.e sunbird), just + // continue. + this.defaultController.doCommand(aCommand); + return; + } + switch (aCommand) { // Common Commands case "calendar_new_event_command": @@ -258,12 +238,12 @@ var calendarController = { pasteFromClipboard(); break; case "cmd_undo": - if (this.isCalendarInForeground() && canUndo()) { + if (canUndo()) { getTransactionMgr().undo(); } break; case "cmd_redo": - if (this.isCalendarInForeground() && canRedo()) { + if (canRedo()) { getTransactionMgr().redo(); } break; @@ -275,25 +255,15 @@ var calendarController = { break; case "button_print": case "cmd_print": - if (this.isCalendarInForeground()) { - calPrint(); - return; - } + calPrint(); break; // Thunderbird commands case "cmd_printpreview": case "button_delete": case "cmd_delete": - if (this.isCalendarInForeground()) { - // For these commands, nothing should happen in calendar mode. - return; - } - break; - } - - if (this.defaultController) { - this.defaultController.doCommand(aCommand); + // For these commands, nothing should happen in calendar mode. + return; } }, diff --git a/calendar/base/content/calendar-views.js b/calendar/base/content/calendar-views.js index 86f1ba7c925..8e1d1e77580 100644 --- a/calendar/base/content/calendar-views.js +++ b/calendar/base/content/calendar-views.js @@ -628,3 +628,40 @@ function editSelectedEvents() { modifyEventWithDialog(getOccurrenceOrParent(selectedItems[0])); } } + +/** + * Select all events from all calendars + */ +function selectAllEvents() { + var items = []; + var listener = { + onOperationComplete: function selectAll_ooc(aCalendar, aStatus, + aOperationType, aId, + aDetail) { + currentView().setSelectedItems(items.length, items, false); + }, + onGetResult: function selectAll_ogr(aCalendar, aStatus, aItemType, + aDetail, aCount, aItems) { + for each (var item in aItems) { + items.push(item); + } + } + }; + + var composite = getCompositeCalendar(); + var filter = composite.ITEM_FILTER_COMPLETED_ALL | + composite.ITEM_FILTER_CLASS_OCCURRENCES; + + if (currentView().tasksInView) { + filter |= composite.ITEM_FILTER_TYPE_ALL; + } else { + filter |= composite.ITEM_FILTER_TYPE_EVENT; + } + + // Need to move one day out to get all events + var end = currentView().endDay.clone(); + end.day += 1; + + composite.getItems(filter, 0, currentView().startDay, end, listener); +} + diff --git a/calendar/resources/content/calendar.js b/calendar/resources/content/calendar.js index c1d1296aaab..13d0df13d8c 100644 --- a/calendar/resources/content/calendar.js +++ b/calendar/resources/content/calendar.js @@ -222,40 +222,6 @@ function calendarFinish() calendarOfflineManager.uninit(); } -function selectAllEvents() -{ - var items = []; - var listener = { - onOperationComplete: function selectAll_ooc(aCalendar, aStatus, - aOperationType, aId, - aDetail) { - currentView().setSelectedItems(items.length, items, false); - }, - onGetResult: function selectAll_ogr(aCalendar, aStatus, aItemType, - aDetail, aCount, aItems) { - for each (var item in aItems) { - items.push(item); - } - } - }; - - var composite = getCompositeCalendar(); - var filter = composite.ITEM_FILTER_COMPLETED_ALL | - composite.ITEM_FILTER_CLASS_OCCURRENCES; - - if (currentView().tasksInView) { - filter |= composite.ITEM_FILTER_TYPE_ALL; - } else { - filter |= composite.ITEM_FILTER_TYPE_EVENT; - } - - // Need to move one day out to get all events - var end = currentView().endDay.clone(); - end.day += 1; - - composite.getItems(filter, 0, currentView().startDay, end, listener); -} - function closeCalendar() { self.close();