comparison frontends/src/quick_frontend/quick_contact_list.py @ 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 8b37a62336c3
comparison
equal deleted inserted replaced
2123:c42aab22c2c0 2124:cf63e4209643
169 @return (set): set of selected entities 169 @return (set): set of selected entities
170 """ 170 """
171 return self._selected 171 return self._selected
172 172
173 @property 173 @property
174 def all_iter(self):
175 """return all know entities in cache as an iterator of tuples
176
177 entities are not sorted
178 """
179 return self._cache.iteritems()
180
181
182 @property
174 def items(self): 183 def items(self):
175 """Return item representation for all visible entities in cache 184 """Return item representation for all visible entities in cache
176 185
177 entities are not sorted 186 entities are not sorted
178 key: bare jid, value: data 187 key: bare jid, value: data
179 """ 188 """
180 return {jid_:cache for jid_, cache in self._cache.iteritems() if self.entityToShow(jid_)} 189 return {jid_:cache for jid_, cache in self._cache.iteritems() if self.entityToShow(jid_)}
190
181 191
182 def getItem(self, entity): 192 def getItem(self, entity):
183 """Return item representation of requested entity 193 """Return item representation of requested entity
184 194
185 @param entity(jid.JID): bare jid of entity 195 @param entity(jid.JID): bare jid of entity
717 for contact_list in self._clist.itervalues(): 727 for contact_list in self._clist.itervalues():
718 entities.update(contact_list.selected) 728 entities.update(contact_list.selected)
719 return entities 729 return entities
720 730
721 @property 731 @property
732 def all_iter(self):
733 """Return item representation for all entities in cache
734
735 items are unordered
736 """
737 for profile, contact_list in self._clist.iteritems():
738 for bare_jid, cache in contact_list.all_iter:
739 data = cache.copy()
740 data[C.CONTACT_PROFILE] = profile
741 yield bare_jid, data
742
743 @property
722 def items(self): 744 def items(self):
723 """Return item representation for visible entities in cache 745 """Return item representation for visible entities in cache
724 746
725 items are unordered 747 items are unordered
726 key: bare jid, value: data 748 key: bare jid, value: data
729 for profile, contact_list in self._clist.iteritems(): 751 for profile, contact_list in self._clist.iteritems():
730 for bare_jid, cache in contact_list.items.iteritems(): 752 for bare_jid, cache in contact_list.items.iteritems():
731 data = cache.copy() 753 data = cache.copy()
732 items[bare_jid] = data 754 items[bare_jid] = data
733 data[C.CONTACT_PROFILE] = profile 755 data[C.CONTACT_PROFILE] = profile
734 items.update(contact_list.items)
735 return items 756 return items
736 757
737 @property 758 @property
738 def items_sorted(self): 759 def items_sorted(self):
739 """Return item representation for visible entities in cache 760 """Return item representation for visible entities in cache
897 self.show_status = None # TODO 918 self.show_status = None # TODO
898 919
899 def postInit(self): 920 def postInit(self):
900 """Method to be called by frontend after widget is initialised""" 921 """Method to be called by frontend after widget is initialised"""
901 handler.register(self) 922 handler.register(self)
923
924 @property
925 def all_iter(self):
926 return handler.all_iter
902 927
903 @property 928 @property
904 def items(self): 929 def items(self):
905 return handler.items 930 return handler.items
906 931