Changed transmitting of calendar to transmitting of events

This commit is contained in:
Maximilian Giller 2019-03-17 20:55:45 +01:00
parent 672d7058d8
commit 5838734c9f
6 changed files with 33 additions and 23 deletions

View file

@ -42,7 +42,10 @@ class DayHeaderDesign (DesignEntity):
self.draw_design(design)
def add_calendar (self, calendar):
self.__draw_event_list__(calendar)
self.__draw_event_list__(calendar.get_today_events())
def add_events (self, events):
self.__draw_event_list__(events)
def add_rssfeed (self, rss):
pass
@ -52,7 +55,7 @@ class DayHeaderDesign (DesignEntity):
self.__draw_month__()
self.__draw_weekday__()
def __draw_event_list__ (self, calendar):
def __draw_event_list__ (self, events):
box_ypos = numberbox_ypos * self.size[1]
box_xpos = numberbox_ypos * self.size[1]
box_height = numberbox_height * self.size[1]
@ -63,7 +66,7 @@ class DayHeaderDesign (DesignEntity):
size = (self.size[0] - pos[0] - weather_width, self.size[1] - pos[1] - box_ypos)
fontsize = eventlist_y_fontsize * self.size[1]
event_list = SingelDayEventListDesign(size, calendar, self.date, fontsize, general_color=general_text_color, background_color=background_color, highlight_color=highlight_color)
event_list = SingelDayEventListDesign(size, events, fontsize, general_color=general_text_color, background_color=background_color, highlight_color=highlight_color)
event_list.pos = pos
self.draw_design(event_list)

View file

@ -50,7 +50,8 @@ class DayRowDesign (DesignEntity):
size = (self.size[0] - pos[0] - weather_width, self.size[1] - pos[1])
fontsize = eventlist_y_fontsize * self.size[1]
event_list = SingelDayEventListDesign(size, calendar, self.date, fontsize, line_spacing=0, general_color=general_text_color, background_color=background_color, highlight_color=highlight_text_color)
events = calendar.get_day_events(self.date)
event_list = SingelDayEventListDesign(size, events, fontsize, line_spacing=0, general_color=general_text_color, background_color=background_color, highlight_color=highlight_text_color)
event_list.pos = pos
self.draw_design(event_list)

View file

@ -1,5 +1,8 @@
from PanelDesign import PanelDesign
from datetime import datetime, timedelta, date
from DayHeaderDesign import DayHeaderDesign
header_size = (1, 0.2)
class DayViewPanel (PanelDesign):
"""Overview that focuses on the current day and
@ -9,13 +12,13 @@ class DayViewPanel (PanelDesign):
self.__first_render__()
def __first_render__ (self):
pass
self.__init_header__()
def add_weather (self, weather):
pass
self.__header__.add_weather(weather)
def add_calendar (self, calendar):
pass
self.__add_allday_events__(calendar)
def add_rssfeed (self, rss):
pass
@ -23,8 +26,16 @@ class DayViewPanel (PanelDesign):
def add_taks (self, tasks):
pass
def __finish_image__(self):
pass
def __finish_image__ (self):
self.draw_design(self.__header__)
def __abs_co__(self, coordinates):
def __init_header__ (self):
self.__header__ = DayHeaderDesign(self.__abs_co__(header_size), date.today())
self.__header__.pos = (0, 0)
def __add_allday_events__ (self, calendar):
allday_events = [event for event in calendar.get_today_events() if event.allday]
self.__header__.add_events(allday_events)
def __abs_co__ (self, coordinates):
return (int(coordinates[0] * self.size[0]),int(coordinates[1] * self.size[1]))

View file

@ -4,13 +4,12 @@ from TableTextDesign import TableTextDesign
class EventListDesign (DesignEntity):
"""Creates a TableTextDesign filled with event
begin date and title"""
def __init__ (self, size, calendar, text_size = 16, filter_date=None, line_spacing=2, col_spacing=10, event_prefix_func=None, font_family=None, general_color="black", background_color="white", highlight_color="red"):
def __init__ (self, size, events, text_size = 16, line_spacing=2, col_spacing=10, event_prefix_func=None, font_family=None, general_color="black", background_color="white", highlight_color="red"):
super(EventListDesign, self).__init__(size)
self.calendar = calendar
self.events = events
self.__event_matrix__ = []
self.__props_matrix__ = []
self.text_size = text_size
self.filter_date = filter_date
self.line_spacing = line_spacing
self.col_spacing = col_spacing
self.font_family = font_family
@ -39,17 +38,11 @@ class EventListDesign (DesignEntity):
return text
def __fill_event_matrix__ (self):
for event in self.__get_events__():
for event in self.events:
row = self.__get_formatted_event__(event)
self.__event_matrix__.append(row)
self.__props_matrix__.append(self.__get_row_props__(event))
def __get_events__(self):
upcoming = self.calendar.get_upcoming_events()
if self.filter_date is not None:
upcoming = [event for event in upcoming if event.begin_datetime.date() == self.filter_date]
return upcoming
def __get_row_props__(self, event):
color = self.general_color
bg_color = self.background_color

View file

@ -80,7 +80,9 @@ class MonthOvPanel (PanelDesign):
month_height = self.month_block.get_real_height()
size = self.__abs_pos__(infolistsize)
size = (size[0], size[1] - month_height)
info_list = EventListDesign(size, calendar, text_size=infolisttextsizeize)
events = calendar.get_upcoming_events()
info_list = EventListDesign(size, events, text_size=infolisttextsizeize)
info_list.pos = (int(month_pos[0] + infolisthorizontalpos * self.size[0]), int(month_pos[1] + month_height))
self.draw_design(info_list)

View file

@ -7,9 +7,9 @@ font = fonts["regular"]
class SingelDayEventListDesign (EventListDesign):
"""Specialized event list for day list design."""
def __init__ (self, size, calendar, date, font_size = 16, line_spacing=2, col_spacing=5, general_color="black", background_color="white", highlight_color="red"):
def __init__ (self, size, events, font_size = 16, line_spacing=2, col_spacing=5, general_color="black", background_color="white", highlight_color="red"):
prefix_func = lambda x : self.__get_event_prefix__(x)
super().__init__(size, calendar, filter_date=date, text_size=font_size, line_spacing=line_spacing, col_spacing=col_spacing, event_prefix_func=prefix_func, font_family=font)
super().__init__(size, events, text_size=font_size, line_spacing=line_spacing, col_spacing=col_spacing, event_prefix_func=prefix_func, font_family=font)
def __get_event_prefix__ (self, event):
if event.allday: