Move configuration for label to contructor

This commit is contained in:
Thomas Lauf 2019-01-30 08:24:58 +01:00
parent 0523262115
commit c7b7b483ba
3 changed files with 26 additions and 13 deletions

View file

@ -36,6 +36,18 @@
#include <timew.h>
#include <Chart.h>
////////////////////////////////////////////////////////////////////////////////
Chart::Chart (
const bool with_label_month,
const bool with_label_week,
const bool with_label_weekday,
const bool with_label_day) :
with_label_month(with_label_month),
with_label_week(with_label_week),
with_label_weekday(with_label_weekday),
with_label_day(with_label_day)
{ }
std::string Chart::render (
const Interval &filter,
const std::vector<Interval> &tracked,
@ -52,10 +64,6 @@ std::string Chart::render (
const bool with_summary,
const bool with_holidays,
const bool with_totals,
const bool with_month,
const bool with_week,
const bool with_day,
const bool with_weekday,
const bool with_internal_axis,
const int minutes_per_char,
const int spacing,
@ -74,7 +82,7 @@ std::string Chart::render (
const auto chars_per_hour = 60 / minutes_per_char;
const auto cell_size = chars_per_hour + spacing;
const auto indent_size = getIndentSize (with_month, with_week, with_day, with_weekday);
const auto indent_size = getIndentSize (with_label_month, with_label_week, with_label_day, with_label_weekday);
const auto indent = std::string (indent_size, ' ');
const auto padding_size = indent_size + ((last_hour - first_hour + 1) * (cell_size)) + 1;
@ -132,10 +140,10 @@ std::string Chart::render (
auto now = Datetime ();
auto color_day = getDayColor (day, now, holidays, color_today, color_holiday);
auto labelMonth = with_month ? renderMonth (previous, day) : "";
auto labelWeek = with_week ? renderWeek (previous, day) : "";
auto labelWeekday = with_weekday ? renderWeekday (day, color_day) : "";
auto labelDay = with_day ? renderDay (day, color_day) : "";
auto labelMonth = with_label_month ? renderMonth (previous, day) : "";
auto labelWeek = with_label_week ? renderWeek (previous, day) : "";
auto labelWeekday = with_label_weekday ? renderWeekday (day, color_day) : "";
auto labelDay = with_label_day ? renderDay (day, color_day) : "";
out << labelMonth
<< labelWeek

View file

@ -34,9 +34,9 @@
class Chart
{
public:
Chart() = default;
Chart(bool, bool, bool, bool);
std::string render (const Interval&, const std::vector <Interval>&, const std::vector <Range>&, const std::map <Datetime, std::string>&, const std::map <std::string, Color>&, const Color&, const Color&, const Color&, const Color&, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, int, int, int);
std::string render (const Interval&, const std::vector <Interval>&, const std::vector <Range>&, const std::map <Datetime, std::string>&, const std::map <std::string, Color>&, const Color&, const Color&, const Color&, const Color&, bool, bool, bool, bool, bool, bool, bool, int, int, int);
private:
unsigned long getIndentSize (bool, bool, bool, bool);
@ -66,6 +66,11 @@ private:
std::string renderHolidays (const std::map <Datetime, std::string>&);
std::string renderSummary (const std::string&, const Interval&, const std::vector <Range>&, const std::vector <Interval>&, bool);
const bool with_label_month;
const bool with_label_week;
const bool with_label_weekday;
const bool with_label_day;
};
#endif

View file

@ -145,9 +145,9 @@ int renderChart (
auto axis_type = rules.get ("reports." + type + ".axis");
const auto with_internal_axis = axis_type == "internal";
Chart chart;
Chart chart(with_month, with_week, with_weekday, with_day);
std::cout << chart.render (filter, tracked, exclusions, holidays, tag_colors, color_today, color_holiday, color_label, color_exclusion, show_intervals, determine_hour_range, with_ids, with_summary, with_holidays, with_totals, with_month, with_week, with_day, with_weekday, with_internal_axis, minutes_per_char, spacing, num_lines);
std::cout << chart.render (filter, tracked, exclusions, holidays, tag_colors, color_today, color_holiday, color_label, color_exclusion, show_intervals, determine_hour_range, with_ids, with_summary, with_holidays, with_totals, with_internal_axis, minutes_per_char, spacing, num_lines);
return 0;
}