示例#1
0
 def show_duplicates_report(self, dupes: list[tuple[str,
                                                    list[NoteId]]]) -> None:
     self._dupes = dupes
     if not self._dupesButton:
         self._dupesButton = b = self.form.buttonBox.addButton(
             tr.browsing_tag_duplicates(),
             QDialogButtonBox.ButtonRole.ActionRole)
         qconnect(b.clicked, self._tag_duplicates)
     text = ""
     groups = len(dupes)
     notes = sum(len(r[1]) for r in dupes)
     part1 = tr.browsing_group(count=groups)
     part2 = tr.browsing_note_count(count=notes)
     text += tr.browsing_found_as_across_bs(part=part1, whole=part2)
     text += "<p><ol>"
     for val, nids in dupes:
         text += (
             """<li><a href=# onclick="pycmd('%s');return false;">%s</a>: %s</a>"""
             % (
                 html.escape(
                     self.mw.col.build_search_string(
                         SearchNode(nids=SearchNode.IdList(ids=nids)))),
                 tr.browsing_note_count(count=len(nids)),
                 html.escape(val),
             ))
     text += "</ol>"
     self.form.webView.stdHtml(text, context=self)
示例#2
0
文件: browser.py 项目: RumovZ/anki
 def selectNotes(self) -> None:
     nids = self.selected_notes()
     # clear the selection so we don't waste energy preserving it
     self.table.clear_selection()
     search = self.col.build_search_string(
         SearchNode(nids=SearchNode.IdList(ids=nids)))
     self.search_for(search)
     self.table.select_all()
示例#3
0
 def duplicatesReport(
     self,
     web: AnkiWebView,
     fname: str,
     search: str,
     frm: aqt.forms.finddupes.Ui_Dialog,
     web_context: FindDupesDialog,
 ) -> None:
     self.mw.progress.start()
     try:
         res = self.mw.col.findDupes(fname, search)
     except Exception as e:
         self.mw.progress.finish()
         showWarning(str(e))
         return
     if not self._dupesButton:
         self._dupesButton = b = frm.buttonBox.addButton(
             tr.browsing_tag_duplicates(), QDialogButtonBox.ActionRole
         )
         qconnect(b.clicked, lambda: self._onTagDupes(res))
     t = ""
     groups = len(res)
     notes = sum(len(r[1]) for r in res)
     part1 = tr.browsing_group(count=groups)
     part2 = tr.browsing_note_count(count=notes)
     t += tr.browsing_found_as_across_bs(part=part1, whole=part2)
     t += "<p><ol>"
     for val, nids in res:
         t += (
             """<li><a href=# onclick="pycmd('%s');return false;">%s</a>: %s</a>"""
             % (
                 html.escape(
                     self.col.build_search_string(
                         SearchNode(nids=SearchNode.IdList(ids=nids))
                     )
                 ),
                 tr.browsing_note_count(count=len(nids)),
                 html.escape(val),
             )
         )
     t += "</ol>"
     web.stdHtml(t, context=web_context)
     self.mw.progress.finish()