def enable_lazy_search(self): self._lazy_updater = LazyObjectListUpdater( search=self._search, objectlist=self)
class SearchResultListView(ObjectList): """ This class implements the ISearchResultView interface on top of a ObjectList. """ __gtype_name__ = 'SearchResultListView' gsignal("item-activated", object) gsignal("item-popup-menu", object, object) def __init__(self): self._lazy_updater = None ObjectList.__init__(self) self.connect('double-click', self._on__double_click) self.connect('row-activated', self._on__row_activated) self.connect('right-click', self._on__right_click) # # ISearchResultView # def attach(self, search, columns): self._search = search self.set_columns(columns) def enable_lazy_search(self): self._lazy_updater = LazyObjectListUpdater( search=self._search, objectlist=self) def get_n_items(self): return len(self.get_model()) def search_completed(self, results): if self._lazy_updater: self._lazy_updater.add_results(results) else: self.extend(results) summary_label = self._search.get_summary_label() if summary_label is None: return if self._lazy_updater and len(self): post = self.get_model().get_post_data() if post is not None: summary_label.update_total(post.sum) else: summary_label.update_total() def get_settings(self): d = {} _serialize_columns(self.get_treeview(), d) return d def get_selected_item(self): return self.get_selected() # # Callbacks # def _on__double_click(self, object_list, item): self.emit('item-activated', item) def _on__row_activated(self, object_list, item): self.emit('item-activated', item) def _on__right_click(self, object_list, results, event): self.emit('item-popup-menu', results, event)