From 6907ae73e76d11c201ff237663af79b3bbfc5385 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 27 Jun 2012 08:52:42 +0200 Subject: 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 --- src/event.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/event.c') diff --git a/src/event.c b/src/event.c index 4f70391..d937a8b 100644 --- a/src/event.c +++ b/src/event.c @@ -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); } -- cgit v1.2.3-54-g00ecf