Fixed agenda view getting stuck when there are not enough events
This commit is contained in:
parent
d830281789
commit
4df439018e
1 changed files with 5 additions and 2 deletions
|
@ -12,12 +12,13 @@ separator_width = line_thickness
|
|||
class AgendaListDesign (DesignEntity):
|
||||
'''Lists upcoming events in chronological order and groups them by days'''
|
||||
|
||||
def __init__(self, size, calendar, line_spacing=0, col_spacing=8, text_size=defaultfontsize, start_date=date.today(), always_add_start_row=True):
|
||||
def __init__(self, size, calendar, line_spacing=0, col_spacing=8, text_size=defaultfontsize, start_date=date.today(), always_add_start_row=True, day_limit_foresight=91):
|
||||
super(AgendaListDesign, self).__init__(size)
|
||||
self.calendar = calendar
|
||||
self.line_spacing = line_spacing
|
||||
self.col_spacing = col_spacing
|
||||
self.text_size = text_size
|
||||
self.day_limit_foresight = day_limit_foresight
|
||||
self.start_dt = date(start_date.year, start_date.month, start_date.day)
|
||||
self.always_add_start_row = always_add_start_row
|
||||
|
||||
|
@ -37,7 +38,8 @@ class AgendaListDesign (DesignEntity):
|
|||
self.infos = []
|
||||
self.cell_props = []
|
||||
fetch_day = self.start_dt
|
||||
while len(self.infos) < self.__event_number__:
|
||||
days_foresight = 0
|
||||
while len(self.infos) < self.__event_number__ and days_foresight < self.day_limit_foresight:
|
||||
day_events = self.calendar.get_day_events(fetch_day)
|
||||
fetch_day_added_once = False
|
||||
for event in day_events:
|
||||
|
@ -54,6 +56,7 @@ class AgendaListDesign (DesignEntity):
|
|||
|
||||
self.infos.append(row)
|
||||
fetch_day = fetch_day + timedelta(1)
|
||||
days_foresight = days_foresight + 1
|
||||
|
||||
if self.infos[0][1] != date_summary_str(self.start_dt) and self.always_add_start_row:
|
||||
row = ["", date_summary_str(self.start_dt), "", ""]
|
||||
|
|
Loading…
Reference in a new issue