mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-20 04:13:07 +02:00
Task Validation
- Made the validation more gentle - it no longer stomps on the status, which may help with bug #824.
This commit is contained in:
parent
af404a5b5e
commit
cc24a3d2f0
1 changed files with 19 additions and 16 deletions
35
src/Task.cpp
35
src/Task.cpp
|
@ -108,11 +108,11 @@ Task::~Task ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Task::status Task::textToStatus (const std::string& input)
|
Task::status Task::textToStatus (const std::string& input)
|
||||||
{
|
{
|
||||||
if (input == "pending") return Task::pending;
|
if (input[0] == 'p') return Task::pending;
|
||||||
else if (input == "completed") return Task::completed;
|
else if (input[0] == 'c') return Task::completed;
|
||||||
else if (input == "deleted") return Task::deleted;
|
else if (input[0] == 'd') return Task::deleted;
|
||||||
else if (input == "recurring") return Task::recurring;
|
else if (input[0] == 'r') return Task::recurring;
|
||||||
else if (input == "waiting") return Task::waiting;
|
else if (input[0] == 'w') return Task::waiting;
|
||||||
|
|
||||||
return Task::pending;
|
return Task::pending;
|
||||||
}
|
}
|
||||||
|
@ -987,28 +987,31 @@ void Task::substitute (
|
||||||
//
|
//
|
||||||
void Task::validate ()
|
void Task::validate ()
|
||||||
{
|
{
|
||||||
|
Task::status status = getStatus ();
|
||||||
|
|
||||||
// 1) Provide missing attributes where possible
|
// 1) Provide missing attributes where possible
|
||||||
// Provide a UUID if necessary.
|
// Provide a UUID if necessary.
|
||||||
if (! has ("uuid"))
|
if (! has ("uuid"))
|
||||||
set ("uuid", uuid ());
|
set ("uuid", uuid ());
|
||||||
|
|
||||||
// Recurring tasks get a special status.
|
// Recurring tasks get a special status.
|
||||||
if (has ("due") &&
|
if (status == Task::pending &&
|
||||||
has ("recur"))
|
has ("due") &&
|
||||||
{
|
has ("recur") &&
|
||||||
if (has ("parent"))
|
! has ("parent"))
|
||||||
setStatus (Task::pending);
|
status = Task::recurring;
|
||||||
else
|
|
||||||
setStatus (Task::recurring);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tasks with a wait: date get a special status.
|
// Tasks with a wait: date get a special status.
|
||||||
else if (has ("wait"))
|
else if (status == Task::pending &&
|
||||||
setStatus (Task::waiting);
|
has ("wait"))
|
||||||
|
status = Task::waiting;
|
||||||
|
|
||||||
// By default, tasks are pending.
|
// By default, tasks are pending.
|
||||||
else if (! has ("status"))
|
else if (! has ("status"))
|
||||||
setStatus (Task::pending);
|
status = Task::pending;
|
||||||
|
|
||||||
|
// Store the derived status.
|
||||||
|
setStatus (status);
|
||||||
|
|
||||||
// Provide an entry date unless user already specified one.
|
// Provide an entry date unless user already specified one.
|
||||||
if (!has ("entry"))
|
if (!has ("entry"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue