quick frontend(contact list): added all_iter property to get all cached entities

This commit is contained in:
Goffi 2017-01-15 22:41:22 +01:00
commit dc4e3c9d8c

View file

@ -170,6 +170,15 @@ class ProfileContactList(object):
"""
return self._selected
@property
def all_iter(self):
"""return all know entities in cache as an iterator of tuples
entities are not sorted
"""
return self._cache.iteritems()
@property
def items(self):
"""Return item representation for all visible entities in cache
@ -179,6 +188,7 @@ class ProfileContactList(object):
"""
return {jid_:cache for jid_, cache in self._cache.iteritems() if self.entityToShow(jid_)}
def getItem(self, entity):
"""Return item representation of requested entity
@ -718,6 +728,18 @@ class QuickContactListHandler(object):
entities.update(contact_list.selected)
return entities
@property
def all_iter(self):
"""Return item representation for all entities in cache
items are unordered
"""
for profile, contact_list in self._clist.iteritems():
for bare_jid, cache in contact_list.all_iter:
data = cache.copy()
data[C.CONTACT_PROFILE] = profile
yield bare_jid, data
@property
def items(self):
"""Return item representation for visible entities in cache
@ -731,7 +753,6 @@ class QuickContactListHandler(object):
data = cache.copy()
items[bare_jid] = data
data[C.CONTACT_PROFILE] = profile
items.update(contact_list.items)
return items
@property
@ -900,6 +921,10 @@ class QuickContactList(QuickWidget):
"""Method to be called by frontend after widget is initialised"""
handler.register(self)
@property
def all_iter(self):
return handler.all_iter
@property
def items(self):
return handler.items