Commit b8010cb4 authored by Glen Ditchfield's avatar Glen Ditchfield 🐛
Browse files

Clean up after deleteIncidence changes

 * `deleteTodoIncidence()` is unused.

 * RFC 5545 allows relationships between all sorts of instances, and
   the deletion code doesn't gain by limiting itself to to-dos.
parent de11c043
Pipeline #56660 passed with stage
in 19 minutes and 29 seconds
......@@ -1249,7 +1249,7 @@ bool CalendarView::incidence_unsub(const Akonadi::Item &item)
const KCalendarCore::Incidence::Ptr inc = CalendarSupport::incidence(item);
if (!inc || inc->relatedTo().isEmpty()) {
qCDebug(KORGANIZER_LOG) << "Refusing to unparent this to-do" << inc;
qCDebug(KORGANIZER_LOG) << "Refusing to unparent this instance" << inc;
return false;
}
......@@ -2131,32 +2131,28 @@ bool CalendarView::editIncidence(const Akonadi::Item &item, bool isCounter)
}
IncidenceEditorNG::IncidenceDialog *dialog = incidenceDialog(item);
// connectIncidenceEditor( dialog ); // TODO: This as well
dialog->load(item, activeIncidenceDate()); // Show the dialog as soon as it loads the item.
return true;
}
void CalendarView::deleteSubTodosIncidence(const Akonadi::Item &todoItem)
void CalendarView::deleteIncidenceFamily(const Akonadi::Item &item)
{
const KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(todoItem);
if (!todo) {
const auto incidence = CalendarSupport::incidence(item);
if (!incidence) {
return;
}
deleteChildren(todoItem);
deleteRecurringIncidence(todoItem);
deleteChildren(item);
deleteRecurringIncidence(item);
}
void CalendarView::deleteChildren(const Akonadi::Item &todoItem)
void CalendarView::deleteChildren(const Akonadi::Item &item)
{
const KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(todoItem);
if (todo && !todo->hasRecurrenceId()) {
const Akonadi::Item::List subTodos = mCalendar->childItems(todoItem.id());
for (const Akonadi::Item &item : subTodos) {
if (CalendarSupport::hasTodo(item)) {
deleteSubTodosIncidence(item);
}
const auto incidence = CalendarSupport::incidence(item);
if (incidence && !incidence->hasRecurrenceId()) {
const Akonadi::Item::List childItems = mCalendar->childItems(item.id());
for (const Akonadi::Item &c : childItems) {
deleteIncidenceFamily(c);
}
}
}
......@@ -2174,57 +2170,6 @@ void CalendarView::deleteRecurringIncidence(const Akonadi::Item &todoItem)
}
}
void CalendarView::deleteTodoIncidence(const Akonadi::Item &todoItem, bool force)
{
const KCalendarCore::Todo::Ptr todo = CalendarSupport::todo(todoItem);
if (!todo) {
return;
}
// This to-do does not own any sub-to-dos, so just ask for confirmation.
if (todo->hasRecurrenceId() || mCalendar->childItems(todoItem.id()).isEmpty()) {
bool doDelete = true;
if (!force && KOPrefs::instance()->mConfirm) {
doDelete = (msgItemDelete(todoItem) == KMessageBox::Continue);
}
if (doDelete && !mChanger->deletedRecently(todoItem.id())) {
startMultiModify(i18n("Delete parent to-do"));
deleteSubTodosIncidence(todoItem);
endMultiModify();
}
return;
}
/* Ok, this to-do has sub-to-dos, ask what to do */
int km = KMessageBox::No;
if (!force) {
km = KMessageBox::questionYesNoCancel(this,
i18n("The item \"%1\" has sub-to-dos. "
"Do you want to delete just this item and "
"make all its sub-to-dos independent, or "
"delete the to-do with all its sub-to-dos?",
todo->summary()),
i18n("KOrganizer Confirmation"),
KGuiItem(i18n("Delete Only This")),
KGuiItem(i18n("Delete All")));
}
if (km != KMessageBox::Cancel) {
// Delete only the father
if (km == KMessageBox::Yes) {
startMultiModify(i18n("Delete parent to-do"));
makeChildrenIndependent(todoItem);
} else if (km == KMessageBox::No) {
startMultiModify(i18n("Delete parent to-do and sub-to-dos"));
// Delete all
// we have to hide the delete confirmation for each itemDate
deleteChildren(todoItem);
}
deleteRecurringIncidence(todoItem);
endMultiModify();
}
}
int CalendarView::questionIndependentChildren(const Akonadi::Item &item)
{
int km;
......@@ -2257,7 +2202,7 @@ bool CalendarView::deleteIncidence(const Akonadi::Item &item, bool force)
qCCritical(KORGANIZER_LOG) << "Null incidence";
KNotification::beep();
}
qCCritical(KORGANIZER_LOG) << "CalendarView::deleteIncidence(): Unable do delete, incidence is null.";
qCCritical(KORGANIZER_LOG) << "CalendarView::deleteIncidence(): Unable to delete, incidence is null.";
return false;
}
......
......@@ -150,8 +150,6 @@ public:
return mDateNavigator;
}
// TODO_NG
// IncidenceEditors::IncidenceEditor *editorDialog( const Akonadi::Item &item ) const;
Akonadi::IncidenceChanger *incidenceChanger() const override
{
return mChanger;
......@@ -271,22 +269,22 @@ public Q_SLOTS:
void newEvent(const QDate &);
/**
create new event without having a date hint. Takes current date as
default hint.
Create an event editor dialog for a new event without having a date hint.
Uses the current date/time as defaults.
*/
void newEvent();
/**
create an editeventwin with supplied date/time, and if bool is true,
make the event take all day.
*/
void newEvent(const QDateTime &startDt);
/**
Create an event editor dialog for a new event with supplied date/times,
and if bool is true, make the event take all day.
*/
void newEvent(const QDateTime &startDt, const QDateTime &EndDt, bool allDay = false);
/**
Create new Event from given summary, description, attachment list and
attendees list
Create an event editor dialog for a new event from given summary,
description, attachment list and attendees list
*/
void newEvent(const QString &summary,
const QString &description = QString(),
......@@ -316,10 +314,13 @@ public Q_SLOTS:
void editIncidence();
/**
Delete the supplied incidence. It calls the correct deleteXXX method
@param force If true, all recurrences and sub-todos (if applicable) will be
deleted without prompting for confirmation.
@param force If true, all recurrences and sub-todos (if applicable) will be
Delete the supplied incidence, optionally after asking the user for confirmation.
If it recurs, the user can choose to delete a single recurrence, the recurrence
and all subsequent recurrences, or all recurrences.
If all recurrences are deleted, all dissociated instances will also be deleted.
If it has children (e.g. sub-todos) the children will be deleted or made
independent as the user chooses.
@param force If true, the incidence, instances, and children will be
deleted without prompting for confirmation.
*/
bool deleteIncidence(const Akonadi::Item &item, bool force = false);
......@@ -352,15 +353,11 @@ public Q_SLOTS:
*/
void pasteIncidence();
/** Delete the supplied todo and all sub-todos */
void deleteSubTodosIncidence(const Akonadi::Item &todo);
/**
Delete the todo incidence, and its sub-to-dos.
@param todo The todo to delete.
@param force If true, all sub-todos will be deleted without prompting for confirmation.
*/
void deleteTodoIncidence(const Akonadi::Item &todo, bool force = false);
Delete the supplied incidence, including any dissociated instances, and
all children (e.g. sub-todos).
*/
void deleteIncidenceFamily(const Akonadi::Item &todo);
/** create new todo */
void newTodo();
......@@ -643,7 +640,7 @@ protected:
void deleteRecurringIncidence(const Akonadi::Item& todoItem);
/** Delete the child incidences of the given incidence. */
void deleteChildren(const Akonadi::Item& todoItem);
void deleteChildren(const Akonadi::Item &);
private Q_SLOTS:
void onCheckableProxyAboutToToggle(bool newState);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment