- TW-1547 Recur column is always shown even if no recurring task is displayed
          (thanks to Renato Alves).
This commit is contained in:
Paul Beckingham
2015-02-18 20:53:56 -08:00
parent d2b2631db7
commit f2998aba74
10 changed files with 209 additions and 158 deletions

View File

@@ -1,7 +1,11 @@
2.4.2 () -
- TW-1546 column type due.remaining breaks colors on due tasks (thanks to Renato
Alves).
- TW-1547 Recur column is always shown even if no recurring task is displayed
(thanks to Renato Alves).
- TW-1545 cc1plus: error: unrecognized command line option '-std=c++11' (thanks
to Petteri).
- TW-1546 column type due.remaining breaks colors on due tasks (thanks to
Renato Alves).
- Eliminated some code that is not UTF8-safe.
- Removed pthreads linkage.

View File

@@ -62,11 +62,16 @@ bool ColumnIMask::validate (std::string& value)
// Set the minimum and maximum widths for the value.
void ColumnIMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
minimum = maximum = task.get ("imask").length ();
if (_style != "default" &&
_style != "number")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -76,6 +81,7 @@ void ColumnIMask::render (
int width,
Color& color)
{
if (task.has (_name))
lines.push_back (color.colorize (rightJustify (task.get ("imask"), width)));
}

View File

@@ -62,10 +62,14 @@ bool ColumnMask::validate (std::string& value)
// Set the minimum and maximum widths for the value.
void ColumnMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
minimum = maximum = task.get ("mask").length ();
if (_style != "default")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -75,6 +79,7 @@ void ColumnMask::render (
int width,
Color& color)
{
if (task.has (_name))
lines.push_back (color.colorize (task.get ("mask")));
}

View File

@@ -62,12 +62,17 @@ bool ColumnParent::validate (std::string& value)
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnParent::measure (Task&, unsigned int& minimum, unsigned int& maximum)
void ColumnParent::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
if (_style == "default" || _style == "long") minimum = maximum = 36;
else if (_style == "short") minimum = maximum = 8;
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -77,6 +82,8 @@ void ColumnParent::render (
int width,
Color& color)
{
if (task.has (_name))
{
// f30cb9c3-3fc0-483f-bfb2-3bf134f00694 default
// 34f00694 short
if (_style == "default" ||
@@ -92,6 +99,7 @@ void ColumnParent::render (
else
lines.push_back (color.colorize (leftJustify ("", width)));
}
}
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -78,6 +78,9 @@ void ColumnPriority::setStyle (const std::string& value)
// Set the minimum and maximum widths for the value.
void ColumnPriority::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
std::string priority = task.get (_name);
if (priority == "")
@@ -94,6 +97,7 @@ void ColumnPriority::measure (Task& task, unsigned int& minimum, unsigned int& m
else if (_style != "default" &&
_style != "short")
throw format (STRING_COLUMN_BAD_FORMAT, "priority", _style);
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -103,6 +107,8 @@ void ColumnPriority::render (
int width,
Color& color)
{
if (task.has (_name))
{
std::string priority = task.get (_name);
if (_style == "long")
{
@@ -112,6 +118,7 @@ void ColumnPriority::render (
}
lines.push_back (color.colorize (leftJustify (priority, width)));
}
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -68,6 +68,10 @@ bool ColumnProject::validate (std::string& value)
// Set the minimum and maximum widths for the value.
void ColumnProject::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
std::string project = task.get (_name);
if (_style == "parent")
@@ -87,6 +91,7 @@ void ColumnProject::measure (Task& task, unsigned int& minimum, unsigned int& ma
minimum = longestWord (project);
maximum = utf8_width (project);
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -96,6 +101,8 @@ void ColumnProject::render (
int width,
Color& color)
{
if (task.has (_name))
{
std::string project = task.get (_name);
if (_style == "parent")
{
@@ -114,6 +121,7 @@ void ColumnProject::render (
std::vector <std::string>::iterator i;
for (i = raw.begin (); i != raw.end (); ++i)
lines.push_back (color.colorize (leftJustify (*i, width)));
}
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -79,6 +79,10 @@ void ColumnRecur::setStyle (const std::string& value)
// Set the minimum and maximum widths for the value.
void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
if (_style == "default" ||
_style == "duration")
{
@@ -91,6 +95,7 @@ void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maxi
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -108,8 +113,7 @@ void ColumnRecur::render (
lines.push_back (
color.colorize (
rightJustify (
Duration (task.get ("recur")).formatISO (),
width)));
Duration (task.get ("recur")).formatISO (), width)));
}
else if (_style == "indicator")
{

View File

@@ -71,6 +71,8 @@ void ColumnString::setReport (const std::string& value)
//
void ColumnString::measure (const std::string& value, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
if (_style == "left" ||
_style == "right" ||
_style == "default")

View File

@@ -84,13 +84,16 @@ void ColumnTags::setStyle (const std::string& value)
// Set the minimum and maximum widths for the value.
void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
if (_style == "indicator") minimum = maximum = utf8_width (context.config.get ("tag.indicator"));
else if (_style == "count") minimum = maximum = 3;
else if (_style == "default" ||
_style == "list")
{
std::string tags = task.get (_name);
minimum = 0;
maximum = utf8_width (tags);
if (maximum)
@@ -108,6 +111,7 @@ void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maxim
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -117,9 +121,9 @@ void ColumnTags::render (
int width,
Color& color)
{
std::string tags = task.get (_name);
if (tags != "")
if (task.has (_name))
{
std::string tags = task.get (_name);
if (_style == "default" ||
_style == "list")
{

View File

@@ -80,6 +80,8 @@ void ColumnUDA::measure (Task& task, unsigned int& minimum, unsigned int& maximu
{
minimum = maximum = 0;
if (task.has (_name))
{
if (_style == "default")
{
std::string value = task.get (_name);
@@ -123,6 +125,7 @@ void ColumnUDA::measure (Task& task, unsigned int& minimum, unsigned int& maximu
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
}
////////////////////////////////////////////////////////////////////////////////
@@ -132,11 +135,11 @@ void ColumnUDA::render (
int width,
Color& color)
{
if (task.has (_name))
{
if (_style == "default")
{
std::string value = task.get (_name);
if (value != "")
{
if (_type == "date")
{
// Determine the output date format, which uses a hierarchy of definitions.
@@ -177,7 +180,6 @@ void ColumnUDA::render (
lines.push_back (color.colorize (rightJustify (value, width)));
}
}
}
else if (_style == "indicator")
{
if (task.has (_name))
@@ -185,6 +187,7 @@ void ColumnUDA::render (
color.colorize (
rightJustify (context.config.get ("uda." + _name + ".indicator"), width)));
}
}
}
////////////////////////////////////////////////////////////////////////////////