From 5838734c9f62b24ce0786a29a369a712e652d784 Mon Sep 17 00:00:00 2001 From: Max G Date: Sun, 17 Mar 2019 20:55:45 +0100 Subject: [PATCH] Changed transmitting of calendar to transmitting of events --- Calendar/DayHeaderDesign.py | 9 ++++++--- Calendar/DayRowDesign.py | 3 ++- Calendar/DayViewPanel.py | 23 +++++++++++++++++------ Calendar/EventListDesign.py | 13 +++---------- Calendar/MonthOvPanel.py | 4 +++- Calendar/SingelDayEventListDesign.py | 4 ++-- 6 files changed, 33 insertions(+), 23 deletions(-) diff --git a/Calendar/DayHeaderDesign.py b/Calendar/DayHeaderDesign.py index ede4b8b..845082a 100644 --- a/Calendar/DayHeaderDesign.py +++ b/Calendar/DayHeaderDesign.py @@ -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) diff --git a/Calendar/DayRowDesign.py b/Calendar/DayRowDesign.py index 650b9bf..3be74f9 100644 --- a/Calendar/DayRowDesign.py +++ b/Calendar/DayRowDesign.py @@ -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) diff --git a/Calendar/DayViewPanel.py b/Calendar/DayViewPanel.py index 60d6efa..502ced4 100644 --- a/Calendar/DayViewPanel.py +++ b/Calendar/DayViewPanel.py @@ -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])) \ No newline at end of file diff --git a/Calendar/EventListDesign.py b/Calendar/EventListDesign.py index 8bbe6c1..4f31c3a 100644 --- a/Calendar/EventListDesign.py +++ b/Calendar/EventListDesign.py @@ -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 diff --git a/Calendar/MonthOvPanel.py b/Calendar/MonthOvPanel.py index 1c394d2..65977ec 100644 --- a/Calendar/MonthOvPanel.py +++ b/Calendar/MonthOvPanel.py @@ -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) diff --git a/Calendar/SingelDayEventListDesign.py b/Calendar/SingelDayEventListDesign.py index c9e256e..40685d5 100644 --- a/Calendar/SingelDayEventListDesign.py +++ b/Calendar/SingelDayEventListDesign.py @@ -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: