- 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 () - 2.4.2 () -
- TW-1546 column type due.remaining breaks colors on due tasks (thanks to Renato - TW-1547 Recur column is always shown even if no recurring task is displayed
Alves). (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. - Eliminated some code that is not UTF8-safe.
- Removed pthreads linkage. - Removed pthreads linkage.

View File

@@ -62,11 +62,16 @@ bool ColumnIMask::validate (std::string& value)
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnIMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum) void ColumnIMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
minimum = maximum = task.get ("imask").length (); minimum = maximum = 0;
if (_style != "default" && if (task.has (_name))
_style != "number") {
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); minimum = maximum = task.get ("imask").length ();
if (_style != "default" &&
_style != "number")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -76,7 +81,8 @@ void ColumnIMask::render (
int width, int width,
Color& color) Color& color)
{ {
lines.push_back (color.colorize (rightJustify (task.get ("imask"), width))); 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. // Set the minimum and maximum widths for the value.
void ColumnMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum) void ColumnMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
minimum = maximum = task.get ("mask").length (); minimum = maximum = 0;
if (task.has (_name))
{
minimum = maximum = task.get ("mask").length ();
if (_style != "default") if (_style != "default")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -75,7 +79,8 @@ void ColumnMask::render (
int width, int width,
Color& color) Color& color)
{ {
lines.push_back (color.colorize (task.get ("mask"))); 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. // 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)
{ {
if (_style == "default" || _style == "long") minimum = maximum = 36; minimum = maximum = 0;
else if (_style == "short") minimum = maximum = 8;
else if (task.has (_name))
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); {
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,20 +82,23 @@ void ColumnParent::render (
int width, int width,
Color& color) Color& color)
{ {
// f30cb9c3-3fc0-483f-bfb2-3bf134f00694 default if (task.has (_name))
// 34f00694 short
if (_style == "default" ||
_style == "long")
{ {
lines.push_back (color.colorize (leftJustify (task.get (_name), width))); // f30cb9c3-3fc0-483f-bfb2-3bf134f00694 default
} // 34f00694 short
if (_style == "default" ||
_style == "long")
{
lines.push_back (color.colorize (leftJustify (task.get (_name), width)));
}
else if (_style == "short") else if (_style == "short")
{ {
if (task.has (_name)) if (task.has (_name))
lines.push_back (color.colorize (leftJustify (task.get (_name).substr (28), width))); lines.push_back (color.colorize (leftJustify (task.get (_name).substr (28), width)));
else else
lines.push_back (color.colorize (leftJustify ("", width))); lines.push_back (color.colorize (leftJustify ("", width)));
}
} }
} }

View File

@@ -78,22 +78,26 @@ 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, unsigned int& minimum, unsigned int& maximum) void ColumnPriority::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
std::string priority = task.get (_name); minimum = maximum = 0;
if (task.has (_name))
if (priority == "")
minimum = maximum = 0;
else
minimum = maximum = 1;
if (_style == "long")
{ {
if (priority == "H") minimum = maximum = 4; std::string priority = task.get (_name);
else if (priority == "M") minimum = maximum = 6;
else if (priority == "L") minimum = maximum = 3; if (priority == "")
minimum = maximum = 0;
else
minimum = maximum = 1;
if (_style == "long")
{
if (priority == "H") minimum = maximum = 4;
else if (priority == "M") minimum = maximum = 6;
else if (priority == "L") minimum = maximum = 3;
}
else if (_style != "default" &&
_style != "short")
throw format (STRING_COLUMN_BAD_FORMAT, "priority", _style);
} }
else if (_style != "default" &&
_style != "short")
throw format (STRING_COLUMN_BAD_FORMAT, "priority", _style);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -103,15 +107,18 @@ void ColumnPriority::render (
int width, int width,
Color& color) Color& color)
{ {
std::string priority = task.get (_name); if (task.has (_name))
if (_style == "long")
{ {
if (priority == "H") priority = "High"; std::string priority = task.get (_name);
else if (priority == "M") priority = "Medium"; if (_style == "long")
else if (priority == "L") priority = "Low"; {
} if (priority == "H") priority = "High";
else if (priority == "M") priority = "Medium";
else if (priority == "L") priority = "Low";
}
lines.push_back (color.colorize (leftJustify (priority, width))); lines.push_back (color.colorize (leftJustify (priority, width)));
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@@ -68,25 +68,30 @@ bool ColumnProject::validate (std::string& value)
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnProject::measure (Task& task, unsigned int& minimum, unsigned int& maximum) void ColumnProject::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
std::string project = task.get (_name); minimum = maximum = 0;
if (_style == "parent") if (task.has (_name))
{ {
std::string::size_type period = project.find ('.'); std::string project = task.get (_name);
if (period != std::string::npos)
project = project.substr (0, period);
}
else if (_style == "indented")
{
project = indentProject (project, " ", '.');
}
else if (_style != "default" &&
_style != "full" &&
_style != "indented")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
minimum = longestWord (project); if (_style == "parent")
maximum = utf8_width (project); {
std::string::size_type period = project.find ('.');
if (period != std::string::npos)
project = project.substr (0, period);
}
else if (_style == "indented")
{
project = indentProject (project, " ", '.');
}
else if (_style != "default" &&
_style != "full" &&
_style != "indented")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
minimum = longestWord (project);
maximum = utf8_width (project);
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -96,24 +101,27 @@ void ColumnProject::render (
int width, int width,
Color& color) Color& color)
{ {
std::string project = task.get (_name); if (task.has (_name))
if (_style == "parent")
{ {
std::string::size_type period = project.find ('.'); std::string project = task.get (_name);
if (period != std::string::npos) if (_style == "parent")
project = project.substr (0, period); {
} std::string::size_type period = project.find ('.');
else if (_style == "indented") if (period != std::string::npos)
{ project = project.substr (0, period);
project = indentProject (project, " ", '.'); }
} else if (_style == "indented")
{
project = indentProject (project, " ", '.');
}
std::vector <std::string> raw; std::vector <std::string> raw;
wrapText (raw, project, width, _hyphenate); wrapText (raw, project, width, _hyphenate);
std::vector <std::string>::iterator i; std::vector <std::string>::iterator i;
for (i = raw.begin (); i != raw.end (); ++i) for (i = raw.begin (); i != raw.end (); ++i)
lines.push_back (color.colorize (leftJustify (*i, width))); lines.push_back (color.colorize (leftJustify (*i, width)));
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@@ -79,18 +79,23 @@ void ColumnRecur::setStyle (const std::string& value)
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maximum) void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
if (_style == "default" || minimum = maximum = 0;
_style == "duration")
if (task.has (_name))
{ {
minimum = maximum = Duration (task.get ("recur")).formatISO ().length (); if (_style == "default" ||
_style == "duration")
{
minimum = maximum = Duration (task.get ("recur")).formatISO ().length ();
}
else if (_style == "indicator")
{
if (task.has (_name))
minimum = maximum = utf8_width (context.config.get ("recurrence.indicator"));
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
} }
else if (_style == "indicator")
{
if (task.has (_name))
minimum = maximum = utf8_width (context.config.get ("recurrence.indicator"));
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -108,8 +113,7 @@ void ColumnRecur::render (
lines.push_back ( lines.push_back (
color.colorize ( color.colorize (
rightJustify ( rightJustify (
Duration (task.get ("recur")).formatISO (), Duration (task.get ("recur")).formatISO (), width)));
width)));
} }
else if (_style == "indicator") 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) void ColumnString::measure (const std::string& value, unsigned int& minimum, unsigned int& maximum)
{ {
minimum = maximum = 0;
if (_style == "left" || if (_style == "left" ||
_style == "right" || _style == "right" ||
_style == "default") _style == "default")

View File

@@ -84,30 +84,34 @@ void ColumnTags::setStyle (const std::string& value)
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maximum) void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
if (_style == "indicator") minimum = maximum = utf8_width (context.config.get ("tag.indicator")); minimum = maximum = 0;
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) 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::vector <std::string> all; std::string tags = task.get (_name);
split (all, tags, ','); maximum = utf8_width (tags);
std::vector <std::string>::iterator i;
for (i = all.begin (); i != all.end (); ++i) if (maximum)
{ {
unsigned int length = utf8_width (*i); std::vector <std::string> all;
if (length > minimum) split (all, tags, ',');
minimum = length; std::vector <std::string>::iterator i;
for (i = all.begin (); i != all.end (); ++i)
{
unsigned int length = utf8_width (*i);
if (length > minimum)
minimum = length;
}
} }
} }
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
} }
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -117,9 +121,9 @@ void ColumnTags::render (
int width, int width,
Color& color) Color& color)
{ {
std::string tags = task.get (_name); if (task.has (_name))
if (tags != "")
{ {
std::string tags = task.get (_name);
if (_style == "default" || if (_style == "default" ||
_style == "list") _style == "list")
{ {

View File

@@ -80,49 +80,52 @@ void ColumnUDA::measure (Task& task, unsigned int& minimum, unsigned int& maximu
{ {
minimum = maximum = 0; minimum = maximum = 0;
if (_style == "default") if (task.has (_name))
{ {
std::string value = task.get (_name); if (_style == "default")
if (value != "")
{ {
if (_type == "date") std::string value = task.get (_name);
if (value != "")
{ {
// Determine the output date format, which uses a hierarchy of definitions. if (_type == "date")
// rc.report.<report>.dateformat {
// rc.dateformat.report // Determine the output date format, which uses a hierarchy of definitions.
// rc.dateformat // rc.report.<report>.dateformat
Date date ((time_t) strtol (value.c_str (), NULL, 10)); // rc.dateformat.report
std::string format = context.config.get ("report." + _report + ".dateformat"); // rc.dateformat
if (format == "") Date date ((time_t) strtol (value.c_str (), NULL, 10));
format = context.config.get ("dateformat.report"); std::string format = context.config.get ("report." + _report + ".dateformat");
if (format == "") if (format == "")
format = context.config.get ("dateformat"); format = context.config.get ("dateformat.report");
if (format == "")
format = context.config.get ("dateformat");
minimum = maximum = Date::length (format); minimum = maximum = Date::length (format);
} }
else if (_type == "duration") else if (_type == "duration")
{ {
minimum = maximum = utf8_width (Duration (value).formatISO ()); minimum = maximum = utf8_width (Duration (value).formatISO ());
} }
else if (_type == "string") else if (_type == "string")
{ {
std::string stripped = Color::strip (value); std::string stripped = Color::strip (value);
maximum = longestLine (stripped); maximum = longestLine (stripped);
minimum = longestWord (stripped); minimum = longestWord (stripped);
} }
else if (_type == "numeric") else if (_type == "numeric")
{ {
minimum = maximum = utf8_width (value); minimum = maximum = utf8_width (value);
}
} }
} }
else if (_style == "indicator")
{
if (task.has (_name))
minimum = maximum = utf8_width (context.config.get ("uda." + _name + ".indicator"));
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
} }
else if (_style == "indicator")
{
if (task.has (_name))
minimum = maximum = utf8_width (context.config.get ("uda." + _name + ".indicator"));
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -132,11 +135,11 @@ void ColumnUDA::render (
int width, int width,
Color& color) Color& color)
{ {
if (_style == "default") if (task.has (_name))
{ {
std::string value = task.get (_name); if (_style == "default")
if (value != "")
{ {
std::string value = task.get (_name);
if (_type == "date") if (_type == "date")
{ {
// Determine the output date format, which uses a hierarchy of definitions. // Determine the output date format, which uses a hierarchy of definitions.
@@ -177,13 +180,13 @@ void ColumnUDA::render (
lines.push_back (color.colorize (rightJustify (value, width))); lines.push_back (color.colorize (rightJustify (value, width)));
} }
} }
} else if (_style == "indicator")
else if (_style == "indicator") {
{ if (task.has (_name))
if (task.has (_name)) lines.push_back (
lines.push_back ( color.colorize (
color.colorize ( rightJustify (context.config.get ("uda." + _name + ".indicator"), width)));
rightJustify (context.config.get ("uda." + _name + ".indicator"), width))); }
} }
} }