Bug 537456 - It is not possible to copy/paste Tasks. r=philipp

This commit is contained in:
Matthew Mecca 2011-12-19 22:10:21 -05:00
Родитель e4e9e26861
Коммит 4764809fc0
4 изменённых файлов: 65 добавлений и 14 удалений

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

@ -22,6 +22,7 @@
* Joey Minta <jminta@gmail.com>
* Philipp Kewisch <mozilla@kewis.ch>
* Martin Schroeder <mschroeder@mozilla.x-home.org>
* Matthew Mecca <matthew.mecca@gmail.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
@ -73,10 +74,8 @@ function canPaste() {
* deletes the events on success
*/
function cutToClipboard() {
let calendarItemArray = currentView().getSelectedItems({});
if (copyToClipboard(calendarItemArray)) {
deleteSelectedEvents();
if (copyToClipboard()) {
deleteSelectedItems();
}
}
@ -91,10 +90,11 @@ function cutToClipboard() {
*/
function copyToClipboard(calendarItemArray) {
if (!calendarItemArray) {
calendarItemArray = currentView().getSelectedItems({});
calendarItemArray = getSelectedItems();
}
if (!calendarItemArray.length) {
cal.LOG("[calendar-clipboard] No items to copy.");
return false;
}
@ -207,14 +207,17 @@ function pasteFromClipboard() {
}
let firstDate = currentView().selectedDay;
let offset = null;
if (earliestDate) {
// Timezones and DT/DST time may differ between the earliest item
// and the selected day. Determine the offset between the
// earliestDate in local time and the selected day in whole days.
earliestDate = earliestDate.getInTimezone(calendarDefaultTimezone());
earliestDate.isDate = true;
let offset = firstDate.subtractDate(earliestDate);
offset = firstDate.subtractDate(earliestDate);
let deltaDST = firstDate.timezoneOffset - earliestDate.timezoneOffset;
offset.inSeconds += deltaDST;
}
startBatchTransaction();
for each (let item in items) {
@ -222,7 +225,9 @@ function pasteFromClipboard() {
// Set new UID to allow multiple paste actions of the same
// clipboard content.
newItem.id = cal.getUUID();
if (offset) {
cal.shiftItem(newItem, offset);
}
doTransaction('add', newItem, destCal, null, null);
}
endBatchTransaction();

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

@ -914,3 +914,25 @@ function selectAllItems() {
selectAllEvents();
}
}
/**
* Returns the selected items, based on which mode we are currently in and what task tree is focused
*/
function getSelectedItems() {
if (calendarController.todo_tasktree_focused) {
return getSelectedTasks();
}
return currentView().getSelectedItems({});
}
/**
* Deletes the selected items, based on which mode we are currently in and what task tree is focused
*/
function deleteSelectedItems() {
if (calendarController.todo_tasktree_focused) {
deleteToDoCommand();
} else if (calendarController.isInMode("calendar")) {
deleteSelectedEvents();
}
}

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

@ -389,6 +389,25 @@
key="calendar-new-todo-key"
command="calendar_new_todo_todaypane_command"
observes="calendar_new_todo_todaypane_command"/>
<menuseparator id="task-context-menuseparator-cutcopypaste"/>
<menuitem id="task-context-menu-cut-menuitem"
label="&calendar.context.cutevent.label;"
accesskey="&calendar.context.cutevent.accesskey;"
key="key_cut"
observes="cmd_cut"
command="cmd_cut"/>
<menuitem id="task-context-menu-copy-menuitem"
label="&calendar.context.copyevent.label;"
accesskey="&calendar.context.copyevent.accesskey;"
key="key_copy"
observes="cmd_copy"
command="cmd_copy"/>
<menuitem id="task-context-menu-paste-menuitem"
label="&calendar.context.pasteevent.label;"
accesskey="&calendar.context.pasteevent.accesskey;"
key="key_paste"
observes="cmd_paste"
command="cmd_paste"/>
<menuseparator id="calendar-menuseparator-beforemarkcompleted"/>
<menuitem id="calendar-context-markcompleted"
type="checkbox"

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

@ -126,6 +126,11 @@ function changeContextMenuForTask(aEvent) {
document.getElementById("calendar_new_todo_todaypane_command").setAttribute("disabled", "true");
}
// make sure the paste menu item is enabled
if (calendarController2.isCommandEnabled("cmd_paste")) {
document.getElementById("cmd_paste").removeAttribute("disabled");
}
// make sure the filter menu is enabled
document.getElementById("task-context-menu-filter-todaypane").removeAttribute("disabled");
applyAttributeToMenuChildren(document.getElementById("task-context-menu-filter-todaypane-popup"),