diff --git a/src/TDB.cpp b/src/TDB.cpp index 890c94144..d80067644 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -239,7 +239,6 @@ bool TDB::completeT (const T& t) const bool TDB::addT (const T& t) const { T task (t); - std::vector tags; task.getTags (tags); @@ -254,7 +253,8 @@ bool TDB::addT (const T& t) const } } - if (task.getStatus () == T::pending) + if (task.getStatus () == T::pending || + task.getStatus () == T::recurring) return writePending (task); return writeCompleted (task); diff --git a/src/parse.cpp b/src/parse.cpp index f69e8a8dc..0de8a0dbf 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -381,10 +381,8 @@ void parse ( std::string value = arg.substr (colon + 1, std::string::npos); if (validAttribute (name, value, conf)) - { if (name != "recur" || validDuration (value)) task.setAttribute (name, value); - } } // Substitution of description text. @@ -408,6 +406,14 @@ void parse ( } } + if (task.getAttribute ("recur") != "" && + task.getAttribute ("due") == "") + throw std::string ("You cannot specify a recurring task without a due date."); + + if (task.getAttribute ("until") != "" && + task.getAttribute ("recur") == "") + throw std::string ("You cannot specify an until date for a non-recurring task."); + if (validDescription (descCandidate)) task.setDescription (descCandidate); } diff --git a/src/rules.cpp b/src/rules.cpp index 6f2657692..4d9ccabe2 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -83,7 +83,7 @@ void initializeColorRules (Config& conf) void autoColorize (T& task, Text::color& fg, Text::color& bg) { // Note: fg, bg already contain colors specifically assigned via command. - // TODO These rules form a hierarchy - the last rule is king. + // Note: These rules form a hierarchy - the last rule is king. // Colorization of the tagged. if (gsFg["color.tagged"] != Text::nocolor || diff --git a/src/task.cpp b/src/task.cpp index a7541541b..dc023209f 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -403,6 +403,9 @@ void handleAdd (const TDB& tdb, T& task, Config& conf) sprintf (entryTime, "%u", (unsigned int) time (NULL)); task.setAttribute ("entry", entryTime); + if (task.getAttribute ("recur") != "") + decorateRecurringTask (task); + if (task.getDescription () == "") throw std::string ("Cannot add a blank task."); @@ -3356,3 +3359,15 @@ void nag (const TDB& tdb, T& task, Config& conf) } //////////////////////////////////////////////////////////////////////////////// +void decorateRecurringTask (T& task) +{ + if (task.getAttribute ("due") != "" && + task.getAttribute ("recur") != "") + { + task.setAttribute ("base", task.getAttribute ("due")); + + // TODO Create "range". + } +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/task.h b/src/task.h index 937c940ed..6d529ed50 100644 --- a/src/task.h +++ b/src/task.h @@ -87,6 +87,7 @@ void handleModify (const TDB&, T&, Config&); void handleColor (Config&); void gatherNextTasks (const TDB&, T&, Config&, std::vector &, std::vector &); void nag (const TDB&, T&, Config&); +void decorateRecurringTask (T&); // util.cpp bool confirm (const std::string&); diff --git a/src/util.cpp b/src/util.cpp index 31d153b44..877f4791a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -282,7 +282,7 @@ int convertDuration (const std::string& input) else { // Verify all digits followed by d, w, m, q, or y. - int length = input.length (); + unsigned int length = input.length (); for (unsigned int i = 0; i < length; ++i) { if (! isdigit (input[i]) &&