diff --git a/ChangeLog b/ChangeLog index e45eac57d..98c334bda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/Config.cpp b/src/Config.cpp index b12fddbdb..58a745de6 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -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" diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 41256639c..f3012e2b7 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -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" || diff --git a/src/custom.cpp b/src/custom.cpp index ddf45eb36..82aa7ff5c 100644 --- a/src/custom.cpp +++ b/src/custom.cpp @@ -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 & columns) *it != "end" && *it != "end_time" && *it != "due" && + *it != "countdown" && + *it != "countdown_compact" && *it != "age" && *it != "age_compact" && *it != "active" &&