Mercurial > libervia-backend
comparison sat_frontends/primitivus/contact_list.py @ 2617:81b70eeb710f
quick_frontend(contact list): refactored update:
update is now called with appropriate constant value (C.UPDATE_ADD, C.UPDATE_DELETE, C.UPDATE_MODIFY and so on) when a widget change visibility according to current options.
Before it was linked to cache only (C.UPDATE_ADD was only called when contact was first added to cache).
This make widget handling in frontends more easy.
Renamed entityToShow to entityVisible, which seems to correspond better.
Started reducing lines lenght to 90 chars as a test. May become the new coding style soon.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 24 Jun 2018 21:59:29 +0200 |
parents | 26edcf3a30eb |
children | 56f94936df1e |
comparison
equal
deleted
inserted
replaced
2616:1cc88adb5142 | 2617:81b70eeb710f |
---|---|
229 if not entities: | 229 if not entities: |
230 return | 230 return |
231 widgets = [] # list of built widgets | 231 widgets = [] # list of built widgets |
232 | 232 |
233 for entity in entities: | 233 for entity in entities: |
234 if entity in self.contact_list._specials or not self.contact_list.entityToShow(entity): | 234 if entity in self.contact_list._specials or not self.contact_list.entityVisible(entity): |
235 continue | 235 continue |
236 markup_extra = [] | 236 markup_extra = [] |
237 if self.contact_list.show_resources: | 237 if self.contact_list.show_resources: |
238 for resource in self.contact_list.getCache(entity, C.CONTACT_RESOURCES): | 238 for resource in self.contact_list.getCache(entity, C.CONTACT_RESOURCES): |
239 resource_disp = ('resource_main' if resource == self.contact_list.getCache(entity, C.CONTACT_MAIN_RESOURCE) else 'resource', "\n " + resource) | 239 resource_disp = ('resource_main' if resource == self.contact_list.getCache(entity, C.CONTACT_MAIN_RESOURCE) else 'resource', "\n " + resource) |
285 groups.sort(key=lambda x: x.lower() if x else x) | 285 groups.sort(key=lambda x: x.lower() if x else x) |
286 for group in groups: | 286 for group in groups: |
287 data = self.contact_list.getGroupData(group) | 287 data = self.contact_list.getGroupData(group) |
288 folded = data.get(C.GROUP_DATA_FOLDED, False) | 288 folded = data.get(C.GROUP_DATA_FOLDED, False) |
289 jids = list(data['jids']) | 289 jids = list(data['jids']) |
290 if group is not None and (self.contact_list.anyEntityToShow(jids) or self.contact_list.show_empty_groups): | 290 if group is not None and (self.contact_list.anyEntityVisible(jids) or self.contact_list.show_empty_groups): |
291 header = '[-]' if not folded else '[+]' | 291 header = '[-]' if not folded else '[+]' |
292 widget = sat_widgets.ClickableText(group, header=header + ' ') | 292 widget = sat_widgets.ClickableText(group, header=header + ' ') |
293 content.append(widget) | 293 content.append(widget) |
294 urwid.connect_signal(widget, 'click', self._groupClicked) | 294 urwid.connect_signal(widget, 'click', self._groupClicked) |
295 if not folded: | 295 if not folded: |