From 1712ad2cde671f77f91630b70d93742896cd0210 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 6 Jul 2008 02:01:51 -0400 Subject: [PATCH] - "task delete" now properly supports recurring tasks. --- src/task.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/task.cpp b/src/task.cpp index 373ba0557..099bb150f 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -2943,7 +2943,29 @@ void handleVersion (Config& conf) void handleDelete (const TDB& tdb, T& task, Config& conf) { if (conf.get ("confirmation") != "yes" || confirm ("Permanently delete task?")) - tdb.deleteT (task); + { + // Check for the more complex case of a recurring task. + std::string parent = task.getAttribute ("parent"); + + // If this is a recurring task, get confirmation to delete them all. + if (parent != "" && + confirm ("This is a recurring task. Do you want to delete all pending recurrences of this same task?")) + { + // Scan all pending tasks for siblings of this task, and the parent + // itself, and delete them. + std::vector all; + tdb.allPendingT (all); + std::vector ::iterator it; + for (it = all.begin (); it != all.end (); ++it) + if (it->getAttribute ("parent") == parent || + it->getUUID () == parent) + tdb.deleteT (*it); + } + + // No confirmation, just delete the one. + else + tdb.deleteT (task); + } else std::cout << "Task not deleted." << std::endl; }