Clean up annotation details

- changed variable name from annotation.details to annotations
- added report.X.annotations
- changed values from 2, 1, 0 to full, sparse, none
- made reportdateformat available in timesheet
This commit is contained in:
Federico Hernandez 2010-01-19 00:46:25 +01:00
parent fccd0d6c96
commit ab86490b37
7 changed files with 63 additions and 30 deletions

View file

@ -116,8 +116,10 @@ May be "yes" or "no", and determines whether task will ask for confirmation befo
May be "yes" or "no", and causes task to display the ID and description of any task when you run the start, stop, do, undo or delete commands. The default value is "yes".
.TP
.B annotation.details=2
Controls the output of annotations in reports. Defaults to 2 - all annotations are displayed. Set to 1 only the last (youngest) annotation is displayed and if there are more than one present for a task a "+" sign is added to the description. Set to 0 the output of annotations is disabled and a "+" sign will be added if there are any annotations present.
.B annotations=full
.TP
.B report.X.annotations=full
Controls the output of annotations in reports. Defaults to full - all annotations are displayed. Set to "sparse" only the last (youngest) annotation is displayed and if there are more than one present for a task a "+" sign is added to the description. Set to "none" the output of annotations is disabled and a "+" sign will be added if there are any annotations present.
.TP
.B next=2
@ -470,6 +472,13 @@ it is not set then reportdateformat and dateformat will be used in this order. S
.B DATES
section for details on the sequence placeholders.
.TP
.B report.X.annotations
GThis adds the possibility to control the output of annotations for a task in a report. See
the
.B annotations
variable for details on the possible values.
.TP
.B report.X.limit
An optional value to a report limiting the number of displayed tasks in the

View file

@ -59,7 +59,7 @@ std::string Config::defaults =
"# Miscellaneous\n"
"confirmation=yes # Confirmation on delete, big changes\n"
"echo.command=yes # Details on command just run\n"
"annotation.details=2 # Level of verbosity for annotations in reports\n"
"annotations=full # Level of verbosity for annotations in reports\n"
"next=2 # How many tasks per project in next report\n"
"bulk=2 # > 2 tasks considered 'a lot', for confirmation\n"
"nag=You have higher priority tasks. # Nag message to keep you honest\n" // TODO
@ -153,6 +153,7 @@ std::string Config::defaults =
"report.long.sort=due+,priority-,project+\n"
"report.long.filter=status:pending\n"
"#report.long.dateformat=m/d/Y\n"
"#report.long.annotations=full\n"
"\n"
"# task list\n"
"report.list.description=Lists all tasks matching the specified criteria\n"
@ -161,6 +162,7 @@ std::string Config::defaults =
"report.list.sort=due+,priority-,project+\n"
"report.list.filter=status:pending\n"
"#report.list.dateformat=m/d/Y\n"
"#report.list.annotations=full\n"
"\n"
"# task ls\n"
"report.ls.description=Minimal listing of all tasks matching the specified criteria\n"
@ -169,6 +171,7 @@ std::string Config::defaults =
"report.ls.sort=priority-,project+\n"
"report.ls.filter=status:pending\n"
"#report.ls.dateformat=m/d/Y\n"
"#report.ls.annotations=full\n"
"\n"
"# task minimal\n"
"report.minimal.description=A really minimal listing\n"
@ -177,6 +180,7 @@ std::string Config::defaults =
"report.minimal.sort=project+,description+\n"
"report.minimal.filter=status:pending\n"
"#report.minimal.dateformat=m/d/Y\n"
"#report.minimal.annotations=full\n"
"\n"
"# task newest\n"
"report.newest.description=Shows the newest tasks\n"
@ -185,6 +189,7 @@ std::string Config::defaults =
"report.newest.sort=id-\n"
"report.newest.filter=status:pending limit:10\n"
"#report.newest.dateformat=m/d/Y\n"
"#report.newest.annotations=full\n"
"\n"
"# task oldest\n"
"report.oldest.description=Shows the oldest tasks\n"
@ -193,6 +198,7 @@ std::string Config::defaults =
"report.oldest.sort=id+\n"
"report.oldest.filter=status:pending limit:10\n"
"#report.oldest.dateformat=m/d/Y\n"
"#report.oldest.annotations=full\n"
"\n"
"# task overdue\n"
"report.overdue.description=Lists overdue tasks matching the specified criteria\n"
@ -201,6 +207,7 @@ std::string Config::defaults =
"report.overdue.sort=due+,priority-,project+\n"
"report.overdue.filter=status:pending due.before:today\n"
"#report.overdue.dateformat=m/d/Y\n"
"#report.overdue.annotations=full\n"
"\n"
"# task active\n"
"report.active.description=Lists active tasks matching the specified criteria\n"
@ -209,6 +216,7 @@ std::string Config::defaults =
"report.active.sort=due+,priority-,project+\n"
"report.active.filter=status:pending start.any:\n"
"#report.active.dateformat=m/d/Y\n"
"#report.active.annotations=full\n"
"\n"
"# task completed\n"
"report.completed.description=Lists completed tasks matching the specified criteria\n"
@ -217,6 +225,7 @@ std::string Config::defaults =
"report.completed.sort=end+,priority-,project+\n"
"report.completed.filter=status:completed\n"
"#report.completed.dateformat=m/d/Y\n"
"#report.completed.annotations=full\n"
"\n"
"# task recurring\n"
"report.recurring.description=Lists recurring tasks matching the specified criteria\n"
@ -225,6 +234,7 @@ std::string Config::defaults =
"report.recurring.sort=due+,priority-,project+\n"
"report.recurring.filter=status:pending parent.any:\n"
"#report.recurring.dateformat=m/d/Y\n"
"#report.recurring.annotations=full\n"
"\n"
"# task waiting\n"
"report.waiting.description=Lists all waiting tasks matching the specified criteria\n"
@ -233,6 +243,7 @@ std::string Config::defaults =
"report.waiting.sort=wait+,priority-,project+\n"
"report.waiting.filter=status:waiting\n"
"#report.waiting.dateformat=m/d/Y\n"
"#report.waiting.annotations=full\n"
"\n"
"# task all\n"
"report.all.description=Lists all tasks matching the specified criteria\n"
@ -240,6 +251,7 @@ std::string Config::defaults =
"report.all.labels=ID,Project,Pri,Due,Active,Age,Description\n"
"report.all.sort=due+,priority-,project+\n"
"#report.all.dateformat=m/d/Y\n"
"#report.all.annotations=full\n"
"\n"
"# task next\n"
"report.next.description=Lists the most urgent tasks\n"
@ -248,6 +260,7 @@ std::string Config::defaults =
"report.next.sort=due+,priority-,project+\n"
"report.next.filter=status:pending\n"
"#report.next.dateformat=m/d/Y\n"
"#report.next.annotations=full\n"
"\n";
////////////////////////////////////////////////////////////////////////////////

View file

@ -649,7 +649,7 @@ int handleConfig (std::string &outs)
// These are the regular configuration variables.
// Note that there is a leading and trailing space, to make searching easier.
std::string recognized =
" annotation.details blanklines bulk calendar.details calendar.details.report color "
" annotations blanklines bulk calendar.details calendar.details.report color "
"color.active color.due color.overdue color.pri.H color.pri.L color.pri.M color.pri.none "
"color.recurring color.tagged color.footnote color.header color.debug color.alternate "
"color.calendar.today color.calendar.due color.calendar.overdue color.calendar.weekend "

View file

@ -464,7 +464,7 @@ int runCustomReport (
int row = 0;
foreach (task, tasks)
table.addCell (row++, columnCount, getFullDescription (*task));
table.addCell (row++, columnCount, getFullDescription (*task, report));
}
else if (*col == "recur")

View file

@ -102,7 +102,7 @@ int handleReportGHistory (std::string &);
int handleReportCalendar (std::string &);
int handleReportStats (std::string &);
int handleReportTimesheet (std::string &);
std::string getFullDescription (Task&);
std::string getFullDescription (Task&, const std::string&);
std::string getDueDate (Task&, const std::string&);
// custom.cpp

View file

