mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +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;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnProject::ColumnProject ()
|
||||
{
|
||||
_name = "project";
|
||||
_type = "string";
|
||||
_style = "default";
|
||||
_label = STRING_COLUMN_LABEL_PROJECT;
|
||||
|
@ -47,11 +48,17 @@ ColumnProject::~ColumnProject ()
|
|||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnProject::validate (std::string& value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnProject::measure (Task& task, int& minimum, int& maximum)
|
||||
{
|
||||
std::string project = task.get ("project");
|
||||
std::string project = task.get (_name);
|
||||
|
||||
if (_style == "parent")
|
||||
{
|
||||
|
@ -60,7 +67,7 @@ void ColumnProject::measure (Task& task, int& minimum, int& maximum)
|
|||
project = project.substr (0, period);
|
||||
}
|
||||
else if (_style != "default")
|
||||
throw format (STRING_COLUMN_BAD_FORMAT, "project.", _style);
|
||||
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||
|
||||
minimum = longestWord (project);
|
||||
maximum = project.length ();
|
||||
|
@ -73,7 +80,7 @@ void ColumnProject::render (
|
|||
int width,
|
||||
Color& color)
|
||||
{
|
||||
std::string project = task.get ("project");
|
||||
std::string project = task.get (_name);
|
||||
if (_style == "parent")
|
||||
{
|
||||
std::string::size_type period = project.find ('.');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue