Revise cut/pasting

Instead of calling type-specific duplication handlers and inserting
clones of the original items when pasting, save the generic day item and
remove the actual item from the linked list, so that it can be inserted
anywhere else later.

The cut/paste buffer is moved to the interaction unit, item-specific cut
operations are changed to remove the item from the linked list only
instead of copying and freeing it. An item is only freed if another item
is cut before the current cut/paste buffer is pasted. All paste
operations are changed and reinsert the actual item instead of creating
a clone.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer
2012-06-27 08:52:42 +02:00
parent b230e2949e
commit 6907ae73e7
7 changed files with 120 additions and 116 deletions

View File

@@ -167,10 +167,8 @@ void event_delete(struct event *ev, enum eraseflg flag)
erase_note(&ev->note);
break;
case ERASE_CUT:
event_free_bkp();
event_dup(ev, &bkp_cut_event);
erase_note(&ev->note);
/* FALLTHROUGH */
LLIST_REMOVE(&eventlist, i);
break;
default:
LLIST_REMOVE(&eventlist, i);
mem_free(ev->mesg);
@@ -179,9 +177,8 @@ void event_delete(struct event *ev, enum eraseflg flag)
}
}
void event_paste_item(void)
void event_paste_item(struct event *ev, long date)
{
event_new(bkp_cut_event.mesg, bkp_cut_event.note,
date2sec(*calendar_get_slctd_day(), 0, 0), bkp_cut_event.id);
event_free_bkp();
ev->day = date;
LLIST_ADD_SORTED(&eventlist, ev, event_cmp_day);
}