mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Extract rules from renderSubTotal
This commit is contained in:
parent
c73359ad7e
commit
25609c598d
1 changed files with 17 additions and 14 deletions
|
@ -43,7 +43,7 @@ static std::string renderWeek (const Datetime&, const Datetime&);
|
|||
static std::string renderWeekday (const Rules&, Datetime&, Color&, Color&);
|
||||
static std::string renderDay (const Rules&, Datetime&, Color&, Color&);
|
||||
static std::string renderTotal (time_t);
|
||||
static std::string renderSubTotal (const std::string&, const Rules&, int, int, time_t);
|
||||
static std::string renderSubTotal (int, int, time_t, unsigned long, const int, const int);
|
||||
static void renderExclusionBlocks (const std::string&, const Rules&, std::vector <Composite>&, bool, const Datetime&, int, int, const std::vector <Range>&);
|
||||
static void renderInterval (const std::string&, const Rules&, std::vector <Composite>&, const Datetime&, const Interval&, std::map <std::string, Color>&, int, time_t&, bool);
|
||||
std::string renderHolidays (const Rules&, const Interval&, const std::vector<std::string>&);
|
||||
|
@ -134,7 +134,8 @@ int renderChart (
|
|||
int first_hour = hour_range.first;
|
||||
int last_hour = hour_range.second;
|
||||
|
||||
auto indent = std::string (getIndentSize (type, rules), ' ');
|
||||
const auto indent_size = getIndentSize (type, rules);
|
||||
auto indent = std::string (indent_size, ' ');
|
||||
|
||||
// Render the axis.
|
||||
std::cout << '\n';
|
||||
|
@ -232,7 +233,13 @@ int renderChart (
|
|||
const auto with_holidays = rules.getBoolean ("reports." + type + ".holidays");
|
||||
const auto with_totals = rules.getBoolean ("reports." + type + ".totals");
|
||||
|
||||
std::cout << (with_totals ? renderSubTotal (type, rules, first_hour, last_hour, total_work) : "")
|
||||
const auto minutes_per_char = rules.getInteger ("reports." + type + ".cell");
|
||||
if (minutes_per_char < 1)
|
||||
throw format ("The value for 'reports.{1}.cell' must be at least 1.", type);
|
||||
|
||||
const auto spacing = rules.getInteger ("reports." + type + ".spacing");
|
||||
|
||||
std::cout << (with_totals ? renderSubTotal (first_hour, last_hour, total_work, indent_size, spacing, minutes_per_char) : "")
|
||||
<< (with_holidays ? renderHolidays (rules, filter, rules.all ("holidays.")) : "")
|
||||
<< (with_summary ? renderSummary (indent, filter, exclusions, tracked, blank) : "");
|
||||
|
||||
|
@ -454,23 +461,19 @@ static std::string renderTotal (time_t work)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static std::string renderSubTotal (
|
||||
const std::string& type,
|
||||
const Rules& rules,
|
||||
int first_hour,
|
||||
int last_hour,
|
||||
time_t total_work)
|
||||
time_t total_work,
|
||||
const unsigned long indent_size,
|
||||
const int spacing,
|
||||
const int minutes_per_char)
|
||||
{
|
||||
std::stringstream out;
|
||||
auto indent = getIndentSize (type, rules);
|
||||
int spacing = rules.getInteger ("reports." + type + ".spacing");
|
||||
|
||||
auto cell = rules.getInteger ("reports." + type + ".cell");
|
||||
if (cell < 1)
|
||||
throw format ("The value for 'reports.{1}.cell' must be at least 1.", type);
|
||||
auto chars_per_hour = 60 / minutes_per_char;
|
||||
|
||||
auto chars_per_hour = 60 / cell;
|
||||
|
||||
std::string pad (indent + ((last_hour - first_hour + 1) * (chars_per_hour + spacing)) + 1, ' ');
|
||||
const auto padding_size = indent_size + ((last_hour - first_hour + 1) * (chars_per_hour + spacing)) + 1;
|
||||
std::string pad (padding_size, ' ');
|
||||
|
||||
int hours = total_work / 3600;
|
||||
int minutes = (total_work % 3600) / 60;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue