mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
2 new report columns
- countdown and countdown_compact
This commit is contained in:
parent
e80769794e
commit
883e264319
4 changed files with 60 additions and 3 deletions
|
@ -33,6 +33,9 @@
|
|||
+ The 'entry', 'start' and 'end' columns now have equivalents that include the
|
||||
time, and are called 'entry_time', 'start_time', and 'end_time', for use in
|
||||
custom reports.
|
||||
+ 2 new columns have been added to the reports: countdown and countdown_compact.
|
||||
They show the days left until a task is due or how many days a task has been
|
||||
overdue.
|
||||
+ The new 'priority_long' field can be shown in custom reports, and will
|
||||
display 'High' rather than the abbreviated 'H'.
|
||||
+ Task now supports .taskrc command line overrides using rc.name:value and
|
||||
|
|
|
@ -153,7 +153,7 @@ std::string Config::defaults =
|
|||
"# Fields: id,uuid,project,priority,priority_long,entry,entry_time,\n" // TODO
|
||||
"# start,entry_time,due,recur,recurrence_indicator,age,\n" // TODO
|
||||
"# age_compact,active,tags,tag_indicator,description,\n" // TODO
|
||||
"# description_only,end,end_time\n" // TODO
|
||||
"# description_only,end,end_time,countdown,countdown_compact\n" // TODO
|
||||
"# Description: This report is ...\n"
|
||||
"# Sort: due+,priority-,project+\n"
|
||||
"# Filter: pro:x pri:H +bug limit:10\n"
|
||||
|
@ -161,8 +161,8 @@ std::string Config::defaults =
|
|||
"\n"
|
||||
"# task long\n"
|
||||
"report.long.description=Lists all task, all data, matching the specified criteria\n"
|
||||
"report.long.columns=id,project,priority,entry,start,due,recur,age,tags,description\n"
|
||||
"report.long.labels=ID,Project,Pri,Added,Started,Due,Recur,Age,Tags,Description\n"
|
||||
"report.long.columns=id,project,priority,entry,start,due,recur,countdown,age,tags,description\n"
|
||||
"report.long.labels=ID,Project,Pri,Added,Started,Due,Recur,Countdown,Age,Tags,Description\n"
|
||||
"report.long.sort=due+,priority-,project+\n"
|
||||
"report.long.filter=status:pending\n"
|
||||
"#report.long.dateformat=m/d/Y\n"
|
||||
|
|
|
@ -361,6 +361,8 @@ bool Hooks::validFieldEvent (const std::string& event)
|
|||
event == "format-end" ||
|
||||
event == "format-end_time" ||
|
||||
event == "format-due" ||
|
||||
event == "format-countdown" ||
|
||||
event == "format-countdown_compact" ||
|
||||
event == "format-age" ||
|
||||
event == "format-age_compact" ||
|
||||
event == "format-active" ||
|
||||
|
|
|
@ -409,6 +409,56 @@ int runCustomReport (
|
|||
dueColumn = columnCount;
|
||||
}
|
||||
|
||||
else if (*col == "countdown")
|
||||
{
|
||||
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Countdown");
|
||||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
std::string due;
|
||||
std::string countdown;
|
||||
Date now;
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
due = tasks[row].get ("due");
|
||||
if (due.length ())
|
||||
{
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
time_t cntdwn = (time_t) (now - dt);
|
||||
countdown = formatSeconds ( cntdwn < 0 ? cntdwn * -1 : cntdwn );
|
||||
if ( cntdwn < 0 )
|
||||
countdown = std::string("- ") + countdown;
|
||||
context.hooks.trigger ("format-countdown", "countdown", countdown);
|
||||
table.addCell (row, columnCount, countdown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (*col == "countdown_compact")
|
||||
{
|
||||
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Countdown");
|
||||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
std::string due;
|
||||
std::string countdown;
|
||||
Date now;
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
due = tasks[row].get ("due");
|
||||
if (due.length ())
|
||||
{
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
time_t cntdwn = (time_t) (now - dt);
|
||||
countdown = formatSecondsCompact ( cntdwn < 0 ? cntdwn * -1 : cntdwn );
|
||||
if ( cntdwn < 0 )
|
||||
countdown = std::string("- ") + countdown;
|
||||
context.hooks.trigger ("format-countdown_compact", "countdown_compact", countdown);
|
||||
table.addCell (row, columnCount, countdown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (*col == "age")
|
||||
{
|
||||
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Age");
|
||||
|
@ -700,6 +750,8 @@ void validReportColumns (const std::vector <std::string>& columns)
|
|||
*it != "end" &&
|
||||
*it != "end_time" &&
|
||||
*it != "due" &&
|
||||
*it != "countdown" &&
|
||||
*it != "countdown_compact" &&
|
||||
*it != "age" &&
|
||||
*it != "age_compact" &&
|
||||
*it != "active" &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue