예제 #1
0
 def editHistory(self, nid: int) -> None:
     aqt.dialogs.open("Browser", self.mw, search=(SearchNode(nid=nid),))
예제 #2
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.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)
예제 #3
0
파일: browser.py 프로젝트: tiramisuCzk/anki
 def on_show_single_card() -> None:
     self.card = card
     search = self.col.build_search_string(SearchNode(nid=card.nid))
     search = gui_hooks.default_search(search, card)
     self.search_for(search, "")
     self.table.select_single_card(card.id)
예제 #4
0
파일: tree.py 프로젝트: hgiesel/anki
    def _today_tree(self, root: SidebarItem) -> None:
        icon = "icons:clock-outline.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_sidebar_rescheduled(),
            icon=icon,
            type=type,
            search_node=SearchNode(rated=SearchNode.Rated(
                days=1, rating=SearchNode.RATING_BY_RESCHEDULE)),
        )
        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)),
            ),
        )
예제 #5
0
 def _default_search(self, card: Optional[Card] = None) -> None:
     search = self.col.build_search_string(SearchNode(deck="current"))
     if card is not None:
         search = gui_hooks.default_search(search, card)
     self.search_for(search, "")