mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +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
|
@ -37,6 +37,7 @@ extern Context context;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnPriority::ColumnPriority ()
|
||||
{
|
||||
_name = "priority";
|
||||
_type = "string";
|
||||
_style = "default";
|
||||
_label = STRING_COLUMN_LABEL_PRI;
|
||||
|
@ -47,6 +48,20 @@ ColumnPriority::~ColumnPriority ()
|
|||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnPriority::validate (std::string& value)
|
||||
{
|
||||
value = upperCase (value);
|
||||
|
||||
if (value == "H" ||
|
||||
value == "M" ||
|
||||
value == "L" ||
|
||||
value == "")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
|
@ -62,7 +77,7 @@ void ColumnPriority::setStyle (const std::string& value)
|
|||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnPriority::measure (Task& task, int& minimum, int& maximum)
|
||||
{
|
||||
std::string priority = task.get ("priority");
|
||||
std::string priority = task.get (_name);
|
||||
|
||||
minimum = maximum = 1;
|
||||
if (_style == "long")
|
||||
|
@ -82,7 +97,7 @@ void ColumnPriority::render (
|
|||
int width,
|
||||
Color& color)
|
||||
{
|
||||
std::string priority = task.get ("priority");
|
||||
std::string priority = task.get (_name);
|
||||
if (_style == "long")
|
||||
{
|
||||
if (priority == "H") priority = "High";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue