mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
helper: Custom tag colors are now used
This commit is contained in:
parent
eb3649aa0e
commit
2f32f96f7f
1 changed files with 10 additions and 3 deletions
|
@ -180,18 +180,25 @@ Palette createPalette (const Rules& rules)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Extract the tags from a set of intervals, and using a rotating color palette,
|
||||
// map unique tags to color.
|
||||
//
|
||||
// If there is a tags.<tag>.color setting, use it.
|
||||
std::map <std::string, Color> createTagColorMap (
|
||||
const Rules& rules,
|
||||
Palette& palette,
|
||||
const std::vector <Interval>& intervals)
|
||||
{
|
||||
// TODO Note: tags may have their own defined color.
|
||||
|
||||
std::map <std::string, Color> mapping;
|
||||
for (auto& interval : intervals)
|
||||
{
|
||||
for (auto& tag : interval.tags ())
|
||||
if (mapping.find (tag) == mapping.end ())
|
||||
{
|
||||
std::string custom = "tags." + tag + ".color";
|
||||
if (rules.has (custom))
|
||||
mapping[tag] = Color (rules.get (custom));
|
||||
else if (mapping.find (tag) == mapping.end ())
|
||||
mapping[tag] = palette.next ();
|
||||
}
|
||||
}
|
||||
|
||||
return mapping;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue