def __init__(self, **kwargs): super(TaskListScreen, self).__init__(**kwargs) self.today_list = TaskScrollContainer(list_id=0, name='today') self.tomorrow_list = TaskScrollContainer(list_id=1, name='tomorrow') self.future_list = TaskScrollContainer(list_id=2, name='future') self.archived_list = TaskScrollContainer(list_id=3, name='archived') self.deleted_list = TaskScrollContainer(list_id=4, name='deleted') # current size of screen self.width_state = 0 # Register reference in app control singleton APP_CONTROL.task_list_screen = self self.current_display = TaskListView(self.today_list) self.add_widget(self.current_display) # used in list swapping self.lists = [self.today_list, self.tomorrow_list, self.future_list, self.archived_list] self.list_slide_queue = [] self.animating = False self.lists_pos = 0 self.current_touch_pos = None # Init loading tasks from database DB.load_all_tasks(self._tasks_loaded)
def stop_click_drag(self, task, touch): # task.state = 'normal' col_data = self.click_drag_window.check_children(touch.pos, task) self.click_drag_window.remove_widget(task) task.size_hint_x = 1 last_list = self.last_parent task.height = self.height if col_data[0] is not None: # If it is None then task was released outside of a TaskList.. self.last_parent = col_data[0] if col_data[1]: in_index = col_data[1].parent.children.index(col_data[1]) self.last_parent.add_widget(task, index=in_index + 1) else: self.last_parent.add_widget(task) if self.last_parent.list_id == 4: DB.delete_task(task.uuid, self.last_parent.list_id) elif self.last_parent != last_list: # Only record the task list switch if it's a different list. DB.task_switch(task.uuid, self.last_parent.list_id) last_list.update_list_positions() # Writes new index to database from list that task left self.last_parent.update_list_positions() # writes new task indexes to the database self.click_drag_window.remove_list_names(self.last_parent) touch.ungrab(task)
def _complete_task_action(self): self.current_task_action.finish_time = datetime.now() if not self.current_task_action.task_id == 0: # TODO: Should no-task timer actions be recorded? print('Writing Task Action. Type: %s' % self.current_task_action) DB.write_task_action(self.current_task_action) self.current_task_action = None
def update_list_positions(self): print(self.parent.name) tasks_to_update = list() for index, child in enumerate(self.children): DB.update_task_list_index(index, child.uuid)
def on_stop(self): DB.thread_shutdown()
def exception_shutdown(exctype, value, tb): DB.thread_shutdown() tb.print_tb() print(exctype, value, tb)