Added simplified, multiday-aware prefix

This commit is contained in:
Maximilian Giller 2019-04-07 12:54:34 +02:00
parent c48af815b9
commit a5bfd90b5e
2 changed files with 12 additions and 2 deletions

View file

@ -1,12 +1,12 @@
from EventListDesign import EventListDesign
from settings import hours
from Assets import fonts, defaultfontsize, colors
from TextFormatter import event_prefix_str
from TextFormatter import event_prefix_str_sum
font = fonts["regular"]
class SingelDayEventListDesign (EventListDesign):
"""Specialized event list for day list design."""
def __init__ (self, size, events, font_size = defaultfontsize, line_spacing=2, event_prefix_rel_dates = [], col_spacing=5, general_color=colors["fg"], background_color=colors["bg"], highlight_color=colors["hl"]):
prefix_func = lambda x, rel_date : event_prefix_str(x, rel_date)
prefix_func = lambda x, rel_date : event_prefix_str_sum(x, rel_date)
super().__init__(size, events, text_size=font_size, line_spacing=line_spacing, col_spacing=col_spacing, event_prefix_rel_dates = event_prefix_rel_dates, event_prefix_func=prefix_func, font_family=font, show_more_info=True, general_color=general_color, background_color=background_color, highlight_color = highlight_color)

View file

@ -8,6 +8,7 @@ multiday_begin_character = ' >'
multiday_end_character = '< '
until_character = ' - '
allday_character = ""
multiday_character = allday_character + allday_character
allday_lang = {
"en" : "All day",
@ -60,6 +61,15 @@ def event_prefix_str (event, relative_date=None):
else:
return event_time_detailed(event)
def event_prefix_str_sum (event, relative_date=None):
if relative_date is None:
relative_date = event.begin_datetime.date()
if __is_multiday__(event):
return multiday_character
else:
return event_time_summary(event)
def event_time_summary (event):
if event.allday:
return allday_character