def get_documents(self, db): """ return the database docids for the given category """ enq = AppEnquire(db._aptcache, db) app_filter = AppFilter(db, db._aptcache) if "available-only" in self.flags: app_filter.set_available_only(True) if "not-installed-only" in self.flags: app_filter.set_not_installed_only(True) enq.set_query(self.query, limit=self.item_limit, filter=app_filter, sortmode=self.sortmode, nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE, nonblocking_load=False) return enq.get_documents()
def _get_new_category_content(self): whatsnew_cat = get_category_by_name( self.categories, u"What\u2019s New") # unstranslated name if whatsnew_cat is None: LOG.warn("No 'new' category found!!") return None, [] enq = AppEnquire(self.cache, self.db) app_filter = AppFilter(self.db, self.cache) app_filter.set_available_only(True) app_filter.set_not_installed_only(True) enq.set_query(whatsnew_cat.query, limit=8, filter=app_filter, sortmode=SortMethods.BY_CATALOGED_TIME, nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE, nonblocking_load=False) if not hasattr(self, "helper"): self.helper = AppPropertiesHelper(self.db, self.cache, self.icons) return whatsnew_cat, enq.get_documents()
def _get_new_category_content(self): whatsnew_cat = get_category_by_name(self.categories, u"What\u2019s New") # unstranslated name if whatsnew_cat is None: LOG.warn("No 'new' category found!!") return None, [] enq = AppEnquire(self.cache, self.db) app_filter = AppFilter(self.db, self.cache) app_filter.set_available_only(True) app_filter.set_not_installed_only(True) enq.set_query(whatsnew_cat.query, limit=8, filter=app_filter, sortmode=SortMethods.BY_CATALOGED_TIME, nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE, nonblocking_load=False) if not hasattr(self, "helper"): self.helper = AppPropertiesHelper(self.db, self.cache, self.icons) return whatsnew_cat, enq.get_documents()
def rebuild_oneconfview(): # FIXME for P: hide the search entry self.searchentry.hide() self.cat_docid_map = {} enq = self.enquirer query = xapian.Query("") if self.state.channel and self.state.channel.query: query = xapian.Query(xapian.Query.OP_AND, query, self.state.channel.query) i = 0 # First search: missing apps only xfilter = AppFilter(self.db, self.cache) xfilter.set_restricted_list(self.oneconf_additional_pkg) xfilter.set_not_installed_only(True) enq.set_query( query, sortmode=SortMethods.BY_ALPHABET, nonapps_visible=self.nonapps_visible, filter=xfilter, nonblocking_load=True, # we don't block this one for # better oneconf responsiveness persistent_duplicate_filter=(i > 0), ) L = len(enq.matches) if L: cat_title = utf8( ngettext( u"%(amount)s item on “%(machine)s” not on this computer", u"%(amount)s items on “%(machine)s” not on this computer", L, ) ) % {"amount": L, "machine": utf8(self.current_hostname)} i += L docs = enq.get_documents() self.cat_docid_map["missingpkg"] = set([doc.get_docid() for doc in docs]) model.set_nocategory_documents(docs, untranslated_name="additionalpkg", display_name=cat_title) # Second search: additional apps xfilter.set_restricted_list(self.oneconf_missing_pkg) xfilter.set_not_installed_only(False) xfilter.set_installed_only(True) enq.set_query( query, sortmode=SortMethods.BY_ALPHABET, nonapps_visible=self.nonapps_visible, filter=xfilter, nonblocking_load=False, persistent_duplicate_filter=(i > 0), ) L = len(enq.matches) if L: cat_title = utf8( ngettext( u"%(amount)s item on this computer not on “%(machine)s”", "%(amount)s items on this computer not on “%(machine)s”", L, ) ) % {"amount": L, "machine": utf8(self.current_hostname)} i += L docs = enq.get_documents() self.cat_docid_map["additionalpkg"] = set([doc.get_docid() for doc in docs]) model.set_nocategory_documents(docs, untranslated_name="additionalpkg", display_name=cat_title) if i: self.app_view.tree_view.set_cursor(Gtk.TreePath(), None, False) if i <= 10: self.app_view.tree_view.expand_all() # cache the installed app count self.installed_count = i self.app_view._append_appcount(self.installed_count, mode=AppView.DIFF_MODE) self.app_view.set_model(self.treefilter) if keep_state: self._restore_treeview_state(treeview_state) # hide the local spinner self.hide_installed_view_spinner() if window: window.set_cursor(None) self.emit("app-list-changed", i) return
def rebuild_oneconfview(): # FIXME for P: hide the search entry self.searchentry.hide() self.cat_docid_map = {} enq = self.enquirer query = xapian.Query("") if self.state.channel and self.state.channel.query: query = xapian.Query(xapian.Query.OP_AND, query, self.state.channel.query) i = 0 # First search: missing apps only xfilter = AppFilter(self.db, self.cache) xfilter.set_restricted_list(self.oneconf_additional_pkg) xfilter.set_not_installed_only(True) enq.set_query( query, sortmode=SortMethods.BY_ALPHABET, nonapps_visible=self.nonapps_visible, filter=xfilter, nonblocking_load=True, # we don't block this one for # better oneconf responsiveness persistent_duplicate_filter=(i > 0)) L = len(enq.matches) if L: cat_title = utf8( ngettext( u'%(amount)s item on “%(machine)s” not on this computer', u'%(amount)s items on “%(machine)s” not on this computer', L)) % { 'amount': L, 'machine': utf8(self.current_hostname) } i += L docs = enq.get_documents() self.cat_docid_map["missingpkg"] = set( [doc.get_docid() for doc in docs]) model.set_nocategory_documents( docs, untranslated_name="additionalpkg", display_name=cat_title) # Second search: additional apps xfilter.set_restricted_list(self.oneconf_missing_pkg) xfilter.set_not_installed_only(False) xfilter.set_installed_only(True) enq.set_query(query, sortmode=SortMethods.BY_ALPHABET, nonapps_visible=self.nonapps_visible, filter=xfilter, nonblocking_load=False, persistent_duplicate_filter=(i > 0)) L = len(enq.matches) if L: cat_title = utf8( ngettext( u'%(amount)s item on this computer not on “%(machine)s”', '%(amount)s items on this computer not on “%(machine)s”', L)) % { 'amount': L, 'machine': utf8(self.current_hostname) } i += L docs = enq.get_documents() self.cat_docid_map["additionalpkg"] = set( [doc.get_docid() for doc in docs]) model.set_nocategory_documents( docs, untranslated_name="additionalpkg", display_name=cat_title) if i: self.app_view.tree_view.set_cursor(Gtk.TreePath(), None, False) if i <= 10: self.app_view.tree_view.expand_all() # cache the installed app count self.installed_count = i self.app_view._append_appcount(self.installed_count, mode=AppView.DIFF_MODE) self.app_view.set_model(self.treefilter) if keep_state: self._restore_treeview_state(treeview_state) # hide the local spinner self.hide_installed_view_spinner() if window: window.set_cursor(None) self.emit("app-list-changed", i) return