- Urgency recalc was not properly set with the task was modified.
- Corrected urgency formatting.
- Cleaned up some code in A3 and E9.
This commit is contained in:
Paul Beckingham
2011-08-12 23:08:54 -04:00
parent 5a2fba607e
commit e238b94d1b
4 changed files with 57 additions and 35 deletions

View File

@@ -780,7 +780,6 @@ const A3 A3::tokenize (const A3& input) const
} }
} }
// TODO This may be redundant.
else if (n.getNumber (d)) else if (n.getNumber (d))
{ {
output.push_back (Arg (format (d), "num")); output.push_back (Arg (format (d), "num"));

View File

@@ -299,10 +299,9 @@ void E9::operator_lt (Term& result, Term& left, Term& right)
} }
else else
{ {
if (left._value < right._value) result._raw = result._value = (left._value < right._value)
result._raw = result._value = "true"; ? "true"
else : "fasle";
result._raw = result._value = "false";
} }
result._category = "bool"; result._category = "bool";
@@ -323,10 +322,9 @@ void E9::operator_lte (Term& result, Term& left, Term& right)
} }
else else
{ {
if (left._value <= right._value) result._raw = result._value = (left._value <= right._value)
result._raw = result._value = "true"; ? "true"
else : "fasle";
result._raw = result._value = "false";
} }
result._category = "bool"; result._category = "bool";
@@ -347,10 +345,9 @@ void E9::operator_gte (Term& result, Term& left, Term& right)
} }
else else
{ {
if (left._value >= right._value) result._raw = result._value = (left._value >= right._value)
result._raw = result._value = "true"; ? "true"
else : "fasle";
result._raw = result._value = "false";
} }
result._category = "bool"; result._category = "bool";
@@ -370,10 +367,9 @@ void E9::operator_gt (Term& result, Term& left, Term& right)
} }
else else
{ {
if (left._value > right._value) result._raw = result._value = (left._value > right._value)
result._raw = result._value = "true"; ? "true"
else : "fasle";
result._raw = result._value = "false";
} }
result._category = "bool"; result._category = "bool";
@@ -389,10 +385,9 @@ void E9::operator_inequal (
bool case_sensitive) bool case_sensitive)
{ {
operator_equal (result, left, right, case_sensitive); operator_equal (result, left, right, case_sensitive);
if (result._raw == "false") result._raw = result._value = result._raw == "false"
result._raw = result._value = "true"; ? "true"
else : "false";
result._raw = result._value = "false";
// std::cout << "# " << left << " != " << right << " --> " << result << "\n"; // std::cout << "# " << left << " != " << right << " --> " << result << "\n";
} }
@@ -434,6 +429,10 @@ void E9::operator_equal (
// Regular equality matching. // Regular equality matching.
else else
{ {
result._raw = result._value = left._value == right._value
? "true"
: "false";
if (left._value == right._value) if (left._value == right._value)
{ {
result._raw = result._value = "true"; result._raw = result._value = "true";
@@ -453,10 +452,9 @@ void E9::operator_match (
{ {
result._category = "bool"; result._category = "bool";
if (eval_match (left, right, case_sensitive)) result._raw = result._value = eval_match (left, right, case_sensitive)
result._raw = result._value = "true"; ? "true"
else : "false";
result._raw = result._value = "false";
// std::cout << "# " << left << " ~ " << right << " --> " << result << "\n"; // std::cout << "# " << left << " ~ " << right << " --> " << result << "\n";
} }
@@ -480,10 +478,9 @@ void E9::operator_nomatch (
{ {
result._category = "bool"; result._category = "bool";
if (!eval_match (left, right, case_sensitive)) result._raw = result._value = eval_match (left, right, case_sensitive)
result._raw = result._value = "true"; ? "false"
else : "true";
result._raw = result._value = "false";
// std::cout << "# " << left << " !~ " << right << " --> " << result << "\n"; // std::cout << "# " << left << " !~ " << right << " --> " << result << "\n";
} }

View File

@@ -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; // TODO i18n if (input == "pending") return Task::pending;
else if (input == "completed") return Task::completed; // TODO i18n else if (input == "completed") return Task::completed;
else if (input == "deleted") return Task::deleted; // TODO i18n else if (input == "deleted") return Task::deleted;
else if (input == "recurring") return Task::recurring; // TODO i18n else if (input == "recurring") return Task::recurring;
else if (input == "waiting") return Task::waiting; // TODO i18n else if (input == "waiting") return Task::waiting;
return Task::pending; return Task::pending;
} }
@@ -234,12 +234,16 @@ time_t Task::get_duration (const std::string& name) const
void Task::set (const std::string& name, const std::string& value) void Task::set (const std::string& name, const std::string& value)
{ {
(*this)[name] = value; (*this)[name] = value;
recalc_urgency = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Task::set (const std::string& name, int value) void Task::set (const std::string& name, int value)
{ {
(*this)[name] = format (value); (*this)[name] = format (value);
recalc_urgency = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -248,6 +252,8 @@ void Task::remove (const std::string& name)
Task::iterator it; Task::iterator it;
if ((it = this->find (name)) != this->end ()) if ((it = this->find (name)) != this->end ())
this->erase (it); this->erase (it);
recalc_urgency = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -322,6 +328,8 @@ void Task::parse (const std::string& input)
{ {
legacyParse (copy); legacyParse (copy);
} }
recalc_urgency = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -499,6 +507,8 @@ void Task::legacyParse (const std::string& line)
throw std::string (STRING_TASK_PARSE_UNREC_FF); throw std::string (STRING_TASK_PARSE_UNREC_FF);
break; break;
} }
recalc_urgency = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -758,6 +768,7 @@ void Task::addAnnotation (const std::string& description)
s << "annotation_" << time (NULL); s << "annotation_" << time (NULL);
(*this)[s.str ()] = description; (*this)[s.str ()] = description;
recalc_urgency = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -772,6 +783,8 @@ void Task::removeAnnotations ()
else else
i++; i++;
} }
recalc_urgency = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -800,6 +813,8 @@ void Task::addDependency (int id)
// Prevent circular dependencies. // Prevent circular dependencies.
if (dependencyIsCircular (*this)) if (dependencyIsCircular (*this))
throw std::string (STRING_TASK_DEPEND_CIRCULAR); throw std::string (STRING_TASK_DEPEND_CIRCULAR);
recalc_urgency = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -817,6 +832,8 @@ void Task::removeDependency (const std::string& uuid)
join (combined, ",", deps); join (combined, ",", deps);
set ("depends", combined); set ("depends", combined);
} }
recalc_urgency = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -827,6 +844,8 @@ void Task::removeDependency (int id)
removeDependency (uuid); removeDependency (uuid);
else else
throw std::string (STRING_TASK_DEPEND_NO_UUID); throw std::string (STRING_TASK_DEPEND_NO_UUID);
recalc_urgency = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -882,6 +901,8 @@ void Task::addTag (const std::string& tag)
std::string combined; std::string combined;
join (combined, ",", tags); join (combined, ",", tags);
set ("tags", combined); set ("tags", combined);
recalc_urgency = true;
} }
} }
@@ -893,6 +914,8 @@ void Task::addTags (const std::vector <std::string>& tags)
std::vector <std::string>::const_iterator it; std::vector <std::string>::const_iterator it;
for (it = tags.begin (); it != tags.end (); ++it) for (it = tags.begin (); it != tags.end (); ++it)
addTag (*it); addTag (*it);
recalc_urgency = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -916,6 +939,8 @@ void Task::removeTag (const std::string& tag)
join (combined, ",", tags); join (combined, ",", tags);
set ("tags", combined); set ("tags", combined);
} }
recalc_urgency = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -1032,6 +1057,7 @@ void Task::substitute (
{ {
set ("description", description); set ("description", description);
setAnnotations (annotations); setAnnotations (annotations);
recalc_urgency = true;
} }
} }

View File

@@ -905,7 +905,7 @@ const std::string format (
{ {
std::string output = fmt; std::string output = fmt;
replace_positional (output, "{1}", format (arg1)); replace_positional (output, "{1}", format (arg1));
replace_positional (output, "{2}", format (arg2, 6, 3)); replace_positional (output, "{2}", trim (format (arg2, 6, 3)));
return output; return output;
} }