Enhancement - nag

- Improved nagging with respect to multiple tasks.
This commit is contained in:
Paul Beckingham 2009-06-20 13:55:11 -04:00
parent f5e0f8b7a6
commit 344b1aba58
3 changed files with 16 additions and 9 deletions

View file

@ -568,6 +568,7 @@ std::string handleStart ()
// Filter sequence. // Filter sequence.
context.filter.applySequence (tasks, context.sequence); context.filter.applySequence (tasks, context.sequence);
bool nagged = false;
foreach (task, tasks) foreach (task, tasks)
{ {
if (! task->has ("start")) if (! task->has ("start"))
@ -585,7 +586,8 @@ std::string handleStart ()
<< task->get ("description") << task->get ("description")
<< "'" << "'"
<< std::endl; << std::endl;
nag (*task); if (!nagged)
nagged = nag (*task);
} }
else else
{ {
@ -664,6 +666,7 @@ std::string handleDone ()
std::vector <Task> all = tasks; std::vector <Task> all = tasks;
context.filter.applySequence (tasks, context.sequence); context.filter.applySequence (tasks, context.sequence);
bool nagged = false;
foreach (task, tasks) foreach (task, tasks)
{ {
if (task->getStatus () == Task::pending) if (task->getStatus () == Task::pending)
@ -692,7 +695,8 @@ std::string handleDone ()
<< std::endl; << std::endl;
updateRecurrenceMask (all, *task); updateRecurrenceMask (all, *task);
nag (*task); if (!nagged)
nagged = nag (*task);
++count; ++count;
} }

View file

@ -53,7 +53,7 @@ Date getNextRecurrence (Date&, std::string&);
bool generateDueDates (Task&, std::vector <Date>&); bool generateDueDates (Task&, std::vector <Date>&);
void updateRecurrenceMask (std::vector <Task>&, Task&); void updateRecurrenceMask (std::vector <Task>&, Task&);
int getDueState (const std::string&); int getDueState (const std::string&);
void nag (Task&); bool nag (Task&);
// command.cpp // command.cpp
std::string handleAdd (); std::string handleAdd ();

View file

@ -397,7 +397,7 @@ int getDueState (const std::string& due)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void nag (Task& task) bool nag (Task& task)
{ {
std::string nagMessage = context.config.get ("nag", ""); std::string nagMessage = context.config.get ("nag", "");
if (nagMessage != "") if (nagMessage != "")
@ -448,15 +448,18 @@ void nag (Task& task)
} }
// General form is "if there are no more deserving tasks", suppress the nag. // General form is "if there are no more deserving tasks", suppress the nag.
if (isOverdue ) return; if (isOverdue ) return false;
if (pri == 'H' && !overdue ) return; if (pri == 'H' && !overdue ) return false;
if (pri == 'M' && !overdue && !high ) return; if (pri == 'M' && !overdue && !high ) return false;
if (pri == 'L' && !overdue && !high && !medium ) return; if (pri == 'L' && !overdue && !high && !medium ) return false;
if (pri == ' ' && !overdue && !high && !medium && !low) return; if (pri == ' ' && !overdue && !high && !medium && !low) return false;
// All the excuses are made, all that remains is to nag the user. // All the excuses are made, all that remains is to nag the user.
context.message (nagMessage); context.message (nagMessage);
return true;
} }
return false;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////