changeset 2124:cf63e4209643

quick frontend(contact list): added all_iter property to get all cached entities
author Goffi <goffi@goffi.org>
date Sun, 15 Jan 2017 22:41:22 +0100
parents c42aab22c2c0
children ca82c97db195
files frontends/src/quick_frontend/quick_contact_list.py
diffstat 1 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_contact_list.py	Sun Jan 15 17:51:37 2017 +0100
+++ b/frontends/src/quick_frontend/quick_contact_list.py	Sun Jan 15 22:41:22 2017 +0100
@@ -171,6 +171,15 @@
         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 @@
         """
         return {jid_:cache for jid_, cache in self._cache.iteritems() if self.entityToShow(jid_)}
 
+
     def getItem(self, entity):
         """Return item representation of requested entity
 
@@ -719,6 +729,18 @@
         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 @@
                 data = cache.copy()
                 items[bare_jid] = data
                 data[C.CONTACT_PROFILE] = profile
-            items.update(contact_list.items)
         return items
 
     @property
@@ -901,6 +922,10 @@
         handler.register(self)
 
     @property
+    def all_iter(self):
+        return handler.all_iter
+
+    @property
     def items(self):
         return handler.items