Custom Reports

- Integrated new View in place of Table for all custom reports.
- Implemented legacy field mapping for columns and sort fields.
- Implemented rc.indent.report.
- Implemented rc.row.padding.
- Implemented rc.column.padding.
- Implemented rc.color.label.
- Modified default rc.indent.annotation from 1 to 2.
- Implemented urgency value caching.
- Implemented View truncation by line and row.
- Columns now know which report thy belong to, so they can use the
  rc.report.<report>.dateformat override.
- Assorted bugs remain.
This commit is contained in:
Paul Beckingham 2011-05-08 09:29:55 -04:00
parent 67a43d6099
commit 041bcfdf21
18 changed files with 346 additions and 798 deletions

View file

@ -42,7 +42,6 @@ ColumnDate::ColumnDate ()
_style = "default";
_label = "";
_attribute = "";
_report = "";
}
////////////////////////////////////////////////////////////////////////////////
@ -50,12 +49,6 @@ ColumnDate::~ColumnDate ()
{
}
////////////////////////////////////////////////////////////////////////////////
void ColumnDate::setReport (const std::string& report)
{
_report = report;
}
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnDate::measure (Task& task, int& minimum, int& maximum)
@ -97,7 +90,7 @@ void ColumnDate::measure (Task& task, int& minimum, int& maximum)
else if (_style == "age")
{
Date now;
minimum = maximum = Duration (now - date).format ().length ();
minimum = maximum = Duration (now - date).formatCompact ().length ();
}
else
throw std::string ("Unrecognized column format '") + _type + "." + _style + "'";
@ -165,7 +158,7 @@ void ColumnDate::render (
lines.push_back (
color.colorize (
rightJustify (
Duration (now - date).format (), width)));
Duration (now - date).formatCompact (), width)));
}
else if (_style == "short")
{

View file

@ -39,13 +39,11 @@ public:
ColumnDate ();
~ColumnDate ();
void setReport (const std::string&);
virtual void measure (Task&, int&, int&);
virtual void render (std::vector <std::string>&, Task&, int, Color&);
protected:
std::string _attribute;
std::string _report;
};
#endif

View file

@ -52,7 +52,7 @@ extern Context context;
//
// <type>[.<format>]
//
Column* Column::factory (const std::string& name)
Column* Column::factory (const std::string& name, const std::string& report)
{
// Decompose name into type and style.
std::string::size_type dot = name.find ('.');
@ -89,33 +89,8 @@ Column* Column::factory (const std::string& name)
else
throw std::string ("Unrecognized column type '") + column_name + "'";
column->setReport (report);
column->setStyle (column_style);
/*
// TODO Load the report column def from config
// TODO Parse column defs
// TODO Create column object
// TODO Column: name
// TODO Column: style
// TODO Column: break
// TODO Color: odd
// TODO Color: even
// TODO Color: intra_odd
// TODO Color: intra_even
// TODO Color: extra_odd
// TODO Color: extra_even
// TODO Color: header
// Terminal width.
view.width (getWidth ());
// TODO Intra padding.
// TODO Extra padding.
// TODO Margin.
// TODO Truncate lines/page.
*/
return column;
}
@ -124,6 +99,7 @@ Column::Column ()
: _type ("string")
, _style ("default")
, _label ("")
, _report ("")
{
}

View file

@ -35,7 +35,7 @@
class Column
{
public:
static Column* factory (const std::string&);
static Column* factory (const std::string&, const std::string&);
Column ();
Column (const Column&);
@ -47,8 +47,9 @@ public:
std::string getLabel () { return _label; }
std::string type () const { return _type; }
virtual void setStyle (const std::string& value) { _style = value; }
virtual void setLabel (const std::string& value) { _label = value; }
virtual void setStyle (const std::string& value) { _style = value; }
virtual void setLabel (const std::string& value) { _label = value; }
virtual void setReport (const std::string& value) { _report = value; }
virtual void measure (Task&, int&, int&) = 0;
virtual void renderHeader (std::vector <std::string>&, int, Color&);
@ -58,6 +59,7 @@ protected:
std::string _type;
std::string _style;
std::string _label;
std::string _report;
};
#endif