TW-1449
- TW-1449 Nag function does not respect urgency (thanks to Tomas Babej).
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -235,4 +235,5 @@ suggestions:
|
|||||||
Black Ops Testing
|
Black Ops Testing
|
||||||
Jens Erat
|
Jens Erat
|
||||||
Leon Feng
|
Leon Feng
|
||||||
|
Tomas Babej
|
||||||
|
|
||||||
|
|||||||
@@ -183,6 +183,7 @@
|
|||||||
confirmation requests (thanks to Adam Coddington).
|
confirmation requests (thanks to Adam Coddington).
|
||||||
- TW-1441 task import continues happily if filename doesn't exist.
|
- TW-1441 task import continues happily if filename doesn't exist.
|
||||||
- TW-1444 Tag ordering is preserved, but should be sorted in reports.
|
- TW-1444 Tag ordering is preserved, but should be sorted in reports.
|
||||||
|
- TW-1449 Nag function does not respect urgency (thanks to Tomas Babej).
|
||||||
- TW-1460 Empty due dates lead to endless loop.
|
- TW-1460 Empty due dates lead to endless loop.
|
||||||
- TW-1463 A few more problems with special characters in filters, pluses,
|
- TW-1463 A few more problems with special characters in filters, pluses,
|
||||||
question marks, and braces (thanks to Ralph Bean).
|
question marks, and braces (thanks to Ralph Bean).
|
||||||
|
|||||||
@@ -406,6 +406,9 @@ void updateRecurrenceMask (Task& task)
|
|||||||
// Returns a Boolean indicator as to whether a nag message was generated, so
|
// Returns a Boolean indicator as to whether a nag message was generated, so
|
||||||
// that commands can control the number of nag messages displayed (ie one is
|
// that commands can control the number of nag messages displayed (ie one is
|
||||||
// enough).
|
// enough).
|
||||||
|
//
|
||||||
|
// Otherwise generates a nag message, if one is defined, if there are tasks of
|
||||||
|
// higher urgency.
|
||||||
bool nag (Task& task)
|
bool nag (Task& task)
|
||||||
{
|
{
|
||||||
// Special tag overrides nagging.
|
// Special tag overrides nagging.
|
||||||
@@ -418,56 +421,16 @@ bool nag (Task& task)
|
|||||||
// Load all pending tasks.
|
// Load all pending tasks.
|
||||||
std::vector <Task> tasks = context.tdb2.pending.get_tasks ();
|
std::vector <Task> tasks = context.tdb2.pending.get_tasks ();
|
||||||
|
|
||||||
// Counters.
|
|
||||||
int overdue = 0;
|
|
||||||
int high = 0;
|
|
||||||
int medium = 0;
|
|
||||||
int low = 0;
|
|
||||||
bool isOverdue = false;
|
|
||||||
char pri = ' ';
|
|
||||||
|
|
||||||
// Scan all pending tasks.
|
// Scan all pending tasks.
|
||||||
std::vector <Task>::iterator t;
|
std::vector <Task>::iterator t;
|
||||||
for (t = tasks.begin (); t != tasks.end (); ++t)
|
for (t = tasks.begin (); t != tasks.end (); ++t)
|
||||||
{
|
{
|
||||||
if (t->id == task.id)
|
if (t->urgency () > task.urgency ())
|
||||||
{
|
{
|
||||||
if (t->getDateState ("due") == Task::dateBeforeToday)
|
context.footnote (nagMessage);
|
||||||
isOverdue = true;
|
return true;
|
||||||
|
|
||||||
std::string priority = t->get ("priority");
|
|
||||||
if (priority.length ())
|
|
||||||
pri = priority[0];
|
|
||||||
}
|
|
||||||
else if (t->getStatus () == Task::pending)
|
|
||||||
{
|
|
||||||
if (t->getDateState ("due") == Task::dateBeforeToday)
|
|
||||||
overdue++;
|
|
||||||
|
|
||||||
std::string priority = t->get ("priority");
|
|
||||||
if (priority.length ())
|
|
||||||
{
|
|
||||||
switch (priority[0])
|
|
||||||
{
|
|
||||||
case 'H': high++; break;
|
|
||||||
case 'M': medium++; break;
|
|
||||||
case 'L': low++; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// General form is "if there are no more deserving tasks", suppress the nag.
|
|
||||||
if (isOverdue ) return false;
|
|
||||||
if (pri == 'H' && !overdue ) return false;
|
|
||||||
if (pri == 'M' && !overdue && !high ) return false;
|
|
||||||
if (pri == 'L' && !overdue && !high && !medium ) return false;
|
|
||||||
if (pri == ' ' && !overdue && !high && !medium && !low ) return false;
|
|
||||||
if (task.is_blocking && !task.is_blocked ) return false;
|
|
||||||
|
|
||||||
// All the excuses are made, all that remains is to nag the user.
|
|
||||||
context.footnote (nagMessage);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user