From dc4e3c9d8ce7e511858f0e3868814d565c9afc10 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 15 Jan 2017 22:41:22 +0100 Subject: [PATCH] quick frontend(contact list): added all_iter property to get all cached entities --- .../src/quick_frontend/quick_contact_list.py | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/frontends/src/quick_frontend/quick_contact_list.py b/frontends/src/quick_frontend/quick_contact_list.py index 17742f16..8a88d3f3 100644 --- a/frontends/src/quick_frontend/quick_contact_list.py +++ b/frontends/src/quick_frontend/quick_contact_list.py @@ -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