示例#1
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()
示例#2
0
文件: models.py 项目: v-limc/anki
    def updateModelsList(self, notetypes: Sequence[NotetypeNameIdUseCount]) -> None:
        row = self.form.modelsList.currentRow()
        if row == -1:
            row = 0
        self.form.modelsList.clear()

        self.models = notetypes
        for m in self.models:
            mUse = tr.browsing_note_count(count=m.use_count)
            item = QListWidgetItem(f"{m.name} [{mUse}]")
            self.form.modelsList.addItem(item)
        self.form.modelsList.setCurrentRow(row)
示例#3
0
    def onDelete(self) -> None:
        if len(self.model["flds"]) < 2:
            showWarning(tr.fields_notes_require_at_least_one_field())
            return
        count = self.mm.useCount(self.model)
        c = tr.browsing_note_count(count=count)
        if not askUser(tr.fields_delete_field_from(val=c)):
            return
        if not self.change_tracker.mark_schema():
            return
        f = self.model["flds"][self.form.fieldList.currentRow()]
        self.mm.remove_field(self.model, f)
        gui_hooks.fields_did_delete_field(self, f)

        self.fillFields()
        self.form.fieldList.setCurrentRow(0)