Revise *_delete{,_bynum}()
Always pass an item instead of passing a date and a index. This makes use of the NULL callback that was added with one of the previous patches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
e1fbee0071
commit
02c90ba53a
@ -269,17 +269,15 @@ struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end, char state,
|
|||||||
return apoint_new(buf, note, tstart, tend - tstart, state);
|
return apoint_new(buf, note, tstart, tend - tstart, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void apoint_delete_bynum(long start, unsigned num, enum eraseflg flag)
|
void apoint_delete(struct apoint *apt, enum eraseflg flag)
|
||||||
{
|
{
|
||||||
llist_item_t *i;
|
|
||||||
int need_check_notify = 0;
|
int need_check_notify = 0;
|
||||||
|
|
||||||
LLIST_TS_LOCK(&alist_p);
|
LLIST_TS_LOCK(&alist_p);
|
||||||
i = LLIST_TS_FIND_NTH(&alist_p, num, &start, apoint_inday);
|
llist_item_t *i = LLIST_TS_FIND_FIRST(&alist_p, apt, NULL);
|
||||||
|
|
||||||
if (!i)
|
if (!i)
|
||||||
EXIT(_("no such appointment"));
|
EXIT(_("no such appointment"));
|
||||||
struct apoint *apt = LLIST_TS_GET_DATA(i);
|
|
||||||
|
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
case ERASE_FORCE_ONLY_NOTE:
|
case ERASE_FORCE_ONLY_NOTE:
|
||||||
|
@ -605,7 +605,7 @@ unsigned apoint_inday(struct apoint *, long *);
|
|||||||
void apoint_sec2str(struct apoint *, long, char *, char *);
|
void apoint_sec2str(struct apoint *, long, char *, char *);
|
||||||
void apoint_write(struct apoint *, FILE *);
|
void apoint_write(struct apoint *, FILE *);
|
||||||
struct apoint *apoint_scan(FILE *, struct tm, struct tm, char, char *);
|
struct apoint *apoint_scan(FILE *, struct tm, struct tm, char, char *);
|
||||||
void apoint_delete_bynum(long, unsigned, enum eraseflg);
|
void apoint_delete(struct apoint *, enum eraseflg);
|
||||||
void apoint_scroll_pad_down(int, int);
|
void apoint_scroll_pad_down(int, int);
|
||||||
void apoint_scroll_pad_up(int);
|
void apoint_scroll_pad_up(int);
|
||||||
struct notify_app *apoint_check_next(struct notify_app *, long);
|
struct notify_app *apoint_check_next(struct notify_app *, long);
|
||||||
@ -695,7 +695,7 @@ struct event *event_new(char *, char *, long, int);
|
|||||||
unsigned event_inday(struct event *, long *);
|
unsigned event_inday(struct event *, long *);
|
||||||
void event_write(struct event *, FILE *);
|
void event_write(struct event *, FILE *);
|
||||||
struct event *event_scan(FILE *, struct tm, int, char *);
|
struct event *event_scan(FILE *, struct tm, int, char *);
|
||||||
void event_delete_bynum(long, unsigned, enum eraseflg);
|
void event_delete(struct event *, enum eraseflg);
|
||||||
void event_paste_item(void);
|
void event_paste_item(void);
|
||||||
|
|
||||||
/* help.c */
|
/* help.c */
|
||||||
@ -871,8 +871,8 @@ unsigned recur_event_find_occurrence(struct recur_event *, long, unsigned *);
|
|||||||
unsigned recur_item_inday(long, long, llist_t *, int, int, long, long);
|
unsigned recur_item_inday(long, long, llist_t *, int, int, long, long);
|
||||||
unsigned recur_apoint_inday(struct recur_apoint *, long *);
|
unsigned recur_apoint_inday(struct recur_apoint *, long *);
|
||||||
unsigned recur_event_inday(struct recur_event *, long *);
|
unsigned recur_event_inday(struct recur_event *, long *);
|
||||||
void recur_event_erase(long, unsigned, unsigned, enum eraseflg);
|
void recur_event_erase(struct recur_event *, long, unsigned, enum eraseflg);
|
||||||
void recur_apoint_erase(long, unsigned, unsigned, enum eraseflg);
|
void recur_apoint_erase(struct recur_apoint *, long, unsigned, enum eraseflg);
|
||||||
void recur_exc_scan(llist_t *, FILE *);
|
void recur_exc_scan(llist_t *, FILE *);
|
||||||
struct notify_app *recur_apoint_check_next(struct notify_app *, long, long);
|
struct notify_app *recur_apoint_check_next(struct notify_app *, long, long);
|
||||||
void recur_apoint_switch_notify(struct recur_apoint *);
|
void recur_apoint_switch_notify(struct recur_apoint *);
|
||||||
@ -900,7 +900,7 @@ char *todo_saved_mesg(void);
|
|||||||
struct todo *todo_add(char *, int, char *);
|
struct todo *todo_add(char *, int, char *);
|
||||||
void todo_write(struct todo *, FILE *);
|
void todo_write(struct todo *, FILE *);
|
||||||
void todo_delete_note_bynum(unsigned);
|
void todo_delete_note_bynum(unsigned);
|
||||||
void todo_delete_bynum(unsigned);
|
void todo_delete(struct todo *);
|
||||||
void todo_flag(void);
|
void todo_flag(void);
|
||||||
void todo_chg_priority(int);
|
void todo_chg_priority(int);
|
||||||
void todo_update_panel(int);
|
void todo_update_panel(int);
|
||||||
|
@ -607,17 +607,16 @@ int day_cut_item(long date, int item_number)
|
|||||||
p = day_get_item(item_number);
|
p = day_get_item(item_number);
|
||||||
switch (p->type) {
|
switch (p->type) {
|
||||||
case EVNT:
|
case EVNT:
|
||||||
event_delete_bynum(date, day_item_nb(date, item_number, EVNT), ERASE_CUT);
|
event_delete(p->item.ev, ERASE_CUT);
|
||||||
break;
|
break;
|
||||||
case RECUR_EVNT:
|
case RECUR_EVNT:
|
||||||
recur_event_erase(date, day_item_nb(date, item_number, RECUR_EVNT),
|
recur_event_erase(p->item.rev, date, DELETE_WHOLE, ERASE_CUT);
|
||||||
DELETE_WHOLE, ERASE_CUT);
|
|
||||||
break;
|
break;
|
||||||
case APPT:
|
case APPT:
|
||||||
apoint_delete_bynum(date, day_item_nb(date, item_number, APPT), ERASE_CUT);
|
apoint_delete(p->item.apt, ERASE_CUT);
|
||||||
break;
|
break;
|
||||||
case RECUR_APPT:
|
case RECUR_APPT:
|
||||||
recur_apoint_erase(date, p->appt_pos, DELETE_WHOLE, ERASE_CUT);
|
recur_apoint_erase(p->item.rapt, date, DELETE_WHOLE, ERASE_CUT);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
EXIT(_("unknwon type"));
|
EXIT(_("unknwon type"));
|
||||||
|
@ -155,13 +155,12 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Delete an event from the list. */
|
/* Delete an event from the list. */
|
||||||
void event_delete_bynum(long start, unsigned num, enum eraseflg flag)
|
void event_delete(struct event *ev, enum eraseflg flag)
|
||||||
{
|
{
|
||||||
llist_item_t *i = LLIST_FIND_NTH(&eventlist, num, &start, event_inday);
|
llist_item_t *i = LLIST_FIND_FIRST(&eventlist, ev, NULL);
|
||||||
|
|
||||||
if (!i)
|
if (!i)
|
||||||
EXIT(_("no such appointment"));
|
EXIT(_("no such appointment"));
|
||||||
struct event *ev = LLIST_TS_GET_DATA(i);
|
|
||||||
|
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
case ERASE_FORCE_ONLY_NOTE:
|
case ERASE_FORCE_ONLY_NOTE:
|
||||||
|
@ -403,9 +403,9 @@ static int day_erase_item(long date, int item_number, enum eraseflg flag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p->type == EVNT) {
|
if (p->type == EVNT) {
|
||||||
event_delete_bynum(date, day_item_nb(date, item_number, EVNT), flag);
|
event_delete(p->item.ev, flag);
|
||||||
} else if (p->type == APPT) {
|
} else if (p->type == APPT) {
|
||||||
apoint_delete_bynum(date, day_item_nb(date, item_number, APPT), flag);
|
apoint_delete(p->item.apt, flag);
|
||||||
} else {
|
} else {
|
||||||
if (flag == ERASE_FORCE_ONLY_NOTE)
|
if (flag == ERASE_FORCE_ONLY_NOTE)
|
||||||
ans = 1;
|
ans = 1;
|
||||||
@ -424,10 +424,9 @@ static int day_erase_item(long date, int item_number, enum eraseflg flag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (p->type == RECUR_EVNT) {
|
if (p->type == RECUR_EVNT) {
|
||||||
recur_event_erase(date, day_item_nb(date, item_number, RECUR_EVNT),
|
recur_event_erase(p->item.rev, date, delete_whole, flag);
|
||||||
delete_whole, flag);
|
|
||||||
} else {
|
} else {
|
||||||
recur_apoint_erase(date, p->appt_pos, delete_whole, flag);
|
recur_apoint_erase(p->item.rapt, date, delete_whole, flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flag == ERASE_FORCE_ONLY_NOTE)
|
if (flag == ERASE_FORCE_ONLY_NOTE)
|
||||||
@ -666,7 +665,7 @@ void interact_todo_delete(void)
|
|||||||
|
|
||||||
switch (answer) {
|
switch (answer) {
|
||||||
case 1:
|
case 1:
|
||||||
todo_delete_bynum(todo_hilt() - 1);
|
todo_delete(todo_get_item(todo_hilt()));
|
||||||
todo_set_nb(todo_nb() - 1);
|
todo_set_nb(todo_nb() - 1);
|
||||||
if (todo_hilt() > 1)
|
if (todo_hilt() > 1)
|
||||||
todo_hilt_decrease(1);
|
todo_hilt_decrease(1);
|
||||||
|
16
src/recur.c
16
src/recur.c
@ -695,16 +695,13 @@ unsigned recur_event_inday(struct recur_event *rev, long *day_start)
|
|||||||
* or delete only one occurence of the recurrent event.
|
* or delete only one occurence of the recurrent event.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
recur_event_erase(long start, unsigned num, unsigned delete_whole,
|
recur_event_erase(struct recur_event *rev, long start, unsigned delete_whole,
|
||||||
enum eraseflg flag)
|
enum eraseflg flag)
|
||||||
{
|
{
|
||||||
llist_item_t *i;
|
llist_item_t *i = LLIST_FIND_FIRST(&recur_elist, rev, NULL);
|
||||||
|
|
||||||
i = LLIST_FIND_NTH(&recur_elist, num, &start, recur_event_inday);
|
|
||||||
|
|
||||||
if (!i)
|
if (!i)
|
||||||
EXIT(_("event not found"));
|
EXIT(_("event not found"));
|
||||||
struct recur_event *rev = LLIST_GET_DATA(i);
|
|
||||||
|
|
||||||
if (delete_whole) {
|
if (delete_whole) {
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
@ -736,17 +733,14 @@ recur_event_erase(long start, unsigned num, unsigned delete_whole,
|
|||||||
* or delete only one occurence of the recurrent appointment.
|
* or delete only one occurence of the recurrent appointment.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
recur_apoint_erase(long start, unsigned num, unsigned delete_whole,
|
recur_apoint_erase(struct recur_apoint *rapt, long start,
|
||||||
enum eraseflg flag)
|
unsigned delete_whole, enum eraseflg flag)
|
||||||
{
|
{
|
||||||
llist_item_t *i;
|
llist_item_t *i = LLIST_TS_FIND_FIRST(&recur_alist_p, rapt, NULL);
|
||||||
int need_check_notify = 0;
|
int need_check_notify = 0;
|
||||||
|
|
||||||
i = LLIST_TS_FIND_NTH(&recur_alist_p, num, &start, recur_apoint_inday);
|
|
||||||
|
|
||||||
if (!i)
|
if (!i)
|
||||||
EXIT(_("appointment not found"));
|
EXIT(_("appointment not found"));
|
||||||
struct recur_apoint *rapt = LLIST_GET_DATA(i);
|
|
||||||
|
|
||||||
LLIST_TS_LOCK(&recur_alist_p);
|
LLIST_TS_LOCK(&recur_alist_p);
|
||||||
if (notify_bar() && flag != ERASE_FORCE_ONLY_NOTE)
|
if (notify_bar() && flag != ERASE_FORCE_ONLY_NOTE)
|
||||||
|
@ -170,13 +170,12 @@ void todo_delete_note_bynum(unsigned num)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Delete an item from the todo linked list. */
|
/* Delete an item from the todo linked list. */
|
||||||
void todo_delete_bynum(unsigned num)
|
void todo_delete(struct todo *todo)
|
||||||
{
|
{
|
||||||
llist_item_t *i = LLIST_NTH(&todolist, num);
|
llist_item_t *i = LLIST_FIND_FIRST(&todolist, todo, NULL);
|
||||||
|
|
||||||
if (!i)
|
if (!i)
|
||||||
EXIT(_("no such todo"));
|
EXIT(_("no such todo"));
|
||||||
struct todo *todo = LLIST_TS_GET_DATA(i);
|
|
||||||
|
|
||||||
LLIST_REMOVE(&todolist, i);
|
LLIST_REMOVE(&todolist, i);
|
||||||
mem_free(todo->mesg);
|
mem_free(todo->mesg);
|
||||||
@ -250,7 +249,7 @@ void todo_chg_priority(int action)
|
|||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
todo_delete_bynum(hilt - 1);
|
todo_delete(todo_get_item(hilt));
|
||||||
backup = todo_add(backup_mesg, backup_id, backup_note);
|
backup = todo_add(backup_mesg, backup_id, backup_note);
|
||||||
hilt = todo_get_position(backup);
|
hilt = todo_get_position(backup);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user