From e5303a2180002c9921401fc3c24bd7ad7527f8a5 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 23 Oct 2011 23:49:25 -0400 Subject: [PATCH] Deletion - An already-completed task may now also be deleted. - Added unit tests. --- src/TDB2.cpp | 21 +++++++-------------- src/TDB2.h | 2 +- test/delete.t | 12 +++++++++++- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 468bf48bf..76dc99d75 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -145,7 +145,7 @@ void TF2::add_task (const Task& task) } //////////////////////////////////////////////////////////////////////////////// -void TF2::modify_task (const Task& task) +bool TF2::modify_task (const Task& task) { // Modify in-place. std::string uuid = task.get ("uuid"); @@ -155,12 +155,13 @@ void TF2::modify_task (const Task& task) if (i->get ("uuid") == uuid) { *i = task; - break; + _modified_tasks.push_back (task); + _dirty = true; + return true; } } - _modified_tasks.push_back (task); - _dirty = true; + return false; } //////////////////////////////////////////////////////////////////////////////// @@ -522,17 +523,9 @@ void TDB2::modify (Task& task) if (taskDiff (original, task)) { - std::string status = original.get ("status"); - if (status == "pending" || - status == "waiting" || - status == "recurring") - { - pending.modify_task (task); - } - else - { + // Update the task, wherever it is. + if (!pending.modify_task (task)) completed.modify_task (task); - } // time