summaryrefslogtreecommitdiffstats
path: root/src/interaction.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-07-07 11:55:10 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-07-07 21:35:02 +0200
commit7fb25a84d427f4a3cb79ea02908daf9ce8ba07ca (patch)
treecb24b54351955c1d354095023534d8b51d8f9cec /src/interaction.c
parent69345edd77b3ff98a99b36de8063f9e5febad3eb (diff)
downloadcalcurse-7fb25a84d427f4a3cb79ea02908daf9ce8ba07ca.tar.gz
calcurse-7fb25a84d427f4a3cb79ea02908daf9ce8ba07ca.zip
Refactor note removal
Remove the note removal code from *_delete()/*_erase() and create a new wrapper function called day_item_erase_note() that is be used to drop the note being associated to an item. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/interaction.c')
-rw-r--r--src/interaction.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/interaction.c b/src/interaction.c
index b619992..4d71520 100644
--- a/src/interaction.c
+++ b/src/interaction.c
@@ -389,32 +389,26 @@ static int day_erase_item(long date, int item_number, enum eraseflg flag)
unsigned delete_whole;
p = day_get_item(item_number);
- if (flag == ERASE_DONT_FORCE) {
- if (day_item_get_note(p) == NULL)
- ans = 1;
- else
- ans = status_ask_choice(note_warning, note_choices, nb_note_choices);
-
- switch (ans) {
+ if (flag == ERASE_DONT_FORCE && day_item_get_note(p)) {
+ switch (status_ask_choice(note_warning, note_choices, nb_note_choices)) {
case 1:
- flag = ERASE_FORCE;
break;
case 2:
- flag = ERASE_FORCE_ONLY_NOTE;
- break;
+ day_item_erase_note(p);
+ return 0;
default: /* User escaped */
return 0;
}
}
+
+ flag = ERASE_FORCE;
+
if (p->type == EVNT) {
event_delete(p->item.ev, flag);
} else if (p->type == APPT) {
apoint_delete(p->item.apt, flag);
} else {
- if (flag == ERASE_FORCE_ONLY_NOTE)
- ans = 1;
- else
- ans = status_ask_choice(erase_warning, erase_choices, nb_erase_choices);
+ ans = status_ask_choice(erase_warning, erase_choices, nb_erase_choices);
switch (ans) {
case 1:
@@ -433,10 +427,8 @@ static int day_erase_item(long date, int item_number, enum eraseflg flag)
recur_apoint_erase(p->item.rapt, date, delete_whole, flag);
}
}
- if (flag == ERASE_FORCE_ONLY_NOTE)
- return 0;
- else
- return p->type;
+
+ return p->type;
}
/* Pipe an appointment or event to an external program. */