def _today_tree(self, root: SidebarItem) -> None: icon = ":/icons/clock.svg" root = self._section_root( root=root, name=TR.BROWSING_TODAY, icon=icon, collapse_key=Config.Bool.COLLAPSE_TODAY, type=SidebarItemType.TODAY_ROOT, ) type = SidebarItemType.TODAY search = self._filter_func root.add_simple( name=TR.BROWSING_SIDEBAR_DUE_TODAY, icon=icon, type=type, on_click=search(SearchTerm(due_on_day=0)), ) root.add_simple( name=TR.BROWSING_ADDED_TODAY, icon=icon, type=type, on_click=search(SearchTerm(added_in_days=1)), ) root.add_simple( name=TR.BROWSING_EDITED_TODAY, icon=icon, type=type, on_click=search(SearchTerm(edited_in_days=1)), ) root.add_simple( name=TR.BROWSING_STUDIED_TODAY, icon=icon, type=type, on_click=search(SearchTerm(rated=SearchTerm.Rated(days=1))), ) root.add_simple( name=TR.BROWSING_AGAIN_TODAY, icon=icon, type=type, on_click=search( SearchTerm(rated=SearchTerm.Rated( days=1, rating=SearchTerm.RATING_AGAIN))), ) root.add_simple( name=TR.BROWSING_SIDEBAR_OVERDUE, icon=icon, type=type, on_click=search( SearchTerm(card_state=SearchTerm.CARD_STATE_DUE), SearchTerm(negated=SearchTerm(due_on_day=0)), ), )
def accept(self) -> None: f = self.form i = self.radioIdx spin = f.spin.value() if i == RADIO_NEW: self.deck["extendNew"] = spin self.mw.col.decks.save(self.deck) self.mw.col.sched.extendLimits(spin, 0) self.mw.reset() QDialog.accept(self) return elif i == RADIO_REV: self.deck["extendRev"] = spin self.mw.col.decks.save(self.deck) self.mw.col.sched.extendLimits(0, spin) self.mw.reset() QDialog.accept(self) return elif i == RADIO_CRAM: tags = self._getTags() # the rest create a filtered deck cur = self.mw.col.decks.byName(tr( TR.CUSTOM_STUDY_CUSTOM_STUDY_SESSION)) if cur: if not cur["dyn"]: showInfo(tr(TR.CUSTOM_STUDY_MUST_RENAME_DECK)) QDialog.accept(self) return else: # safe to empty self.mw.col.sched.empty_filtered_deck(cur["id"]) # reuse; don't delete as it may have children dyn = cur self.mw.col.decks.select(cur["id"]) else: did = self.mw.col.decks.new_filtered( tr(TR.CUSTOM_STUDY_CUSTOM_STUDY_SESSION)) dyn = self.mw.col.decks.get(did) # and then set various options if i == RADIO_FORGOT: search = self.mw.col.build_search_string( SearchTerm(rated=SearchTerm.Rated( days=spin, rating=SearchTerm.RATING_AGAIN))) dyn["terms"][0] = [search, DYN_MAX_SIZE, DYN_RANDOM] dyn["resched"] = False elif i == RADIO_AHEAD: search = self.mw.col.build_search_string( SearchTerm(due_in_days=spin)) dyn["terms"][0] = [search, DYN_MAX_SIZE, DYN_DUE] dyn["resched"] = True elif i == RADIO_PREVIEW: search = self.mw.col.build_search_string( SearchTerm(card_state=SearchTerm.CARD_STATE_NEW), SearchTerm(added_in_days=spin), ) dyn["terms"][0] = [search, DYN_MAX_SIZE, DYN_OLDEST] dyn["resched"] = False elif i == RADIO_CRAM: type = f.cardType.currentRow() if type == TYPE_NEW: terms = self.mw.col.build_search_string( SearchTerm(card_state=SearchTerm.CARD_STATE_NEW)) ord = DYN_ADDED dyn["resched"] = True elif type == TYPE_DUE: terms = self.mw.col.build_search_string( SearchTerm(card_state=SearchTerm.CARD_STATE_DUE)) ord = DYN_DUE dyn["resched"] = True elif type == TYPE_REVIEW: terms = self.mw.col.build_search_string( SearchTerm(card_state=SearchTerm.CARD_STATE_NEW), negate=True) ord = DYN_RANDOM dyn["resched"] = True else: terms = "" ord = DYN_RANDOM dyn["resched"] = False dyn["terms"][0] = [(terms + tags).strip(), spin, ord] # add deck limit dyn["terms"][0][0] = self.mw.col.build_search_string( dyn["terms"][0][0], SearchTerm(deck=self.deck["name"])) self.mw.col.decks.save(dyn) # generate cards self.created_custom_study = True if not self.mw.col.sched.rebuild_filtered_deck(dyn["id"]): showWarning(tr(TR.CUSTOM_STUDY_NO_CARDS_MATCHED_THE_CRITERIA_YOU)) return self.mw.moveToState("overview") QDialog.accept(self)