Mercurial > libervia-desktop-kivy
comparison src/cagou/plugins/plugin_wid_contact_list.py @ 50:c45d6e9ec731
contact list: fixed contact list display
fixed height, and left align everything.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 10 Sep 2016 18:01:32 +0200 |
parents | b9ee3bf81018 |
children | 9a6121722669 |
comparison
equal
deleted
inserted
replaced
49:fd9cbf6ae663 | 50:c45d6e9ec731 |
---|---|
48 class ContactItem(BoxLayout): | 48 class ContactItem(BoxLayout): |
49 data = properties.DictProperty() | 49 data = properties.DictProperty() |
50 jid = properties.StringProperty('') | 50 jid = properties.StringProperty('') |
51 | 51 |
52 def __init__(self, **kwargs): | 52 def __init__(self, **kwargs): |
53 BoxLayout.__init__(self, **kwargs) | 53 super(ContactItem, self).__init__(**kwargs) |
54 | 54 |
55 def on_touch_down(self, touch): | 55 def on_touch_down(self, touch): |
56 if self.collide_point(*touch.pos): | 56 if self.collide_point(*touch.pos): |
57 # XXX: for now clicking on an item launch the corresponding Chat widget | 57 # XXX: for now clicking on an item launch the corresponding Chat widget |
58 # behaviour should change in the future | 58 # behaviour should change in the future |
65 else: | 65 else: |
66 factory = plg_infos['factory'] | 66 factory = plg_infos['factory'] |
67 G.host.switchWidget(self, factory(plg_infos, jid.JID(self.jid), profiles=iter(G.host.profiles))) | 67 G.host.switchWidget(self, factory(plg_infos, jid.JID(self.jid), profiles=iter(G.host.profiles))) |
68 | 68 |
69 | 69 |
70 class ContactListView(ListView): | |
71 pass | |
72 | |
70 | 73 |
71 class ContactList(QuickContactList, cagou_widget.CagouWidget): | 74 class ContactList(QuickContactList, cagou_widget.CagouWidget): |
72 | 75 |
73 def __init__(self, host, target, profiles): | 76 def __init__(self, host, target, profiles): |
74 QuickContactList.__init__(self, G.host, profiles) | 77 QuickContactList.__init__(self, G.host, profiles) |
77 cls=ContactItem, | 80 cls=ContactItem, |
78 args_converter=self.contactDataConverter, | 81 args_converter=self.contactDataConverter, |
79 selection_mode='multiple', | 82 selection_mode='multiple', |
80 allow_empty_selection=True, | 83 allow_empty_selection=True, |
81 ) | 84 ) |
82 self.add_widget(ListView(adapter=self.adapter)) | 85 self.add_widget(ContactListView(adapter=self.adapter)) |
83 self.postInit() | 86 self.postInit() |
84 self.update() | 87 self.update() |
85 | 88 |
86 def contactDataConverter(self, idx, bare_jid): | 89 def contactDataConverter(self, idx, bare_jid): |
87 return {"jid": bare_jid, "data": self._items_cache[bare_jid]} | 90 return {"jid": bare_jid, "data": self._items_cache[bare_jid]} |
88 | 91 |
89 def update(self, entities=None, type_=None, profile=None): | 92 def update(self, entities=None, type_=None, profile=None): |
90 log.info("update: %s %s %s" % (entities, type_, profile)) | 93 log.debug("update: %s %s %s" % (entities, type_, profile)) |
91 # FIXME: for now we update on each event | 94 # FIXME: for now we update on each event |
92 # if entities is None and type_ is None: | 95 # if entities is None and type_ is None: |
93 self._items_cache = self.items | 96 self._items_cache = self.items_sorted |
94 self.adapter.data = self.items_sorted | 97 self.adapter.data = self.items_sorted.keys() |
95 | 98 |