mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-07 21:07:20 +02:00
Columns
- Refactored column objects to contain a ::validate method, for the validation of incoming data. - Context.columns is now a vector of one of each column object, indexed by attribute name, for validation purposes.
This commit is contained in:
parent
a7d6b91ad3
commit
3c1c900b5b
38 changed files with 252 additions and 76 deletions
|
@ -40,8 +40,8 @@ extern Context context;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnDue::ColumnDue ()
|
||||
{
|
||||
_name = "due";
|
||||
_label = STRING_COLUMN_LABEL_DUE;
|
||||
_attribute = "due";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -49,6 +49,12 @@ ColumnDue::~ColumnDue ()
|
|||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnDue::validate (std::string& value)
|
||||
{
|
||||
return ColumnDate::validate (value);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
|
@ -66,11 +72,11 @@ void ColumnDue::measure (Task& task, int& minimum, int& maximum)
|
|||
{
|
||||
minimum = maximum = 0;
|
||||
|
||||
if (task.has (_attribute))
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "countdown")
|
||||
{
|
||||
Date date ((time_t) strtol (task.get (_attribute).c_str (), NULL, 10));
|
||||
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
|
||||
Date now;
|
||||
minimum = maximum = Duration (now - date).format ().length ();
|
||||
}
|
||||
|
@ -86,11 +92,11 @@ void ColumnDue::render (
|
|||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_attribute))
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "countdown")
|
||||
{
|
||||
Date date ((time_t) strtol (task.get (_attribute).c_str (), NULL, 10));
|
||||
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
|
||||
Date now;
|
||||
|
||||
lines.push_back (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue