mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Partially extract rules from renderDay
This commit is contained in:
parent
12140859dc
commit
8ee689702d
1 changed files with 11 additions and 8 deletions
|
@ -41,7 +41,7 @@ static void renderAxis (const std::string&, const Rules&, bool
|
||||||
static std::string renderMonth (const Datetime&, const Datetime&);
|
static std::string renderMonth (const Datetime&, const Datetime&);
|
||||||
static std::string renderWeek (const Datetime&, const Datetime&);
|
static std::string renderWeek (const Datetime&, const Datetime&);
|
||||||
static std::string renderWeekday (const std::string&, const Rules&, Datetime&, Color&, Color&);
|
static std::string renderWeekday (const std::string&, const Rules&, Datetime&, Color&, Color&);
|
||||||
static std::string renderDay (const std::string&, const Rules&, Datetime&, Color&, Color&);
|
static std::string renderDay (const Rules&, Datetime&, Color&, Color&);
|
||||||
static std::string renderTotal (const std::string&, const Rules&, time_t);
|
static std::string renderTotal (const std::string&, const Rules&, time_t);
|
||||||
static std::string renderSubTotal (const std::string&, const Rules&, int, int, time_t);
|
static std::string renderSubTotal (const std::string&, const Rules&, int, int, time_t);
|
||||||
static void renderExclusionBlocks (const std::string&, const Rules&, std::vector <Composite>&, bool, const Datetime&, int, int, const std::vector <Range>&);
|
static void renderExclusionBlocks (const std::string&, const Rules&, std::vector <Composite>&, bool, const Datetime&, int, int, const std::vector <Range>&);
|
||||||
|
@ -199,11 +199,12 @@ int renderChart (
|
||||||
|
|
||||||
const auto with_month = rules.getBoolean ("reports." + type + ".month");
|
const auto with_month = rules.getBoolean ("reports." + type + ".month");
|
||||||
const auto with_week = rules.getBoolean ("reports." + type + ".week");
|
const auto with_week = rules.getBoolean ("reports." + type + ".week");
|
||||||
|
const auto with_day = rules.getBoolean ("reports." + type + ".day");
|
||||||
|
|
||||||
auto labelMonth = with_month ? renderMonth (previous, day) : "";
|
auto labelMonth = with_month ? renderMonth (previous, day) : "";
|
||||||
auto labelWeek = with_week ? renderWeek (previous, day) : "";
|
auto labelWeek = with_week ? renderWeek (previous, day) : "";
|
||||||
auto labelWeekday = renderWeekday (type, rules, day, colorToday, colorHoliday);
|
auto labelWeekday = renderWeekday (type, rules, day, colorToday, colorHoliday);
|
||||||
auto labelDay = renderDay (type, rules, day, colorToday, colorHoliday);
|
auto labelDay = with_day ? renderDay (rules, day, colorToday, colorHoliday) : "";
|
||||||
|
|
||||||
std::cout << labelMonth
|
std::cout << labelMonth
|
||||||
<< labelWeek
|
<< labelWeek
|
||||||
|
@ -405,24 +406,26 @@ static std::string renderWeekday (
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static std::string renderDay (
|
static std::string renderDay (
|
||||||
const std::string& type,
|
|
||||||
const Rules& rules,
|
const Rules& rules,
|
||||||
Datetime& day,
|
Datetime& day,
|
||||||
Color& colorToday,
|
Color& colorToday,
|
||||||
Color& colorHoliday)
|
Color& colorHoliday)
|
||||||
{
|
{
|
||||||
auto showDay = rules.getBoolean ("reports." + type + ".day");
|
|
||||||
|
|
||||||
Color color;
|
Color color;
|
||||||
|
|
||||||
if (day.sameDay (Datetime ()))
|
if (day.sameDay (Datetime ()))
|
||||||
|
{
|
||||||
color = colorToday;
|
color = colorToday;
|
||||||
|
}
|
||||||
else if (dayIsHoliday (rules, day))
|
else if (dayIsHoliday (rules, day))
|
||||||
|
{
|
||||||
color = colorHoliday;
|
color = colorHoliday;
|
||||||
|
}
|
||||||
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
if (showDay)
|
|
||||||
out << color.colorize (rightJustify (day.day (), 2))
|
out << color.colorize (rightJustify (day.day (), 2))
|
||||||
<< ' ';
|
<< ' ';
|
||||||
|
|
||||||
return out.str ();
|
return out.str ();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue