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:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user