self.view.bind(key,no_action)
class SearchableListView(WidgetBasedListView):
- def __init__(self,entry_filters):
- self.current_entry_filter_index = 0
- self.entry_filters = entry_filters
- self.filtered_list = self.entry_filters[0]
+ def __init__(self):
+ self.current_entry_filter_index = -1
+ self.entry_filters = []
+ self.filtered_list = lambda:[]
self.lock = None
super(SearchableListView,self).__init__()
+ def set_filters(self, entry_filters):
+ """
+ Set the filters that could be applied to this list. Each filter
+ can be applied in turn by calling switch_entry_filter (for
+ example from a key binding).
+
+ The entry_filters argument should be a list of filters. The
+ active filter is stored into self.filtered_list and should be
+ processed by generate_widgets in the subclass.
+ """
+ self.current_entry_filter_index = 0
+ self.entry_filters = entry_filters
+ self.filtered_list = self.entry_filters[0]
def search_item(self):
selected_item = appuifw.selection_list(self.all_widget_texts(),search_field=1)
selected_item = self.selected_index()
self.view.set_list(self.items(),selected_item)
self.set_bindings_for_selection(selected_item)
+
def switch_entry_filter(self):
self.current_entry_filter_index += 1
self.filtered_list = self.entry_filters[self.current_entry_filter_index % len(self.entry_filters)]
class EditableListView(SearchableListView,KeyBindingView):
- def __init__(self,entry_filters):
+ def __init__(self):
KeyBindingView.__init__(self)
- super(EditableListView, self).__init__(entry_filters)
+ super(EditableListView, self).__init__()
def key_and_menu_bindings(self,selected_index):
key_and_menu_bindings=[]
def __init__(self,project):
self.project = project
self.project.observers.append(self)
- super(ProjectView, self).__init__([lambda:self.project.actions.with_property(lambda a:a.status==action.active)])
+ super(ProjectView, self).__init__()
self.set_keybindings(ACTION_LIST_KEYS_AND_MENU)
self.set_title(self.project.name)
+ self.set_filters([lambda:self.project.actions.with_property(lambda a:a.status==action.active)])
def exit(self):
self.project.observers.remove(self)
def __init__(self,projects):
self.projects = projects
self.projects.observers.append(self)
- super(ProjectListView, self).__init__([lambda:projects])
+ super(ProjectListView, self).__init__()
self.set_keybindings(PROJECT_LIST_KEYS_AND_MENU)
self.set_title(u'Projects')
+ self.set_filters([lambda:projects])
#appuifw.note(u'Before starting thread')
# thread.start_new_thread(projects.process,())
#appuifw.note(u'After starting thread %s'%repr(projects.observers))