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 root.add_simple( name=tr.browsing_sidebar_due_today(), icon=icon, type=type, search_node=SearchNode(due_on_day=0), ) root.add_simple( name=tr.browsing_added_today(), icon=icon, type=type, search_node=SearchNode(added_in_days=1), ) root.add_simple( name=tr.browsing_edited_today(), icon=icon, type=type, search_node=SearchNode(edited_in_days=1), ) root.add_simple( name=tr.browsing_studied_today(), icon=icon, type=type, search_node=SearchNode(rated=SearchNode.Rated(days=1)), ) root.add_simple( name=tr.browsing_sidebar_first_review(), icon=icon, type=type, search_node=SearchNode(introduced_in_days=1), ) root.add_simple( name=tr.browsing_again_today(), icon=icon, type=type, search_node=SearchNode( rated=SearchNode.Rated(days=1, rating=SearchNode.RATING_AGAIN) ), ) root.add_simple( name=tr.browsing_sidebar_overdue(), icon=icon, type=type, search_node=self.col.group_searches( SearchNode(card_state=SearchNode.CARD_STATE_DUE), SearchNode(negated=SearchNode(due_on_day=0)), ), )
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(SearchNode(due_on_day=0)), ) root.add_simple( name=TR.BROWSING_ADDED_TODAY, icon=icon, type=type, on_click=search(SearchNode(added_in_days=1)), ) root.add_simple( name=TR.BROWSING_EDITED_TODAY, icon=icon, type=type, on_click=search(SearchNode(edited_in_days=1)), ) root.add_simple( name=TR.BROWSING_STUDIED_TODAY, icon=icon, type=type, on_click=search(SearchNode(rated=SearchNode.Rated(days=1))), ) root.add_simple( name=TR.BROWSING_AGAIN_TODAY, icon=icon, type=type, on_click=search( SearchNode( rated=SearchNode.Rated(days=1, rating=SearchNode.RATING_AGAIN) ) ), ) root.add_simple( name=TR.BROWSING_SIDEBAR_OVERDUE, icon=icon, type=type, on_click=search( SearchNode(card_state=SearchNode.CARD_STATE_DUE), SearchNode(negated=SearchNode(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.by_name(tr.custom_study_custom_study_session()) if cur: if not cur["dyn"]: showInfo(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.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( SearchNode(rated=SearchNode.Rated( days=spin, rating=SearchNode.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( SearchNode(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( SearchNode(card_state=SearchNode.CARD_STATE_NEW), SearchNode(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( SearchNode(card_state=SearchNode.CARD_STATE_NEW)) ord = DYN_ADDED dyn["resched"] = True elif type == TYPE_DUE: terms = self.mw.col.build_search_string( SearchNode(card_state=SearchNode.CARD_STATE_DUE)) ord = DYN_DUE dyn["resched"] = True elif type == TYPE_REVIEW: terms = self.mw.col.build_search_string( SearchNode(negated=SearchNode( card_state=SearchNode.CARD_STATE_NEW))) 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], SearchNode(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.custom_study_no_cards_matched_the_criteria_you()) return self.mw.moveToState("overview") QDialog.accept(self)