Task: Duration handling improvements
- Separated handling for 'recur' (store in raw form) and type 'duration' attributes (store formatted). - Added missing storage handling for type duration attributes.
This commit is contained in:
25
src/Task.cpp
25
src/Task.cpp
@@ -2002,8 +2002,7 @@ void Task::modify (modType type, bool text_required /* = false */)
|
|||||||
|
|
||||||
// Special case: type duration.
|
// Special case: type duration.
|
||||||
// Note: "recur" is marked as type "string" to force storage in raw form.
|
// Note: "recur" is marked as type "string" to force storage in raw form.
|
||||||
else if (name == "recur" ||
|
else if (name == "recur")
|
||||||
column->type () == "duration")
|
|
||||||
{
|
{
|
||||||
// The duration is stored in raw form, but it must still be valid,
|
// The duration is stored in raw form, but it must still be valid,
|
||||||
// and therefore is parsed first.
|
// and therefore is parsed first.
|
||||||
@@ -2025,6 +2024,28 @@ void Task::modify (modType type, bool text_required /* = false */)
|
|||||||
throw format (STRING_TASK_INVALID_DUR, value);
|
throw format (STRING_TASK_INVALID_DUR, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (column->type () == "duration")
|
||||||
|
{
|
||||||
|
// The duration is stored in raw form, but it must still be valid,
|
||||||
|
// and therefore is parsed first.
|
||||||
|
Eval e;
|
||||||
|
e.addSource (domSource);
|
||||||
|
e.addSource (namedDates);
|
||||||
|
contextTask = *this;
|
||||||
|
|
||||||
|
Variant v;
|
||||||
|
e.evaluateInfixExpression (value, v);
|
||||||
|
if (v.type () == Variant::type_duration)
|
||||||
|
{
|
||||||
|
// Store the raw value, for 'recur'.
|
||||||
|
context.debug (label + name + " <-- " + (std::string)v + " <-- '" + value + "'");
|
||||||
|
set (name, v);
|
||||||
|
++modCount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw format (STRING_TASK_INVALID_DUR, value);
|
||||||
|
}
|
||||||
|
|
||||||
// Need handling for numeric types, used by UDAs.
|
// Need handling for numeric types, used by UDAs.
|
||||||
else if (column->type () == "numeric")
|
else if (column->type () == "numeric")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user