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
|
@ -113,12 +113,17 @@ void Context::initialize (int argc, const char** argv)
|
||||||
// Instantiate built-in command objects.
|
// Instantiate built-in command objects.
|
||||||
Command::factory (commands);
|
Command::factory (commands);
|
||||||
|
|
||||||
|
// Instantiate built-in column objects.
|
||||||
|
Column::factory (columns);
|
||||||
|
|
||||||
// Finally categorize all arguments.
|
// Finally categorize all arguments.
|
||||||
args.categorize ();
|
args.categorize ();
|
||||||
|
|
||||||
// TODO Instantiate extension command objects.
|
// TODO Instantiate extension command objects.
|
||||||
// TODO Instantiate default command object.
|
// TODO Instantiate default command object.
|
||||||
|
|
||||||
|
// TODO Instantiate extension column objects.
|
||||||
|
|
||||||
// TODO Instantiate extension UDA objects.
|
// TODO Instantiate extension UDA objects.
|
||||||
// TODO Instantiate extension format objects.
|
// TODO Instantiate extension format objects.
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,7 @@ public:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::map <std::string, Command*> commands;
|
std::map <std::string, Command*> commands;
|
||||||
|
std::map <std::string, Column*> columns;
|
||||||
|
|
||||||
int terminal_width;
|
int terminal_width;
|
||||||
int terminal_height;
|
int terminal_height;
|
||||||
|
|
|
@ -41,10 +41,10 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnDate::ColumnDate ()
|
ColumnDate::ColumnDate ()
|
||||||
{
|
{
|
||||||
|
_name = "";
|
||||||
_type = "date";
|
_type = "date";
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = "";
|
_label = "";
|
||||||
_attribute = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -52,15 +52,21 @@ ColumnDate::~ColumnDate ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnDate::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set the minimum and maximum widths for the value.
|
// Set the minimum and maximum widths for the value.
|
||||||
void ColumnDate::measure (Task& task, int& minimum, int& maximum)
|
void ColumnDate::measure (Task& task, int& minimum, int& maximum)
|
||||||
{
|
{
|
||||||
minimum = maximum = 0;
|
minimum = maximum = 0;
|
||||||
|
|
||||||
if (task.has (_attribute))
|
if (task.has (_name))
|
||||||
{
|
{
|
||||||
Date date ((time_t) strtol (task.get (_attribute).c_str (), NULL, 10));
|
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
|
||||||
|
|
||||||
if (_style == "default")
|
if (_style == "default")
|
||||||
{
|
{
|
||||||
|
@ -96,7 +102,7 @@ void ColumnDate::measure (Task& task, int& minimum, int& maximum)
|
||||||
minimum = maximum = Duration (now - date).formatCompact ().length ();
|
minimum = maximum = Duration (now - date).formatCompact ().length ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw format (STRING_COLUMN_BAD_FORMAT, _attribute, _style);
|
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +113,7 @@ void ColumnDate::render (
|
||||||
int width,
|
int width,
|
||||||
Color& color)
|
Color& color)
|
||||||
{
|
{
|
||||||
if (task.has (_attribute))
|
if (task.has (_name))
|
||||||
{
|
{
|
||||||
if (_style == "default")
|
if (_style == "default")
|
||||||
{
|
{
|
||||||
|
@ -124,12 +130,12 @@ void ColumnDate::render (
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
color.colorize (
|
color.colorize (
|
||||||
leftJustify (
|
leftJustify (
|
||||||
Date ((time_t) strtol (task.get (_attribute).c_str (), NULL, 10))
|
Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
|
||||||
.toString (format), width)));
|
.toString (format), width)));
|
||||||
}
|
}
|
||||||
else if (_style == "julian")
|
else if (_style == "julian")
|
||||||
{
|
{
|
||||||
double julian = (Date ((time_t) strtol (task.get (_attribute).c_str (), NULL, 10))
|
double julian = (Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
|
||||||
.toEpoch () / 86400.0) + 2440587.5;
|
.toEpoch () / 86400.0) + 2440587.5;
|
||||||
|
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
|
@ -142,7 +148,7 @@ void ColumnDate::render (
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
color.colorize (
|
color.colorize (
|
||||||
rightJustify (
|
rightJustify (
|
||||||
Date ((time_t) strtol (task.get (_attribute).c_str (), NULL, 10))
|
Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
|
||||||
.toEpochString (), width)));
|
.toEpochString (), width)));
|
||||||
}
|
}
|
||||||
else if (_style == "iso")
|
else if (_style == "iso")
|
||||||
|
@ -150,12 +156,12 @@ void ColumnDate::render (
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
color.colorize (
|
color.colorize (
|
||||||
leftJustify (
|
leftJustify (
|
||||||
Date ((time_t) strtol (task.get (_attribute).c_str (), NULL, 10))
|
Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
|
||||||
.toISO (), width)));
|
.toISO (), width)));
|
||||||
}
|
}
|
||||||
else if (_style == "age")
|
else if (_style == "age")
|
||||||
{
|
{
|
||||||
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;
|
Date now;
|
||||||
|
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
|
|
|
@ -40,11 +40,9 @@ public:
|
||||||
ColumnDate ();
|
ColumnDate ();
|
||||||
~ColumnDate ();
|
~ColumnDate ();
|
||||||
|
|
||||||
|
virtual bool validate (std::string&);
|
||||||
virtual void measure (Task&, int&, int&);
|
virtual void measure (Task&, int&, int&);
|
||||||
virtual void render (std::vector <std::string>&, Task&, int, Color&);
|
virtual void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
||||||
protected:
|
|
||||||
std::string _attribute;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,6 +39,7 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnDepends::ColumnDepends ()
|
ColumnDepends::ColumnDepends ()
|
||||||
{
|
{
|
||||||
|
_name = "depends";
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = STRING_COLUMN_LABEL_DEP;
|
_label = STRING_COLUMN_LABEL_DEP;
|
||||||
|
@ -49,6 +50,12 @@ ColumnDepends::~ColumnDepends ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnDepends::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Overriden so that style <----> label are linked.
|
// Overriden so that style <----> label are linked.
|
||||||
// Note that you can not determine which gets called first.
|
// Note that you can not determine which gets called first.
|
||||||
|
@ -93,7 +100,7 @@ void ColumnDepends::measure (Task& task, int& minimum, int& maximum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw format (STRING_COLUMN_BAD_FORMAT, "depends", _style);
|
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -103,7 +110,7 @@ void ColumnDepends::render (
|
||||||
int width,
|
int width,
|
||||||
Color& color)
|
Color& color)
|
||||||
{
|
{
|
||||||
if (task.has ("depends"))
|
if (task.has (_name))
|
||||||
{
|
{
|
||||||
if (_style == "indicator")
|
if (_style == "indicator")
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
ColumnDepends ();
|
ColumnDepends ();
|
||||||
~ColumnDepends ();
|
~ColumnDepends ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
void setStyle (const std::string&);
|
void setStyle (const std::string&);
|
||||||
void measure (Task&, int&, int&);
|
void measure (Task&, int&, int&);
|
||||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
|
@ -40,6 +40,7 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnDescription::ColumnDescription ()
|
ColumnDescription::ColumnDescription ()
|
||||||
{
|
{
|
||||||
|
_name = "description";
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = STRING_COLUMN_LABEL_DESC;
|
_label = STRING_COLUMN_LABEL_DESC;
|
||||||
|
@ -50,11 +51,17 @@ ColumnDescription::~ColumnDescription ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnDescription::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set the minimum and maximum widths for the value.
|
// Set the minimum and maximum widths for the value.
|
||||||
void ColumnDescription::measure (Task& task, int& minimum, int& maximum)
|
void ColumnDescription::measure (Task& task, int& minimum, int& maximum)
|
||||||
{
|
{
|
||||||
std::string description = task.get ("description");
|
std::string description = task.get (_name);
|
||||||
|
|
||||||
// The text
|
// The text
|
||||||
// <indent> <date> <anno>
|
// <indent> <date> <anno>
|
||||||
|
@ -127,7 +134,7 @@ void ColumnDescription::measure (Task& task, int& minimum, int& maximum)
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
throw format (STRING_COLUMN_BAD_FORMAT, "description.", _style);
|
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -137,7 +144,7 @@ void ColumnDescription::render (
|
||||||
int width,
|
int width,
|
||||||
Color& color)
|
Color& color)
|
||||||
{
|
{
|
||||||
std::string description = task.get ("description");
|
std::string description = task.get (_name);
|
||||||
|
|
||||||
// This is a description
|
// This is a description
|
||||||
// <date> <anno>
|
// <date> <anno>
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
ColumnDescription ();
|
ColumnDescription ();
|
||||||
~ColumnDescription ();
|
~ColumnDescription ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
void measure (Task&, int&, int&);
|
void measure (Task&, int&, int&);
|
||||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnDue::ColumnDue ()
|
ColumnDue::ColumnDue ()
|
||||||
{
|
{
|
||||||
|
_name = "due";
|
||||||
_label = STRING_COLUMN_LABEL_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.
|
// Overriden so that style <----> label are linked.
|
||||||
// Note that you can not determine which gets called first.
|
// 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;
|
minimum = maximum = 0;
|
||||||
|
|
||||||
if (task.has (_attribute))
|
if (task.has (_name))
|
||||||
{
|
{
|
||||||
if (_style == "countdown")
|
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;
|
Date now;
|
||||||
minimum = maximum = Duration (now - date).format ().length ();
|
minimum = maximum = Duration (now - date).format ().length ();
|
||||||
}
|
}
|
||||||
|
@ -86,11 +92,11 @@ void ColumnDue::render (
|
||||||
int width,
|
int width,
|
||||||
Color& color)
|
Color& color)
|
||||||
{
|
{
|
||||||
if (task.has (_attribute))
|
if (task.has (_name))
|
||||||
{
|
{
|
||||||
if (_style == "countdown")
|
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;
|
Date now;
|
||||||
|
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
ColumnDue ();
|
ColumnDue ();
|
||||||
~ColumnDue ();
|
~ColumnDue ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
void setStyle (const std::string&);
|
void setStyle (const std::string&);
|
||||||
void measure (Task&, int&, int&);
|
void measure (Task&, int&, int&);
|
||||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnEnd::ColumnEnd ()
|
ColumnEnd::ColumnEnd ()
|
||||||
{
|
{
|
||||||
|
_name = "end";
|
||||||
_label = STRING_COLUMN_LABEL_COMPLETE;
|
_label = STRING_COLUMN_LABEL_COMPLETE;
|
||||||
_attribute = "end";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -43,3 +43,9 @@ ColumnEnd::~ColumnEnd ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnEnd::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return ColumnDate::validate (value);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -35,6 +35,8 @@ class ColumnEnd : public ColumnDate
|
||||||
public:
|
public:
|
||||||
ColumnEnd ();
|
ColumnEnd ();
|
||||||
~ColumnEnd ();
|
~ColumnEnd ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnEntry::ColumnEntry ()
|
ColumnEntry::ColumnEntry ()
|
||||||
{
|
{
|
||||||
|
_name = "entry";
|
||||||
_label = STRING_COLUMN_LABEL_ADDED;
|
_label = STRING_COLUMN_LABEL_ADDED;
|
||||||
_attribute = "entry";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -42,6 +42,12 @@ ColumnEntry::~ColumnEntry ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnEntry::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return ColumnDate::validate (value);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Overriden so that style <----> label are linked.
|
// Overriden so that style <----> label are linked.
|
||||||
// Note that you can not determine which gets called first.
|
// Note that you can not determine which gets called first.
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
ColumnEntry ();
|
ColumnEntry ();
|
||||||
~ColumnEntry ();
|
~ColumnEntry ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
void setStyle (const std::string&);
|
void setStyle (const std::string&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnID::ColumnID ()
|
ColumnID::ColumnID ()
|
||||||
{
|
{
|
||||||
|
_name = "id";
|
||||||
_type = "number";
|
_type = "number";
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = STRING_COLUMN_LABEL_ID;
|
_label = STRING_COLUMN_LABEL_ID;
|
||||||
|
@ -48,6 +49,12 @@ ColumnID::~ColumnID ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnID::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set the minimum and maximum widths for the value.
|
// Set the minimum and maximum widths for the value.
|
||||||
void ColumnID::measure (Task& task, int& minimum, int& maximum)
|
void ColumnID::measure (Task& task, int& minimum, int& maximum)
|
||||||
|
@ -63,7 +70,7 @@ void ColumnID::measure (Task& task, int& minimum, int& maximum)
|
||||||
minimum = maximum = length;
|
minimum = maximum = length;
|
||||||
|
|
||||||
if (_style != "default")
|
if (_style != "default")
|
||||||
throw format (STRING_COLUMN_BAD_FORMAT, "id", _style);
|
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
ColumnID ();
|
ColumnID ();
|
||||||
~ColumnID ();
|
~ColumnID ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
void measure (Task&, int&, int&);
|
void measure (Task&, int&, int&);
|
||||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnPriority::ColumnPriority ()
|
ColumnPriority::ColumnPriority ()
|
||||||
{
|
{
|
||||||
|
_name = "priority";
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = STRING_COLUMN_LABEL_PRI;
|
_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.
|
// Overriden so that style <----> label are linked.
|
||||||
// Note that you can not determine which gets called first.
|
// 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.
|
// Set the minimum and maximum widths for the value.
|
||||||
void ColumnPriority::measure (Task& task, int& minimum, int& maximum)
|
void ColumnPriority::measure (Task& task, int& minimum, int& maximum)
|
||||||
{
|
{
|
||||||
std::string priority = task.get ("priority");
|
std::string priority = task.get (_name);
|
||||||
|
|
||||||
minimum = maximum = 1;
|
minimum = maximum = 1;
|
||||||
if (_style == "long")
|
if (_style == "long")
|
||||||
|
@ -82,7 +97,7 @@ void ColumnPriority::render (
|
||||||
int width,
|
int width,
|
||||||
Color& color)
|
Color& color)
|
||||||
{
|
{
|
||||||
std::string priority = task.get ("priority");
|
std::string priority = task.get (_name);
|
||||||
if (_style == "long")
|
if (_style == "long")
|
||||||
{
|
{
|
||||||
if (priority == "H") priority = "High";
|
if (priority == "H") priority = "High";
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
ColumnPriority ();
|
ColumnPriority ();
|
||||||
~ColumnPriority ();
|
~ColumnPriority ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
void setStyle (const std::string&);
|
void setStyle (const std::string&);
|
||||||
void measure (Task&, int&, int&);
|
void measure (Task&, int&, int&);
|
||||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
|
@ -37,6 +37,7 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnProject::ColumnProject ()
|
ColumnProject::ColumnProject ()
|
||||||
{
|
{
|
||||||
|
_name = "project";
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = STRING_COLUMN_LABEL_PROJECT;
|
_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.
|
// Set the minimum and maximum widths for the value.
|
||||||
void ColumnProject::measure (Task& task, int& minimum, int& maximum)
|
void ColumnProject::measure (Task& task, int& minimum, int& maximum)
|
||||||
{
|
{
|
||||||
std::string project = task.get ("project");
|
std::string project = task.get (_name);
|
||||||
|
|
||||||
if (_style == "parent")
|
if (_style == "parent")
|
||||||
{
|
{
|
||||||
|
@ -60,7 +67,7 @@ void ColumnProject::measure (Task& task, int& minimum, int& maximum)
|
||||||
project = project.substr (0, period);
|
project = project.substr (0, period);
|
||||||
}
|
}
|
||||||
else if (_style != "default")
|
else if (_style != "default")
|
||||||
throw format (STRING_COLUMN_BAD_FORMAT, "project.", _style);
|
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||||
|
|
||||||
minimum = longestWord (project);
|
minimum = longestWord (project);
|
||||||
maximum = project.length ();
|
maximum = project.length ();
|
||||||
|
@ -73,7 +80,7 @@ void ColumnProject::render (
|
||||||
int width,
|
int width,
|
||||||
Color& color)
|
Color& color)
|
||||||
{
|
{
|
||||||
std::string project = task.get ("project");
|
std::string project = task.get (_name);
|
||||||
if (_style == "parent")
|
if (_style == "parent")
|
||||||
{
|
{
|
||||||
std::string::size_type period = project.find ('.');
|
std::string::size_type period = project.find ('.');
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
ColumnProject ();
|
ColumnProject ();
|
||||||
~ColumnProject ();
|
~ColumnProject ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
void measure (Task&, int&, int&);
|
void measure (Task&, int&, int&);
|
||||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnRecur::ColumnRecur ()
|
ColumnRecur::ColumnRecur ()
|
||||||
{
|
{
|
||||||
|
_name = "recur";
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = STRING_COLUMN_LABEL_RECUR;
|
_label = STRING_COLUMN_LABEL_RECUR;
|
||||||
|
@ -47,6 +48,12 @@ ColumnRecur::~ColumnRecur ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnRecur::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Overriden so that style <----> label are linked.
|
// Overriden so that style <----> label are linked.
|
||||||
// Note that you can not determine which gets called first.
|
// Note that you can not determine which gets called first.
|
||||||
|
@ -68,11 +75,11 @@ void ColumnRecur::measure (Task& task, int& minimum, int& maximum)
|
||||||
}
|
}
|
||||||
else if (_style == "indicator")
|
else if (_style == "indicator")
|
||||||
{
|
{
|
||||||
if (task.has ("recur"))
|
if (task.has (_name))
|
||||||
minimum = maximum = context.config.get ("recurrence.indicator").length ();
|
minimum = maximum = context.config.get ("recurrence.indicator").length ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw format (STRING_COLUMN_BAD_FORMAT, "recur.", _style);
|
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -88,7 +95,7 @@ void ColumnRecur::render (
|
||||||
}
|
}
|
||||||
else if (_style == "indicator")
|
else if (_style == "indicator")
|
||||||
{
|
{
|
||||||
if (task.has ("recur"))
|
if (task.has (_name))
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
color.colorize (
|
color.colorize (
|
||||||
rightJustify (context.config.get ("recurrence.indicator"), width)));
|
rightJustify (context.config.get ("recurrence.indicator"), width)));
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
ColumnRecur ();
|
ColumnRecur ();
|
||||||
~ColumnRecur ();
|
~ColumnRecur ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
void setStyle (const std::string&);
|
void setStyle (const std::string&);
|
||||||
void measure (Task&, int&, int&);
|
void measure (Task&, int&, int&);
|
||||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
|
@ -37,8 +37,8 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnStart::ColumnStart ()
|
ColumnStart::ColumnStart ()
|
||||||
{
|
{
|
||||||
|
_name = "start";
|
||||||
_label = STRING_COLUMN_LABEL_STARTED;
|
_label = STRING_COLUMN_LABEL_STARTED;
|
||||||
_attribute = "start";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -46,6 +46,12 @@ ColumnStart::~ColumnStart ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnStart::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return ColumnDate::validate (value);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Overriden so that style <----> label are linked.
|
// Overriden so that style <----> label are linked.
|
||||||
// Note that you can not determine which gets called first.
|
// Note that you can not determine which gets called first.
|
||||||
|
@ -63,7 +69,7 @@ void ColumnStart::measure (Task& task, int& minimum, int& maximum)
|
||||||
{
|
{
|
||||||
minimum = maximum = 0;
|
minimum = maximum = 0;
|
||||||
|
|
||||||
if (task.has (_attribute))
|
if (task.has (_name))
|
||||||
{
|
{
|
||||||
if (_style == "active")
|
if (_style == "active")
|
||||||
{
|
{
|
||||||
|
@ -82,7 +88,7 @@ void ColumnStart::render (
|
||||||
int width,
|
int width,
|
||||||
Color& color)
|
Color& color)
|
||||||
{
|
{
|
||||||
if (task.has (_attribute))
|
if (task.has (_name))
|
||||||
{
|
{
|
||||||
if (_style == "active")
|
if (_style == "active")
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
ColumnStart ();
|
ColumnStart ();
|
||||||
~ColumnStart ();
|
~ColumnStart ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
void setStyle (const std::string&);
|
void setStyle (const std::string&);
|
||||||
void measure (Task&, int&, int&);
|
void measure (Task&, int&, int&);
|
||||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
|
@ -37,6 +37,7 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnStatus::ColumnStatus ()
|
ColumnStatus::ColumnStatus ()
|
||||||
{
|
{
|
||||||
|
_name = "status";
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = STRING_COLUMN_LABEL_STATUS;
|
_label = STRING_COLUMN_LABEL_STATUS;
|
||||||
|
@ -47,6 +48,12 @@ ColumnStatus::~ColumnStatus ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnStatus::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Overriden so that style <----> label are linked.
|
// Overriden so that style <----> label are linked.
|
||||||
// Note that you can not determine which gets called first.
|
// Note that you can not determine which gets called first.
|
||||||
|
@ -81,7 +88,7 @@ void ColumnStatus::measure (Task& task, int& minimum, int& maximum)
|
||||||
else if (_style == "short")
|
else if (_style == "short")
|
||||||
minimum = maximum = 1;
|
minimum = maximum = 1;
|
||||||
else
|
else
|
||||||
throw format (STRING_COLUMN_BAD_FORMAT, "status.", _style);
|
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
ColumnStatus ();
|
ColumnStatus ();
|
||||||
~ColumnStatus ();
|
~ColumnStatus ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
void setStyle (const std::string&);
|
void setStyle (const std::string&);
|
||||||
void measure (Task&, int&, int&);
|
void measure (Task&, int&, int&);
|
||||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// taskwarrior - a command line task list manager.
|
// taskwarrior - a command line task list manager.
|
||||||
//
|
//
|
||||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
||||||
|
@ -37,6 +37,7 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnString::ColumnString ()
|
ColumnString::ColumnString ()
|
||||||
{
|
{
|
||||||
|
_name = "string";
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = "";
|
_label = "";
|
||||||
|
@ -72,7 +73,7 @@ void ColumnString::measure (const std::string& value, int& minimum, int& maximum
|
||||||
_style == "right_fixed")
|
_style == "right_fixed")
|
||||||
minimum = maximum = strippedLength (value);
|
minimum = maximum = strippedLength (value);
|
||||||
else
|
else
|
||||||
throw format (STRING_COLUMN_BAD_FORMAT, "string.", _style);
|
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -38,6 +38,7 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnTags::ColumnTags ()
|
ColumnTags::ColumnTags ()
|
||||||
{
|
{
|
||||||
|
_name = "tags";
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = STRING_COLUMN_LABEL_TAGS;
|
_label = STRING_COLUMN_LABEL_TAGS;
|
||||||
|
@ -48,6 +49,12 @@ ColumnTags::~ColumnTags ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnTags::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Overriden so that style <----> label are linked.
|
// Overriden so that style <----> label are linked.
|
||||||
// Note that you can not determine which gets called first.
|
// Note that you can not determine which gets called first.
|
||||||
|
@ -73,7 +80,7 @@ void ColumnTags::measure (Task& task, int& minimum, int& maximum)
|
||||||
else if (_style == "count") minimum = maximum = 3;
|
else if (_style == "count") minimum = maximum = 3;
|
||||||
else if (_style == "default")
|
else if (_style == "default")
|
||||||
{
|
{
|
||||||
std::string tags = task.get ("tags");
|
std::string tags = task.get (_name);
|
||||||
minimum = 0;
|
minimum = 0;
|
||||||
maximum = tags.length ();
|
maximum = tags.length ();
|
||||||
|
|
||||||
|
@ -88,7 +95,7 @@ void ColumnTags::measure (Task& task, int& minimum, int& maximum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw format (STRING_COLUMN_BAD_FORMAT, "tags.", _style);
|
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -98,7 +105,7 @@ void ColumnTags::render (
|
||||||
int width,
|
int width,
|
||||||
Color& color)
|
Color& color)
|
||||||
{
|
{
|
||||||
std::string tags = task.get ("tags");
|
std::string tags = task.get (_name);
|
||||||
if (tags != "")
|
if (tags != "")
|
||||||
{
|
{
|
||||||
if (_style == "indicator")
|
if (_style == "indicator")
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
ColumnTags ();
|
ColumnTags ();
|
||||||
~ColumnTags ();
|
~ColumnTags ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
void setStyle (const std::string&);
|
void setStyle (const std::string&);
|
||||||
void measure (Task&, int&, int&);
|
void measure (Task&, int&, int&);
|
||||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
|
@ -38,6 +38,7 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnUUID::ColumnUUID ()
|
ColumnUUID::ColumnUUID ()
|
||||||
{
|
{
|
||||||
|
_name = "uuid";
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = STRING_COLUMN_LABEL_UUID;
|
_label = STRING_COLUMN_LABEL_UUID;
|
||||||
|
@ -48,6 +49,12 @@ ColumnUUID::~ColumnUUID ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnUUID::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set the minimum and maximum widths for the value.
|
// Set the minimum and maximum widths for the value.
|
||||||
void ColumnUUID::measure (Task&, int& minimum, int& maximum)
|
void ColumnUUID::measure (Task&, int& minimum, int& maximum)
|
||||||
|
@ -55,7 +62,7 @@ void ColumnUUID::measure (Task&, int& minimum, int& maximum)
|
||||||
if (_style == "default") minimum = maximum = 36;
|
if (_style == "default") minimum = maximum = 36;
|
||||||
else if (_style == "short") minimum = maximum = 8;
|
else if (_style == "short") minimum = maximum = 8;
|
||||||
else
|
else
|
||||||
throw format (STRING_COLUMN_BAD_FORMAT, "uuid.", _style);
|
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -68,10 +75,10 @@ void ColumnUUID::render (
|
||||||
// f30cb9c3-3fc0-483f-bfb2-3bf134f00694 default
|
// f30cb9c3-3fc0-483f-bfb2-3bf134f00694 default
|
||||||
// 34f00694 short
|
// 34f00694 short
|
||||||
if (_style == "default")
|
if (_style == "default")
|
||||||
lines.push_back (color.colorize (leftJustify (task.get ("uuid"), width)));
|
lines.push_back (color.colorize (leftJustify (task.get (_name), width)));
|
||||||
|
|
||||||
else if (_style == "short")
|
else if (_style == "short")
|
||||||
lines.push_back (color.colorize (leftJustify (task.get ("uuid").substr (28), width)));
|
lines.push_back (color.colorize (leftJustify (task.get (_name).substr (28), width)));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
ColumnUUID ();
|
ColumnUUID ();
|
||||||
~ColumnUUID ();
|
~ColumnUUID ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
void measure (Task&, int&, int&);
|
void measure (Task&, int&, int&);
|
||||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnUntil::ColumnUntil ()
|
ColumnUntil::ColumnUntil ()
|
||||||
{
|
{
|
||||||
|
_name = "until";
|
||||||
_label = STRING_COLUMN_LABEL_UNTIL;
|
_label = STRING_COLUMN_LABEL_UNTIL;
|
||||||
_attribute = "until";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -43,3 +43,9 @@ ColumnUntil::~ColumnUntil ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnUntil::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return ColumnDate::validate (value);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -35,6 +35,8 @@ class ColumnUntil : public ColumnDate
|
||||||
public:
|
public:
|
||||||
ColumnUntil ();
|
ColumnUntil ();
|
||||||
~ColumnUntil ();
|
~ColumnUntil ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -37,6 +37,7 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnUrgency::ColumnUrgency ()
|
ColumnUrgency::ColumnUrgency ()
|
||||||
{
|
{
|
||||||
|
_name = "urgency";
|
||||||
_type = "number";
|
_type = "number";
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = STRING_COLUMN_LABEL_URGENCY;
|
_label = STRING_COLUMN_LABEL_URGENCY;
|
||||||
|
@ -54,7 +55,7 @@ void ColumnUrgency::measure (Task& task, int& minimum, int& maximum)
|
||||||
minimum = maximum = format (task.urgency (), 4, 3).length ();
|
minimum = maximum = format (task.urgency (), 4, 3).length ();
|
||||||
|
|
||||||
if (_style != "default")
|
if (_style != "default")
|
||||||
throw format (STRING_COLUMN_BAD_FORMAT, "urgency.", _style);
|
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnWait::ColumnWait ()
|
ColumnWait::ColumnWait ()
|
||||||
{
|
{
|
||||||
|
_name = "wait";
|
||||||
_label = STRING_COLUMN_LABEL_WAIT;
|
_label = STRING_COLUMN_LABEL_WAIT;
|
||||||
_attribute = "wait";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -43,3 +43,9 @@ ColumnWait::~ColumnWait ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool ColumnWait::validate (std::string& value)
|
||||||
|
{
|
||||||
|
return ColumnDate::validate (value);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -35,6 +35,8 @@ class ColumnWait : public ColumnDate
|
||||||
public:
|
public:
|
||||||
ColumnWait ();
|
ColumnWait ();
|
||||||
~ColumnWait ();
|
~ColumnWait ();
|
||||||
|
|
||||||
|
bool validate (std::string&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Supports the new complete column definition:
|
// Supports the complete column definition:
|
||||||
//
|
//
|
||||||
// <type>[.<format>]
|
// <type>[.<format>]
|
||||||
//
|
//
|
||||||
|
@ -73,37 +73,62 @@ Column* Column::factory (const std::string& name, const std::string& report)
|
||||||
column_style = "default";
|
column_style = "default";
|
||||||
}
|
}
|
||||||
|
|
||||||
Column* column;
|
Column* c;
|
||||||
if (column_name == "depends") column = new ColumnDepends ();
|
if (column_name == "depends") c = new ColumnDepends ();
|
||||||
else if (column_name == "description") column = new ColumnDescription ();
|
else if (column_name == "description") c = new ColumnDescription ();
|
||||||
else if (column_name == "due") column = new ColumnDue ();
|
else if (column_name == "due") c = new ColumnDue ();
|
||||||
else if (column_name == "end") column = new ColumnEnd ();
|
else if (column_name == "end") c = new ColumnEnd ();
|
||||||
else if (column_name == "entry") column = new ColumnEntry ();
|
else if (column_name == "entry") c = new ColumnEntry ();
|
||||||
else if (column_name == "id") column = new ColumnID ();
|
else if (column_name == "id") c = new ColumnID ();
|
||||||
else if (column_name == "priority") column = new ColumnPriority ();
|
else if (column_name == "priority") c = new ColumnPriority ();
|
||||||
else if (column_name == "project") column = new ColumnProject ();
|
else if (column_name == "project") c = new ColumnProject ();
|
||||||
else if (column_name == "recur") column = new ColumnRecur ();
|
else if (column_name == "recur") c = new ColumnRecur ();
|
||||||
else if (column_name == "start") column = new ColumnStart ();
|
else if (column_name == "start") c = new ColumnStart ();
|
||||||
else if (column_name == "status") column = new ColumnStatus ();
|
else if (column_name == "status") c = new ColumnStatus ();
|
||||||
else if (column_name == "tags") column = new ColumnTags ();
|
else if (column_name == "tags") c = new ColumnTags ();
|
||||||
else if (column_name == "until") column = new ColumnUntil ();
|
else if (column_name == "until") c = new ColumnUntil ();
|
||||||
else if (column_name == "urgency") column = new ColumnUrgency ();
|
else if (column_name == "urgency") c = new ColumnUrgency ();
|
||||||
else if (column_name == "uuid") column = new ColumnUUID ();
|
else if (column_name == "uuid") c = new ColumnUUID ();
|
||||||
else if (column_name == "wait") column = new ColumnWait ();
|
else if (column_name == "wait") c = new ColumnWait ();
|
||||||
|
|
||||||
// Special non-task column
|
// Special non-task column.
|
||||||
else if (column_name == "string") column = new ColumnString ();
|
else if (column_name == "string") c = new ColumnString ();
|
||||||
else
|
else
|
||||||
throw format (STRING_COLUMN_BAD_NAME, column_name);
|
throw format (STRING_COLUMN_BAD_NAME, column_name);
|
||||||
|
|
||||||
column->setReport (report);
|
c->setReport (report);
|
||||||
column->setStyle (column_style);
|
c->setStyle (column_style);
|
||||||
return column;
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Bulk column instantiation.
|
||||||
|
void Column::factory (std::map <std::string, Column*>& all)
|
||||||
|
{
|
||||||
|
Column* c;
|
||||||
|
|
||||||
|
c = new ColumnDepends (); all[c->_name] = c;
|
||||||
|
c = new ColumnDescription (); all[c->_name] = c;
|
||||||
|
c = new ColumnDue (); all[c->_name] = c;
|
||||||
|
c = new ColumnEnd (); all[c->_name] = c;
|
||||||
|
c = new ColumnEntry (); all[c->_name] = c;
|
||||||
|
c = new ColumnID (); all[c->_name] = c;
|
||||||
|
c = new ColumnPriority (); all[c->_name] = c;
|
||||||
|
c = new ColumnProject (); all[c->_name] = c;
|
||||||
|
c = new ColumnRecur (); all[c->_name] = c;
|
||||||
|
c = new ColumnStart (); all[c->_name] = c;
|
||||||
|
c = new ColumnStatus (); all[c->_name] = c;
|
||||||
|
c = new ColumnTags (); all[c->_name] = c;
|
||||||
|
c = new ColumnUntil (); all[c->_name] = c;
|
||||||
|
c = new ColumnUrgency (); all[c->_name] = c;
|
||||||
|
c = new ColumnUUID (); all[c->_name] = c;
|
||||||
|
c = new ColumnWait (); all[c->_name] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Column::Column ()
|
Column::Column ()
|
||||||
: _type ("string")
|
: _name ("")
|
||||||
|
, _type ("string")
|
||||||
, _style ("default")
|
, _style ("default")
|
||||||
, _label ("")
|
, _label ("")
|
||||||
, _report ("")
|
, _report ("")
|
||||||
|
@ -113,9 +138,11 @@ Column::Column ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Column::Column (const Column& other)
|
Column::Column (const Column& other)
|
||||||
{
|
{
|
||||||
|
_name = other._name;
|
||||||
_type = other._type;
|
_type = other._type;
|
||||||
_style = other._style;
|
_style = other._style;
|
||||||
_label = other._label;
|
_label = other._label;
|
||||||
|
_label = other._report;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -123,9 +150,11 @@ Column& Column::operator= (const Column& other)
|
||||||
{
|
{
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
{
|
{
|
||||||
|
_name = other._name;
|
||||||
_type = other._type;
|
_type = other._type;
|
||||||
_style = other._style;
|
_style = other._style;
|
||||||
_label = other._label;
|
_label = other._label;
|
||||||
|
_report = other._report;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -134,7 +163,8 @@ Column& Column::operator= (const Column& other)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Column::operator== (const Column& other) const
|
bool Column::operator== (const Column& other) const
|
||||||
{
|
{
|
||||||
return _type == other._type &&
|
return _name == other._name &&
|
||||||
|
_type == other._type &&
|
||||||
_style == other._style &&
|
_style == other._style &&
|
||||||
_label == other._label;
|
_label == other._label;
|
||||||
}
|
}
|
||||||
|
@ -176,6 +206,12 @@ void Column::renderHeader (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool Column::validate (std::string& input)
|
||||||
|
{
|
||||||
|
return input.length () ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// No L10N.
|
// No L10N.
|
||||||
void Column::measure (const std::string&, int&, int&)
|
void Column::measure (const std::string&, int&, int&)
|
||||||
|
|
|
@ -37,6 +37,7 @@ class Column
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Column* factory (const std::string&, const std::string&);
|
static Column* factory (const std::string&, const std::string&);
|
||||||
|
static void factory (std::map <std::string, Column*>&);
|
||||||
|
|
||||||
Column ();
|
Column ();
|
||||||
Column (const Column&);
|
Column (const Column&);
|
||||||
|
@ -52,6 +53,7 @@ public:
|
||||||
virtual void setLabel (const std::string& value) { _label = value; }
|
virtual void setLabel (const std::string& value) { _label = value; }
|
||||||
virtual void setReport (const std::string& value) { _report = value; }
|
virtual void setReport (const std::string& value) { _report = value; }
|
||||||
|
|
||||||
|
virtual bool validate (std::string&);
|
||||||
virtual void measure (const std::string&, int&, int&);
|
virtual void measure (const std::string&, int&, int&);
|
||||||
virtual void measure (Task&, int&, int&);
|
virtual void measure (Task&, int&, int&);
|
||||||
virtual void renderHeader (std::vector <std::string>&, int, Color&);
|
virtual void renderHeader (std::vector <std::string>&, int, Color&);
|
||||||
|
@ -59,6 +61,7 @@ public:
|
||||||
virtual void render (std::vector <std::string>&, Task&, int, Color&);
|
virtual void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
std::string _name;
|
||||||
std::string _type;
|
std::string _type;
|
||||||
std::string _style;
|
std::string _style;
|
||||||
std::string _label;
|
std::string _label;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue