From 612b872ed49be84d9d9a86151517ddb5d39c70ca Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 14 May 2009 00:46:52 -0400 Subject: [PATCH] Silver Bullet - Complete - Entry works - Start works - End works --- src/edit.cpp | 59 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/src/edit.cpp b/src/edit.cpp index 291b41156..8f1d76066 100644 --- a/src/edit.cpp +++ b/src/edit.cpp @@ -238,13 +238,12 @@ static void parseTask (Config& conf, T& task, const std::string& after) } // entry -/* value = findDate (conf, after, "Created:"); if (value != "") { - Date original (::atoi (task.getAttribute ("entry").c_str ())); Date edited (::atoi (value.c_str ())); + Date original (::atoi (task.getAttribute ("entry").c_str ())); if (!original.sameDay (edited)) { std::cout << "Creation date modified." << std::endl; @@ -252,18 +251,24 @@ static void parseTask (Config& conf, T& task, const std::string& after) } } else - std::cout << "Cannot remove creation date." << std::endl; -*/ + throw std::string ("Cannot remove creation date"); // start -/* - value = findDate (conf, after, "Start:"); + value = findDate (conf, after, "Started:"); if (value != "") { - Date original (::atoi (task.getAttribute ("start").c_str ())); Date edited (::atoi (value.c_str ())); - if (!original.sameDay (edited)) + if (task.getAttribute ("start") != "") + { + Date original (::atoi (task.getAttribute ("start").c_str ())); + if (!original.sameDay (edited)) + { + std::cout << "Start date modified." << std::endl; + task.setAttribute ("start", value); + } + } + else { std::cout << "Start date modified." << std::endl; task.setAttribute ("start", value); @@ -271,36 +276,40 @@ static void parseTask (Config& conf, T& task, const std::string& after) } else { - Date original (::atoi (task.getAttribute ("start").c_str ())); - Date edited (::atoi (value.c_str ())); - - if (!original.sameDay (edited)) + if (task.getAttribute ("start") != "") { + std::cout << "Start date removed." << std::endl; + task.removeAttribute ("start"); } - - std::cout << "Cannot remove start date." << std::endl; } -*/ + // end -/* value = findDate (conf, after, "Ended:"); if (value != "") { - Date original (::atoi (task.getAttribute ("end").c_str ())); Date edited (::atoi (value.c_str ())); - if (!original.sameDay (edited)) + if (task.getAttribute ("end") != "") { - std::cout << "Done date modified." << std::endl; - task.setAttribute ("end", value); + Date original (::atoi (task.getAttribute ("end").c_str ())); + if (!original.sameDay (edited)) + { + std::cout << "Done date modified." << std::endl; + task.setAttribute ("end", value); + } } + else if (task.getStatus () != T::deleted) + throw std::string ("Cannot set a done date on a pending task."); } else { - std::cout << "Done date removed." << std::endl; - task.removeAttribute ("end"); + if (task.getAttribute ("end") != "") + { + std::cout << "Done date removed." << std::endl; + task.setStatus (T::pending); + task.removeAttribute ("end"); + } } -*/ // due value = findDate (conf, after, "Due:"); @@ -393,7 +402,11 @@ static void parseTask (Config& conf, T& task, const std::string& after) else { std::cout << "Recurrence removed." << std::endl; + task.setStatus (T::pending); task.removeAttribute ("recur"); + task.removeAttribute ("until"); + task.removeAttribute ("mask"); + task.removeAttribute ("imask"); } }