mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Enhancement - annotations
- Added support for "annotate" command to annotate existing tasks. - Bumped file format to version 3, due to the annotations. - Added unit tests to verify that annotations work. - Changed 'description' column everywhere to include annotations. - Added 'description_only' column to exclude the annotations. - Fixed bug in Table.cpp that calculated the width of multi-line columns by using the cell length, instead of the length of the longest individual line. - Updated documentation with new feature. - Updated documentation with new column. - Enhanced t.t unit tests to cover format 43
This commit is contained in:
parent
ca795ea281
commit
3979c3283e
16 changed files with 446 additions and 54 deletions
|
@ -207,7 +207,18 @@ std::string handleCompleted (TDB& tdb, T& task, Config& conf)
|
|||
|
||||
table.addCell (row, 0, end.toString (conf.get ("dateformat", "m/d/Y")));
|
||||
table.addCell (row, 1, refTask.getAttribute ("project"));
|
||||
table.addCell (row, 2, refTask.getDescription ());
|
||||
|
||||
std::string description = refTask.getDescription ();
|
||||
std::string when;
|
||||
std::map <time_t, std::string> annotations;
|
||||
refTask.getAnnotations (annotations);
|
||||
foreach (anno, annotations)
|
||||
{
|
||||
Date dt (anno->first);
|
||||
when = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
description += "\n" + when + " " + anno->second;
|
||||
}
|
||||
table.addCell (row, 2, description);
|
||||
|
||||
if (conf.get ("color", true) || conf.get (std::string ("_forcecolor"), false))
|
||||
{
|
||||
|
@ -270,7 +281,7 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf)
|
|||
table.setTableDashedUnderline ();
|
||||
|
||||
table.setColumnWidth (0, Table::minimum);
|
||||
table.setColumnWidth (1, Table::minimum);
|
||||
table.setColumnWidth (1, Table::flexible);
|
||||
|
||||
table.setColumnJustification (0, Table::left);
|
||||
table.setColumnJustification (1, Table::left);
|
||||
|
@ -296,9 +307,20 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf)
|
|||
: refTask.getStatus () == T::recurring ? "Recurring"
|
||||
: ""));
|
||||
|
||||
std::string description = refTask.getDescription ();
|
||||
std::string when;
|
||||
std::map <time_t, std::string> annotations;
|
||||
refTask.getAnnotations (annotations);
|
||||
foreach (anno, annotations)
|
||||
{
|
||||
Date dt (anno->first);
|
||||
when = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
description += "\n" + when + " " + anno->second;
|
||||
}
|
||||
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "Description");
|
||||
table.addCell (row, 1, refTask.getDescription ());
|
||||
table.addCell (row, 1, description);
|
||||
|
||||
if (refTask.getAttribute ("project") != "")
|
||||
{
|
||||
|
@ -1683,6 +1705,7 @@ std::string handleReportStats (TDB& tdb, T& task, Config& conf)
|
|||
int pendingT = 0;
|
||||
int completedT = 0;
|
||||
int taggedT = 0;
|
||||
int annotationsT = 0;
|
||||
int recurringT = 0;
|
||||
float daysPending = 0.0;
|
||||
int descLength = 0;
|
||||
|
@ -1713,6 +1736,8 @@ std::string handleReportStats (TDB& tdb, T& task, Config& conf)
|
|||
|
||||
descLength += it->getDescription ().length ();
|
||||
|
||||
annotationsT += it->getAnnotationCount ();
|
||||
|
||||
std::vector <std::string> tags;
|
||||
it->getTags (tags);
|
||||
if (tags.size ()) ++taggedT;
|
||||
|
@ -1760,6 +1785,7 @@ std::string handleReportStats (TDB& tdb, T& task, Config& conf)
|
|||
out << "Tasks tagged " << std::setprecision (3) << (100.0 * taggedT / totalT) << "%" << std::endl;
|
||||
}
|
||||
|
||||
out << "Annotations " << annotationsT << std::endl;
|
||||
out << "Unique tags " << allTags.size () << std::endl;
|
||||
out << "Projects " << allProjects.size () << std::endl;
|
||||
|
||||
|
@ -2164,7 +2190,7 @@ std::string handleCustomReport (
|
|||
}
|
||||
}
|
||||
|
||||
else if (*col == "description")
|
||||
else if (*col == "description_only")
|
||||
{
|
||||
table.addColumn ("Description");
|
||||
table.setColumnWidth (columnCount, Table::flexible);
|
||||
|
@ -2174,6 +2200,30 @@ std::string handleCustomReport (
|
|||
table.addCell (row, columnCount, tasks[row].getDescription ());
|
||||
}
|
||||
|
||||
else if (*col == "description")
|
||||
{
|
||||
table.addColumn ("Description");
|
||||
table.setColumnWidth (columnCount, Table::flexible);
|
||||
table.setColumnJustification (columnCount, Table::left);
|
||||
|
||||
std::string description;
|
||||
std::string when;
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
description = tasks[row].getDescription ();
|
||||
std::map <time_t, std::string> annotations;
|
||||
tasks[row].getAnnotations (annotations);
|
||||
foreach (anno, annotations)
|
||||
{
|
||||
Date dt (anno->first);
|
||||
when = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||
description += "\n" + when + " " + anno->second;
|
||||
}
|
||||
|
||||
table.addCell (row, columnCount, description);
|
||||
}
|
||||
}
|
||||
|
||||
else if (*col == "recur")
|
||||
{
|
||||
table.addColumn ("Recur");
|
||||
|
@ -2302,17 +2352,18 @@ void validReportColumns (const std::vector <std::string>& columns)
|
|||
|
||||
std::vector <std::string>::const_iterator it;
|
||||
for (it = columns.begin (); it != columns.end (); ++it)
|
||||
if (*it != "id" &&
|
||||
*it != "uuid" &&
|
||||
*it != "project" &&
|
||||
*it != "priority" &&
|
||||
*it != "entry" &&
|
||||
*it != "start" &&
|
||||
*it != "due" &&
|
||||
*it != "age" &&
|
||||
*it != "active" &&
|
||||
*it != "tags" &&
|
||||
*it != "recur" &&
|
||||
if (*it != "id" &&
|
||||
*it != "uuid" &&
|
||||
*it != "project" &&
|
||||
*it != "priority" &&
|
||||
*it != "entry" &&
|
||||
*it != "start" &&
|
||||
*it != "due" &&
|
||||
*it != "age" &&
|
||||
*it != "active" &&
|
||||
*it != "tags" &&
|
||||
*it != "recur" &&
|
||||
*it != "description_only" &&
|
||||
*it != "description")
|
||||
bad.push_back (*it);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue