mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Extract with_totals from renderSubTotals
This commit is contained in:
parent
551605a8ba
commit
9294fae712
1 changed files with 19 additions and 21 deletions
|
@ -217,8 +217,9 @@ int renderChart (
|
||||||
|
|
||||||
const auto with_summary = rules.getBoolean ("reports." + type + ".summary");
|
const auto with_summary = rules.getBoolean ("reports." + type + ".summary");
|
||||||
const auto with_holidays = rules.getBoolean ("reports." + type + ".holidays");
|
const auto with_holidays = rules.getBoolean ("reports." + type + ".holidays");
|
||||||
|
const auto with_totals = rules.getBoolean ("reports." + type + ".totals");
|
||||||
|
|
||||||
std::cout << renderSubTotal (type, rules, first_hour, last_hour, total_work)
|
std::cout << (with_totals ? renderSubTotal (type, rules, first_hour, last_hour, total_work) : "")
|
||||||
<< (with_holidays ? renderHolidays (rules, filter, rules.all ("holidays.")) : "")
|
<< (with_holidays ? renderHolidays (rules, filter, rules.all ("holidays.")) : "")
|
||||||
<< (with_summary ? renderSummary (indent, filter, exclusions, tracked, blank) : "");
|
<< (with_summary ? renderSummary (indent, filter, exclusions, tracked, blank) : "");
|
||||||
|
|
||||||
|
@ -415,31 +416,28 @@ static std::string renderSubTotal (
|
||||||
time_t total_work)
|
time_t total_work)
|
||||||
{
|
{
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
if (rules.getBoolean ("reports." + type + ".totals"))
|
auto indent = getIndentSize (type, rules);
|
||||||
{
|
int spacing = rules.getInteger ("reports." + type + ".spacing");
|
||||||
auto indent = getIndentSize (type, rules);
|
|
||||||
int spacing = rules.getInteger ("reports." + type + ".spacing");
|
|
||||||
|
|
||||||
auto cell = rules.getInteger ("reports." + type + ".cell");
|
auto cell = rules.getInteger ("reports." + type + ".cell");
|
||||||
if (cell < 1)
|
if (cell < 1)
|
||||||
throw format ("The value for 'reports.{1}.cell' must be at least 1.", type);
|
throw format ("The value for 'reports.{1}.cell' must be at least 1.", type);
|
||||||
|
|
||||||
auto chars_per_hour = 60 / cell;
|
auto chars_per_hour = 60 / cell;
|
||||||
|
|
||||||
std::string pad (indent + ((last_hour - first_hour + 1) * (chars_per_hour + spacing)) + 1, ' ');
|
std::string pad (indent + ((last_hour - first_hour + 1) * (chars_per_hour + spacing)) + 1, ' ');
|
||||||
|
|
||||||
int hours = total_work / 3600;
|
int hours = total_work / 3600;
|
||||||
int minutes = (total_work % 3600) / 60;
|
int minutes = (total_work % 3600) / 60;
|
||||||
|
|
||||||
out << pad
|
out << pad
|
||||||
<< Color ("underline").colorize (" ")
|
<< Color ("underline").colorize (" ")
|
||||||
<< '\n'
|
<< '\n'
|
||||||
<< pad
|
<< pad
|
||||||
<< std::setw (3) << std::setfill (' ') << hours
|
<< std::setw (3) << std::setfill (' ') << hours
|
||||||
<< ':'
|
<< ':'
|
||||||
<< std::setw (2) << std::setfill ('0') << minutes
|
<< std::setw (2) << std::setfill ('0') << minutes
|
||||||
<< '\n';
|
<< '\n';
|
||||||
}
|
|
||||||
|
|
||||||
return out.str ();
|
return out.str ();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue