def append_lap(self, session_view, lap, laptime): lapitem = session_view.append_lap(session_view.session.session_id, lap, laptime) source_key = str(SourceRef(lap, session_view.session.session_id)) if self.selected_laps.get(source_key): lapitem.state = 'down' lapitem.bind(on_press=self.lap_selection) self.current_laps[source_key] = lapitem
def lap_selection(self, instance): source_ref = SourceRef(instance.lap, instance.session) source_key = str(source_ref) selected = instance.state == 'down' if selected: self.selected_laps[source_key] = instance else: self.selected_laps.pop(source_key, None) Clock.schedule_once(lambda dt: self._notify_lap_selected(source_ref, selected)) self._save()
def deselect_other_laps(self, session): ''' Deselect all laps except from the session specified :param session id :type session integer ''' source_refs = [] for instance in self.selected_laps.itervalues(): if instance.session != session: source_refs.append(SourceRef(instance.lap, instance.session)) self.deselect_laps(source_refs)
def get_all_laps(self): ''' Get a list of laps for this session :returns an array of SourceRef objects :type array ''' lap_list = self.ids.lap_list lap_refs = [] for child in lap_list.children: if type(child) is LapItemButton: lap_refs.append(SourceRef(child.lap, child.session)) return lap_refs
def select_lap(self, session_id, lap_id, selected): source_ref = SourceRef(lap_id, session_id) source_key = str(source_ref) lap_instance = self.current_laps.get(str(source_ref)) if lap_instance: lap_instance.state = 'down' if selected else 'normal' self._notify_lap_selected(source_ref, True) # Save our state if selected: self.selected_laps[source_key] = source_ref else: self.selected_laps.pop(source_key, None) self._save()
def select_lap(self, session_id, lap_id, selected): source_ref = SourceRef(lap_id, session_id) lap_instance = self.current_laps.get(str(source_ref)) if lap_instance: lap_instance.state = 'down' if selected else 'normal' self._notify_lap_selected(source_ref, True)