Skip to content

Commit

Permalink
Make functions of Chart member functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lauft committed Jan 31, 2019
1 parent c562f3f commit 49f25ba
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
22 changes: 11 additions & 11 deletions src/Chart.cpp
Expand Up @@ -86,7 +86,7 @@ std::string Chart::render (
if (!with_internal_axis)
{
out << indent
<< Chart::renderAxis (
<< renderAxis (
first_hour,
last_hour,
color_label,
Expand Down Expand Up @@ -114,7 +114,7 @@ std::string Chart::render (
lines[i].add (std::string (total_width, ' '), 0, Color ());
}

Chart::renderExclusionBlocks (lines, day, first_hour, last_hour, exclusions, minutes_per_char, spacing,
renderExclusionBlocks (lines, day, first_hour, last_hour, exclusions, minutes_per_char, spacing,
color_exclusion, color_label, with_internal_axis);

time_t work = 0;
Expand All @@ -123,7 +123,7 @@ std::string Chart::render (
for (auto &track : tracked)
{
time_t interval_work = 0;
Chart::renderInterval (lines, day, track, tag_colors, first_hour, interval_work, with_ids, minutes_per_char,
renderInterval (lines, day, track, tag_colors, first_hour, interval_work, with_ids, minutes_per_char,
spacing);
work += interval_work;
}
Expand All @@ -132,10 +132,10 @@ std::string Chart::render (
auto now = Datetime ();
auto color_day = getDayColor (day, now, holidays, color_today, color_holiday);

auto labelMonth = with_month ? Chart::renderMonth (previous, day) : "";
auto labelWeek = with_week ? Chart::renderWeek (previous, day) : "";
auto labelWeekday = with_weekday ? Chart::renderWeekday (day, color_day) : "";
auto labelDay = with_day ? Chart::renderDay (day, color_day) : "";
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) : "";

out << labelMonth
<< labelWeek
Expand All @@ -153,16 +153,16 @@ std::string Chart::render (
}
}

out << (with_totals ? Chart::renderTotal (work) : "")
out << (with_totals ? renderTotal (work) : "")
<< '\n';

previous = day;
total_work += work;
}

out << (with_totals ? Chart::renderSubTotal (total_work, std::string (padding_size, ' ')) : "")
<< (with_holidays ? Chart::renderHolidays (holidays) : "")
<< (with_summary ? Chart::renderSummary (indent, filter, exclusions, tracked, show_intervals) : "");
out << (with_totals ? renderSubTotal (total_work, std::string (padding_size, ' ')) : "")
<< (with_holidays ? renderHolidays (holidays) : "")
<< (with_summary ? renderSummary (indent, filter, exclusions, tracked, show_intervals) : "");

return out.str ();
}
Expand Down
30 changes: 15 additions & 15 deletions src/Chart.h
Expand Up @@ -36,35 +36,35 @@ class Chart
public:
Chart() = default;

static 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, bool, bool, bool, bool, int, int, int);

static unsigned long getIndentSize (bool, bool, bool, bool);
unsigned long getIndentSize (bool, bool, bool, bool);

static std::pair <int, int> determineHourRange (const Interval&, const std::vector <Interval>&);
std::pair <int, int> determineHourRange (const Interval&, const std::vector <Interval>&);

static std::string renderAxis (int, int, const Color&, const Color&, int, bool);
std::string renderAxis (int, int, const Color&, const Color&, int, bool);

static std::string renderMonth (const Datetime&, const Datetime&);
std::string renderMonth (const Datetime&, const Datetime&);

static std::string renderWeek (const Datetime&, const Datetime&);
std::string renderWeek (const Datetime&, const Datetime&);

static std::string renderWeekday (Datetime&, const Color&);
std::string renderWeekday (Datetime&, const Color&);

static std::string renderDay (Datetime&, const Color&);
std::string renderDay (Datetime&, const Color&);

static Color getDayColor (const Datetime&, const Datetime&, const std::map <Datetime, std::string>&, const Color&, const Color&);
Color getDayColor (const Datetime&, const Datetime&, const std::map <Datetime, std::string>&, const Color&, const Color&);

static std::string renderTotal (time_t);
std::string renderTotal (time_t);

static std::string renderSubTotal (time_t, const std::string&);
std::string renderSubTotal (time_t, const std::string&);

static void renderExclusionBlocks (std::vector<Composite>&, const Datetime&, int, int, const std::vector<Range>&, int, int, const Color&, const Color&, bool);
void renderExclusionBlocks (std::vector<Composite>&, const Datetime&, int, int, const std::vector<Range>&, int, int, const Color&, const Color&, bool);

static void renderInterval (std::vector<Composite>&, const Datetime&, const Interval&, const std::map<std::string, Color>&, int, time_t&, bool, int, int);
void renderInterval (std::vector<Composite>&, const Datetime&, const Interval&, const std::map<std::string, Color>&, int, time_t&, bool, int, int);

static std::string renderHolidays (const std::map <Datetime, std::string>&);
std::string renderHolidays (const std::map <Datetime, std::string>&);

static std::string renderSummary (const std::string&, const Interval&, const std::vector <Range>&, const std::vector <Interval>&, bool);
std::string renderSummary (const std::string&, const Interval&, const std::vector <Range>&, const std::vector <Interval>&, bool);
};

#endif
4 changes: 3 additions & 1 deletion src/commands/CmdChart.cpp
Expand Up @@ -145,7 +145,9 @@ int renderChart (
auto axis_type = rules.get ("reports." + type + ".axis");
const auto with_internal_axis = axis_type == "internal";

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);
Chart chart;

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);

return 0;
}
Expand Down

0 comments on commit 49f25ba

Please sign in to comment.