Filtration fixed

This commit is contained in:
ingvar1995 2018-06-03 21:18:22 +03:00
parent 56731be79d
commit 41de315496
2 changed files with 13 additions and 4 deletions

View File

@ -320,3 +320,11 @@ class Contact(basecontact.BaseContact):
def get_context_menu_generator(self): def get_context_menu_generator(self):
return BaseContactMenuGenerator(self) return BaseContactMenuGenerator(self)
# -----------------------------------------------------------------------------------------------------------------
# Filtration support
# -----------------------------------------------------------------------------------------------------------------
def set_widget(self, widget):
self._widget = widget
self.init_widget()

View File

@ -154,7 +154,7 @@ class ContactsManager(ToxSave):
def filtration_and_sorting(self, sorting=0, filter_str=''): def filtration_and_sorting(self, sorting=0, filter_str=''):
""" """
Filtration of friends list Filtration of friends list
:param sorting: 0 - no sort, 1 - online only, 2 - online first, 4 - by name :param sorting: 0 - no sorting, 1 - online only, 2 - online first, 4 - by name
:param filter_str: show contacts which name contains this substring :param filter_str: show contacts which name contains this substring
""" """
# TODO: simplify? # TODO: simplify?
@ -183,9 +183,10 @@ class ContactsManager(ToxSave):
part1 = sorted(part1, key=lambda x: x.number) part1 = sorted(part1, key=lambda x: x.number)
part2 = sorted(part2, key=lambda x: x.number) part2 = sorted(part2, key=lambda x: x.number)
self._contacts = part1 + part2 self._contacts = part1 + part2
# self._screen.friends_list.clear() for index, contact in enumerate(self._contacts):
# for contact in self._contacts: list_item = self._screen.friends_list.item(index)
# contact.set_widget(self.create_friend_item()) item_widget = self._screen.friends_list.itemWidget(list_item)
contact.set_widget(item_widget)
for index, friend in enumerate(self._contacts): for index, friend in enumerate(self._contacts):
friend.visibility = (friend.status is not None or not (sorting & 1)) and (filter_str in friend.name.lower()) friend.visibility = (friend.status is not None or not (sorting & 1)) and (filter_str in friend.name.lower())
friend.visibility = friend.visibility or friend.messages or friend.actions friend.visibility = friend.visibility or friend.messages or friend.actions