@ -353,7 +353,7 @@ int handleInfo (std::string &outs)
row = table.addRow ();
table.addCell (row, 0, "Description");
table.addCell (row, 1, getFullDescription (*task));
table.addCell (row, 1, getFullDescription (*task, "info"));
if (task->has ("project"))
{
@ -1223,9 +1223,12 @@ int handleReportTimesheet (std::string &outs)
if (compDate >= start && compDate < end)
{
int row = completed.addRow ();
std::string format = context.config.get ("reportdateformat");
if (format == "")
format = context.config.get ("dateformat");
completed.addCell (row, 1, task->get ("project"));
completed.addCell (row, 2, getDueDate (*task, context.config.get("dateformat")));
completed.addCell (row, 3, getFullDescription (*task));
completed.addCell (row, 2, getDueDate (*task, format));
completed.addCell (row, 3, getFullDescription (*task, "timesheet"));
if (color)
{
@ -1279,9 +1282,12 @@ int handleReportTimesheet (std::string &outs)
if (startDate >= start && startDate < end)
{
int row = started.addRow ();
std::string format = context.config.get ("reportdateformat");
if (format == "")
format = context.config.get ("dateformat");
started.addCell (row, 1, task->get ("project"));
started.addCell (row, 2, getDueDate (*task, context.config.get ("dateformat")));
started.addCell (row, 3, getFullDescription (*task));
started.addCell (row, 2, getDueDate (*task, format));
started.addCell (row, 3, getFullDescription (*task, "timesheet"));
if (color)
{
@ -2109,38 +2115,43 @@ void gatherNextTasks (std::vector <Task>& tasks)
}
///////////////////////////////////////////////////////////////////////////////
std::string getFullDescription (Task& task)
std::string getFullDescription (Task& task, const std::string& report)
{
std::string desc = task.get ("description");
std::string annotationDetails;
std::vector <Att> annotations;
task.getAnnotations (annotations);
if (annotations.size () != 0)
switch (context.config.getInteger ("annotation.details"))
{
std::string annotationDetails = context.config.get ("report." + report + ".annotations");
if (annotationDetails == "")
annotationDetails = context.config.get ("annotations");
if (report == "info")
annotationDetails = "full";
if (annotationDetails == "none")
{
case 0:
desc = "+" + desc;
break;
case 1:
{
if (annotations.size () > 1)
desc = "+" + desc;
Att anno (annotations.back());
Date dt (atoi (anno.name ().substr (11).c_str ()));
std::string when = dt.toString (context.config.get ("dateformat"));
desc += "\n" + when + " " + anno.value ();
}
break;
case 2:
}
else if (annotationDetails == "sparse")
{
if (annotations.size () > 1)
desc = "+" + desc;
Att anno (annotations.back());
Date dt (atoi (anno.name ().substr (11).c_str ()));
std::string when = dt.toString (context.config.get ("dateformat"));
desc += "\n" + when + " " + anno.value ();
}
else
foreach (anno, annotations)
{
Date dt (atoi (anno->name ().substr (11).c_str ()));
std::string when = dt.toString (context.config.get ("dateformat"));
desc += "\n" + when + " " + anno->value ();
}
break;
}
}
return desc;
}

View file

@ -89,7 +89,7 @@ like ($output, qr/bar1.+\d{1,2}\/\d{1,2}\/\d{4} bar2/ms, 'second annotation task
like ($output, qr/three.+\d{1,2}\/\d{1,2}\/\d{4} baz1/ms,'first annotation task 3');
like ($output, qr/4 tasks/, 'count');
$output = qx{../task rc:annotate.rc rc.annotation.details:1 rrr};
$output = qx{../task rc:annotate.rc rc.annotations:sparse rrr};
like ($output, qr/1 \+one/, 'task 1');
like ($output, qr/2 \+two/, 'task 2');
like ($output, qr/3 three/, 'task 3');
@ -102,7 +102,7 @@ like ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar2/ms, 'second annotation t
like ($output, qr/three.+\d{1,2}\/\d{1,2}\/\d{4} baz1/ms, 'third annotation task 3');
like ($output, qr/4 tasks/, 'count');
$output = qx{../task rc:annotate.rc rc.annotation.details:0 rrr};
$output = qx{../task rc:annotate.rc rc.annotations:none rrr};
like ($output, qr/1 \+one/, 'task 1');
like ($output, qr/2 \+two/, 'task 2');
like ($output, qr/3 \+three/, 'task 3');