mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
ColUDA: Removed redundant code
This commit is contained in:
parent
78ff1975b2
commit
c8bd60b713
1 changed files with 33 additions and 57 deletions
|
@ -79,14 +79,12 @@ void ColumnUDAString::measure (Task& task, unsigned int& minimum, unsigned int&
|
|||
std::string value = task.get (_name);
|
||||
if (value != "")
|
||||
{
|
||||
std::string stripped = Color::strip (value);
|
||||
auto stripped = Color::strip (value);
|
||||
maximum = longestLine (stripped);
|
||||
minimum = longestWord (stripped);
|
||||
}
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
auto indicator = context.config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
|
@ -94,9 +92,6 @@ void ColumnUDAString::measure (Task& task, unsigned int& minimum, unsigned int&
|
|||
|
||||
minimum = maximum = utf8_width (indicator);
|
||||
}
|
||||
else
|
||||
minimum = maximum = 0;
|
||||
}
|
||||
else
|
||||
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||
}
|
||||
|
@ -169,13 +164,11 @@ void ColumnUDANumeric::measure (Task& task, unsigned int& minimum, unsigned int&
|
|||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
std::string value = task.get (_name);
|
||||
auto value = task.get (_name);
|
||||
if (value != "")
|
||||
minimum = maximum = value.length ();
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
auto indicator = context.config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
|
@ -183,9 +176,6 @@ void ColumnUDANumeric::measure (Task& task, unsigned int& minimum, unsigned int&
|
|||
|
||||
minimum = maximum = utf8_width (indicator);
|
||||
}
|
||||
else
|
||||
minimum = maximum = 0;
|
||||
}
|
||||
else
|
||||
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||
}
|
||||
|
@ -202,12 +192,10 @@ void ColumnUDANumeric::render (
|
|||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
std::string value = task.get (_name);
|
||||
auto value = task.get (_name);
|
||||
renderStringRight (lines, width, color, value);
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
auto indicator = context.config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
|
@ -216,7 +204,6 @@ void ColumnUDANumeric::render (
|
|||
renderStringRight (lines, width, color, indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -257,7 +244,7 @@ void ColumnUDADate::measure (Task& task, unsigned int& minimum, unsigned int& ma
|
|||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
std::string value = task.get (_name);
|
||||
auto value = task.get (_name);
|
||||
if (value != "")
|
||||
{
|
||||
// Determine the output date format, which uses a hierarchy of definitions.
|
||||
|
@ -265,7 +252,7 @@ void ColumnUDADate::measure (Task& task, unsigned int& minimum, unsigned int& ma
|
|||
// rc.dateformat.report
|
||||
// rc.dateformat
|
||||
Datetime date ((time_t) strtol (value.c_str (), NULL, 10));
|
||||
std::string format = context.config.get ("report." + _report + ".dateformat");
|
||||
auto format = context.config.get ("report." + _report + ".dateformat");
|
||||
if (format == "")
|
||||
format = context.config.get ("dateformat.report");
|
||||
if (format == "")
|
||||
|
@ -275,8 +262,6 @@ void ColumnUDADate::measure (Task& task, unsigned int& minimum, unsigned int& ma
|
|||
}
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
auto indicator = context.config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
|
@ -284,9 +269,6 @@ void ColumnUDADate::measure (Task& task, unsigned int& minimum, unsigned int& ma
|
|||
|
||||
minimum = maximum = utf8_width (indicator);
|
||||
}
|
||||
else
|
||||
minimum = maximum = 0;
|
||||
}
|
||||
else
|
||||
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||
}
|
||||
|
@ -303,13 +285,13 @@ void ColumnUDADate::render (
|
|||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
std::string value = task.get (_name);
|
||||
auto value = task.get (_name);
|
||||
|
||||
// Determine the output date format, which uses a hierarchy of definitions.
|
||||
// rc.report.<report>.dateformat
|
||||
// rc.dateformat.report
|
||||
// rc.dateformat.
|
||||
std::string format = context.config.get ("report." + _report + ".dateformat");
|
||||
auto format = context.config.get ("report." + _report + ".dateformat");
|
||||
if (format == "")
|
||||
{
|
||||
format = context.config.get ("dateformat.report");
|
||||
|
@ -320,8 +302,6 @@ void ColumnUDADate::render (
|
|||
renderStringLeft (lines, width, color, Datetime ((time_t) strtol (value.c_str (), NULL, 10)).toString (format));
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
auto indicator = context.config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
|
@ -330,7 +310,6 @@ void ColumnUDADate::render (
|
|||
renderStringRight (lines, width, color, indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -371,7 +350,7 @@ void ColumnUDADuration::measure (Task& task, unsigned int& minimum, unsigned int
|
|||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
std::string value = task.get (_name);
|
||||
auto value = task.get (_name);
|
||||
if (value != "")
|
||||
minimum = maximum = Duration (value).formatISO ().length ();
|
||||
}
|
||||
|
@ -404,12 +383,10 @@ void ColumnUDADuration::render (
|
|||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
std::string value = task.get (_name);
|
||||
auto value = task.get (_name);
|
||||
renderStringRight (lines, width, color, Duration (value).formatISO ());
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
auto indicator = context.config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
|
@ -418,7 +395,6 @@ void ColumnUDADuration::render (
|
|||
renderStringRight (lines, width, color, indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue