mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-04 21:38:35 +02:00
View
- Converted info report to ViewText. - Fixed bug in history report. - Removed rc.blanklines from Config.cpp defaults.
This commit is contained in:
parent
c1b4f34a70
commit
9e3e40c3a9
3 changed files with 91 additions and 120 deletions
|
@ -253,7 +253,6 @@ std::string Config::defaults =
|
||||||
"default.command=list # When no arguments are specified\n"
|
"default.command=list # When no arguments are specified\n"
|
||||||
"\n"
|
"\n"
|
||||||
"_forcecolor=no # Forces color to be on, even for non TTY output\n"
|
"_forcecolor=no # Forces color to be on, even for non TTY output\n"
|
||||||
"blanklines=true # Use more whitespace in output\n"
|
|
||||||
"complete.all.projects=no # Include old project names in '_projects' command\n"
|
"complete.all.projects=no # Include old project names in '_projects' command\n"
|
||||||
"complete.all.tags=no # Include old tag names in '_ags' command\n"
|
"complete.all.tags=no # Include old tag names in '_ags' command\n"
|
||||||
"list.all.projects=no # Include old project names in 'projects' command\n"
|
"list.all.projects=no # Include old project names in 'projects' command\n"
|
||||||
|
|
|
@ -149,7 +149,8 @@ int handleReportHistoryMonthly (std::string& outs)
|
||||||
|
|
||||||
if (view.rows ())
|
if (view.rows ())
|
||||||
{
|
{
|
||||||
view.addRow ();
|
row = view.addRow ();
|
||||||
|
view.set (row, 0, " ");
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
|
|
||||||
Color row_color;
|
Color row_color;
|
||||||
|
|
207
src/report.cpp
207
src/report.cpp
|
@ -395,63 +395,55 @@ int handleInfo (std::string& outs)
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++task)
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
Table table;
|
ViewText view;
|
||||||
table.setTableWidth (context.getWidth ());
|
view.width (context.getWidth ());
|
||||||
table.setDateFormat (context.config.get ("dateformat"));
|
view.add (Column::factory ("string", "Name"));
|
||||||
|
view.add (Column::factory ("string", "Value"));
|
||||||
|
|
||||||
table.addColumn ("Name");
|
// If an alternating row color is specified, notify the table.
|
||||||
table.addColumn ("Value");
|
if (context.color ())
|
||||||
|
|
||||||
if (context.color () && context.config.getBoolean ("fontunderline"))
|
|
||||||
{
|
{
|
||||||
table.setColumnUnderline (0);
|
Color alternate (context.config.get ("color.alternate"));
|
||||||
table.setColumnUnderline (1);
|
view.colorOdd (alternate);
|
||||||
|
view.intraColorOdd (alternate);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
table.setTableDashedUnderline ();
|
|
||||||
|
|
||||||
table.setColumnWidth (0, Table::minimum);
|
|
||||||
table.setColumnWidth (1, Table::flexible);
|
|
||||||
|
|
||||||
table.setColumnJustification (0, Table::left);
|
|
||||||
table.setColumnJustification (1, Table::left);
|
|
||||||
Date now;
|
Date now;
|
||||||
|
|
||||||
// id
|
// id
|
||||||
int row = table.addRow ();
|
int row = view.addRow ();
|
||||||
table.addCell (row, 0, "ID");
|
view.set (row, 0, "ID");
|
||||||
table.addCell (row, 1, format (task->id));
|
view.set (row, 1, format (task->id));
|
||||||
|
|
||||||
std::string status = ucFirst (Task::statusToText (task->getStatus ()));
|
std::string status = ucFirst (Task::statusToText (task->getStatus ()));
|
||||||
|
|
||||||
// description
|
// description
|
||||||
row = table.addRow ();
|
|
||||||
table.addCell (row, 0, "Description");
|
|
||||||
table.addCell (row, 1, getFullDescription (*task, "info"));
|
|
||||||
|
|
||||||
Color c;
|
Color c;
|
||||||
autoColorize (*task, c);
|
autoColorize (*task, c);
|
||||||
table.setCellColor (row, 1, c);
|
|
||||||
|
row = view.addRow ();
|
||||||
|
view.set (row, 0, "Description");
|
||||||
|
view.set (row, 1, getFullDescription (*task, "info"), c);
|
||||||
|
|
||||||
// status
|
// status
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Status");
|
view.set (row, 0, "Status");
|
||||||
table.addCell (row, 1, status);
|
view.set (row, 1, status);
|
||||||
|
|
||||||
// project
|
// project
|
||||||
if (task->has ("project"))
|
if (task->has ("project"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Project");
|
view.set (row, 0, "Project");
|
||||||
table.addCell (row, 1, task->get ("project"));
|
view.set (row, 1, task->get ("project"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// priority
|
// priority
|
||||||
if (task->has ("priority"))
|
if (task->has ("priority"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Priority");
|
view.set (row, 0, "Priority");
|
||||||
table.addCell (row, 1, task->get ("priority"));
|
view.set (row, 1, task->get ("priority"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// dependencies: blocked
|
// dependencies: blocked
|
||||||
|
@ -465,9 +457,9 @@ int handleInfo (std::string& outs)
|
||||||
for (it = blocked.begin (); it != blocked.end (); ++it)
|
for (it = blocked.begin (); it != blocked.end (); ++it)
|
||||||
message << it->id << " " << it->get ("description") << "\n";
|
message << it->id << " " << it->get ("description") << "\n";
|
||||||
|
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "This task blocked by");
|
view.set (row, 0, "This task blocked by");
|
||||||
table.addCell (row, 1, message.str ());
|
view.set (row, 1, message.str ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,25 +474,25 @@ int handleInfo (std::string& outs)
|
||||||
for (it = blocking.begin (); it != blocking.end (); ++it)
|
for (it = blocking.begin (); it != blocking.end (); ++it)
|
||||||
message << it->id << " " << it->get ("description") << "\n";
|
message << it->id << " " << it->get ("description") << "\n";
|
||||||
|
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "This task is blocking");
|
view.set (row, 0, "This task is blocking");
|
||||||
table.addCell (row, 1, message.str ());
|
view.set (row, 1, message.str ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// recur
|
// recur
|
||||||
if (task->has ("recur"))
|
if (task->has ("recur"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Recurrence");
|
view.set (row, 0, "Recurrence");
|
||||||
table.addCell (row, 1, task->get ("recur"));
|
view.set (row, 1, task->get ("recur"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// until
|
// until
|
||||||
if (task->has ("until"))
|
if (task->has ("until"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Recur until");
|
view.set (row, 0, "Recur until");
|
||||||
|
|
||||||
Date dt (atoi (task->get ("until").c_str ()));
|
Date dt (atoi (task->get ("until").c_str ()));
|
||||||
std::string format = context.config.get ("reportdateformat");
|
std::string format = context.config.get ("reportdateformat");
|
||||||
|
@ -508,68 +500,68 @@ int handleInfo (std::string& outs)
|
||||||
format = context.config.get ("dateformat");
|
format = context.config.get ("dateformat");
|
||||||
|
|
||||||
std::string until = getDueDate (*task, format);
|
std::string until = getDueDate (*task, format);
|
||||||
table.addCell (row, 1, until);
|
view.set (row, 1, until);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mask
|
// mask
|
||||||
if (task->getStatus () == Task::recurring)
|
if (task->getStatus () == Task::recurring)
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Mask");
|
view.set (row, 0, "Mask");
|
||||||
table.addCell (row, 1, task->get ("mask"));
|
view.set (row, 1, task->get ("mask"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (task->has ("parent"))
|
if (task->has ("parent"))
|
||||||
{
|
{
|
||||||
// parent
|
// parent
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Parent task");
|
view.set (row, 0, "Parent task");
|
||||||
table.addCell (row, 1, task->get ("parent"));
|
view.set (row, 1, task->get ("parent"));
|
||||||
|
|
||||||
// imask
|
// imask
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Mask Index");
|
view.set (row, 0, "Mask Index");
|
||||||
table.addCell (row, 1, task->get ("imask"));
|
view.set (row, 1, task->get ("imask"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// due (colored)
|
// due (colored)
|
||||||
if (task->has ("due"))
|
if (task->has ("due"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Due");
|
view.set (row, 0, "Due");
|
||||||
|
|
||||||
std::string format = context.config.get ("reportdateformat");
|
std::string format = context.config.get ("reportdateformat");
|
||||||
if (format == "")
|
if (format == "")
|
||||||
format = context.config.get ("dateformat");
|
format = context.config.get ("dateformat");
|
||||||
|
|
||||||
table.addCell (row, 1, getDueDate (*task, format));
|
view.set (row, 1, getDueDate (*task, format));
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait
|
// wait
|
||||||
if (task->has ("wait"))
|
if (task->has ("wait"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Waiting until");
|
view.set (row, 0, "Waiting until");
|
||||||
Date dt (atoi (task->get ("wait").c_str ()));
|
Date dt (atoi (task->get ("wait").c_str ()));
|
||||||
table.addCell (row, 1, dt.toString (context.config.get ("dateformat")));
|
view.set (row, 1, dt.toString (context.config.get ("dateformat")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// start
|
// start
|
||||||
if (task->has ("start"))
|
if (task->has ("start"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Start");
|
view.set (row, 0, "Start");
|
||||||
Date dt (atoi (task->get ("start").c_str ()));
|
Date dt (atoi (task->get ("start").c_str ()));
|
||||||
table.addCell (row, 1, dt.toString (context.config.get ("dateformat")));
|
view.set (row, 1, dt.toString (context.config.get ("dateformat")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// end
|
// end
|
||||||
if (task->has ("end"))
|
if (task->has ("end"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "End");
|
view.set (row, 0, "End");
|
||||||
Date dt (atoi (task->get ("end").c_str ()));
|
Date dt (atoi (task->get ("end").c_str ()));
|
||||||
table.addCell (row, 1, dt.toString (context.config.get ("dateformat")));
|
view.set (row, 1, dt.toString (context.config.get ("dateformat")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// tags ...
|
// tags ...
|
||||||
|
@ -580,20 +572,20 @@ int handleInfo (std::string& outs)
|
||||||
std::string allTags;
|
std::string allTags;
|
||||||
join (allTags, " ", tags);
|
join (allTags, " ", tags);
|
||||||
|
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Tags");
|
view.set (row, 0, "Tags");
|
||||||
table.addCell (row, 1, allTags);
|
view.set (row, 1, allTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// uuid
|
// uuid
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "UUID");
|
view.set (row, 0, "UUID");
|
||||||
std::string uuid = task->get ("uuid");
|
std::string uuid = task->get ("uuid");
|
||||||
table.addCell (row, 1, uuid);
|
view.set (row, 1, uuid);
|
||||||
|
|
||||||
// entry
|
// entry
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Entered");
|
view.set (row, 0, "Entered");
|
||||||
Date dt (atoi (task->get ("entry").c_str ()));
|
Date dt (atoi (task->get ("entry").c_str ()));
|
||||||
std::string entry = dt.toString (context.config.get ("dateformat"));
|
std::string entry = dt.toString (context.config.get ("dateformat"));
|
||||||
|
|
||||||
|
@ -605,64 +597,45 @@ int handleInfo (std::string& outs)
|
||||||
age = Duration (now - dt).format ();
|
age = Duration (now - dt).format ();
|
||||||
}
|
}
|
||||||
|
|
||||||
table.addCell (row, 1, entry + " (" + age + ")");
|
view.set (row, 1, entry + " (" + age + ")");
|
||||||
|
|
||||||
// fg
|
// fg
|
||||||
std::string color = task->get ("fg");
|
std::string color = task->get ("fg");
|
||||||
if (color != "")
|
if (color != "")
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Foreground color");
|
view.set (row, 0, "Foreground color");
|
||||||
table.addCell (row, 1, color);
|
view.set (row, 1, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bg
|
// bg
|
||||||
color = task->get ("bg");
|
color = task->get ("bg");
|
||||||
if (color != "")
|
if (color != "")
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Background color");
|
view.set (row, 0, "Background color");
|
||||||
table.addCell (row, 1, color);
|
view.set (row, 1, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Task::urgency
|
// Task::urgency
|
||||||
row = table.addRow ();
|
row = view.addRow ();
|
||||||
table.addCell (row, 0, "Urgency");
|
view.set (row, 0, "Urgency");
|
||||||
table.addCell (row, 1, task->urgency ());
|
view.set (row, 1, task->urgency ());
|
||||||
|
|
||||||
// Create a second table, containing undo log change details.
|
// Create a second table, containing undo log change details.
|
||||||
Table journal;
|
ViewText journal;
|
||||||
|
|
||||||
// If an alternating row color is specified, notify the table.
|
// If an alternating row color is specified, notify the table.
|
||||||
if (context.color ())
|
if (context.color ())
|
||||||
{
|
{
|
||||||
Color alternate (context.config.get ("color.alternate"));
|
Color alternate (context.config.get ("color.alternate"));
|
||||||
if (alternate.nontrivial ())
|
journal.colorOdd (alternate);
|
||||||
{
|
journal.intraColorOdd (alternate);
|
||||||
table.setTableAlternateColor (alternate);
|
|
||||||
journal.setTableAlternateColor (alternate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
journal.setTableWidth (context.getWidth ());
|
journal.width (context.getWidth ());
|
||||||
journal.setDateFormat (context.config.get ("dateformat"));
|
journal.add (Column::factory ("string", "Date"));
|
||||||
|
journal.add (Column::factory ("string", "Modification"));
|
||||||
journal.addColumn ("Date");
|
|
||||||
journal.addColumn ("Modification");
|
|
||||||
|
|
||||||
if (context.color () && context.config.getBoolean ("fontunderline"))
|
|
||||||
{
|
|
||||||
journal.setColumnUnderline (0);
|
|
||||||
journal.setColumnUnderline (1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
journal.setTableDashedUnderline ();
|
|
||||||
|
|
||||||
journal.setColumnWidth (0, Table::minimum);
|
|
||||||
journal.setColumnWidth (1, Table::flexible);
|
|
||||||
|
|
||||||
journal.setColumnJustification (0, Table::left);
|
|
||||||
journal.setColumnJustification (1, Table::left);
|
|
||||||
|
|
||||||
if (context.config.getBoolean ("journal.info") &&
|
if (context.config.getBoolean ("journal.info") &&
|
||||||
undo.size () > 3)
|
undo.size () > 3)
|
||||||
|
@ -690,11 +663,11 @@ int handleInfo (std::string& outs)
|
||||||
int row = journal.addRow ();
|
int row = journal.addRow ();
|
||||||
|
|
||||||
Date timestamp (atoi (when.substr (5).c_str ()));
|
Date timestamp (atoi (when.substr (5).c_str ()));
|
||||||
journal.addCell (row, 0, timestamp.toString (context.config.get ("dateformat")));
|
journal.set (row, 0, timestamp.toString (context.config.get ("dateformat")));
|
||||||
|
|
||||||
Task before (previous.substr (4));
|
Task before (previous.substr (4));
|
||||||
Task after (current.substr (4));
|
Task after (current.substr (4));
|
||||||
journal.addCell (row, 1, taskInfoDifferences (before, after));
|
journal.set (row, 1, taskInfoDifferences (before, after));
|
||||||
|
|
||||||
// calculate the total active time
|
// calculate the total active time
|
||||||
if (before.get ("start") == ""
|
if (before.get ("start") == ""
|
||||||
|
@ -721,19 +694,17 @@ int handleInfo (std::string& outs)
|
||||||
if (total_time > 0)
|
if (total_time > 0)
|
||||||
{
|
{
|
||||||
row = journal.addRow ();
|
row = journal.addRow ();
|
||||||
journal.addCell (row, 0, "Total active time");
|
journal.set (row, 0, "Total active time");
|
||||||
journal.addCell (row, 1, Duration (total_time).format ());
|
journal.set (row, 1, Duration (total_time).format (),
|
||||||
|
(context.color () ? Color ("bold") : Color ()));
|
||||||
if (context.color ())
|
|
||||||
journal.setCellColor (row, 1, Color ("bold"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out << optionalBlankLine ()
|
out << optionalBlankLine ()
|
||||||
<< table.render ()
|
<< view.render ()
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
||||||
if (journal.rowCount () > 0)
|
if (journal.rows () > 0)
|
||||||
out << journal.render ()
|
out << journal.render ()
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue