def _show(self, field_names: Sequence[str]) -> None: # add "all fields" and "tags" to the top of the list self.field_names = [ tr(TR.BROWSING_ALL_FIELDS), tr(TR.EDITING_TAGS), ] + list(field_names) disable_help_button(self) self.form = aqt.forms.findreplace.Ui_Dialog() self.form.setupUi(self) self.setWindowModality(Qt.WindowModal) self._find_history = restore_combo_history( self.form.find, self.COMBO_NAME + "Find" ) self.form.find.completer().setCaseSensitivity(True) self._replace_history = restore_combo_history( self.form.replace, self.COMBO_NAME + "Replace" ) self.form.replace.completer().setCaseSensitivity(True) restore_is_checked(self.form.re, self.COMBO_NAME + "Regex") restore_is_checked(self.form.ignoreCase, self.COMBO_NAME + "ignoreCase") self.form.field.addItems(self.field_names) restore_combo_index_for_session( self.form.field, self.field_names, self.COMBO_NAME + "Field" ) qconnect(self.form.buttonBox.helpRequested, self.show_help) restoreGeom(self, "findreplace") self.show() self.form.find.setFocus()
def restore_history(self): self.find_history = restore_combo_history(self.f.input_find, self.combo + "Find") self.f.input_find.completer().setCaseSensitivity(True) self.replace_history = restore_combo_history(self.f.input_replace, self.combo + "Replace") self.f.input_replace.completer().setCaseSensitivity(True)
def _show(self, field_names: Sequence[str]) -> None: # add "all fields" and "tags" to the top of the list self.field_names = [ tr.browsing_all_fields(), tr.editing_tags(), ] + list(field_names) disable_help_button(self) self.form = aqt.forms.findreplace.Ui_Dialog() self.form.setupUi(self) self.setWindowModality(Qt.WindowModality.WindowModal) self._find_history = restore_combo_history(self.form.find, self.COMBO_NAME + "Find") self.form.find.completer().setCaseSensitivity( Qt.CaseSensitivity.CaseSensitive) self._replace_history = restore_combo_history( self.form.replace, self.COMBO_NAME + "Replace") self.form.replace.completer().setCaseSensitivity( Qt.CaseSensitivity.CaseSensitive) if not self.note_ids: # no selected notes to affect self.form.selected_notes.setChecked(False) self.form.selected_notes.setEnabled(False) elif self._field: self.form.selected_notes.setChecked(False) restore_is_checked(self.form.re, self.COMBO_NAME + "Regex") restore_is_checked(self.form.ignoreCase, self.COMBO_NAME + "ignoreCase") self.form.field.addItems(self.field_names) if self._field: self.form.field.setCurrentIndex(self.field_names.index( self._field)) else: restore_combo_index_for_session(self.form.field, self.field_names, self.COMBO_NAME + "Field") qconnect(self.form.buttonBox.helpRequested, self.show_help) restoreGeom(self, "findreplace") self.show() self.form.find.setFocus()
def onFindDupes(self) -> None: import anki.find d = QDialog(self) self.mw.garbage_collect_on_dialog_finish(d) frm = aqt.forms.finddupes.Ui_Dialog() frm.setupUi(d) restoreGeom(d, "findDupes") disable_help_button(d) searchHistory = restore_combo_history(frm.search, "findDupesFind") fields = sorted(anki.find.fieldNames(self.col, downcase=False), key=lambda x: x.lower()) frm.fields.addItems(fields) restore_combo_index_for_session(frm.fields, fields, "findDupesFields") self._dupesButton: Optional[QPushButton] = None # links frm.webView.set_title("find duplicates") web_context = FindDupesDialog(dialog=d, browser=self) frm.webView.set_bridge_command(self.dupeLinkClicked, web_context) frm.webView.stdHtml("", context=web_context) def onFin(code: Any) -> None: saveGeom(d, "findDupes") qconnect(d.finished, onFin) def onClick() -> None: search_text = save_combo_history(frm.search, searchHistory, "findDupesFind") save_combo_index_for_session(frm.fields, "findDupesFields") field = fields[frm.fields.currentIndex()] self.duplicatesReport(frm.webView, field, search_text, frm, web_context) search = frm.buttonBox.addButton(tr.actions_search(), QDialogButtonBox.ActionRole) qconnect(search.clicked, onClick) d.show()