Ejemplo n.º 1
0
    def accept(self) -> None:
        saveGeom(self, "findreplace")
        save_combo_index_for_session(self.form.field,
                                     self.COMBO_NAME + "Field")

        search = save_combo_history(self.form.find, self._find_history,
                                    self.COMBO_NAME + "Find")
        replace = save_combo_history(self.form.replace, self._replace_history,
                                     self.COMBO_NAME + "Replace")
        regex = self.form.re.isChecked()
        match_case = not self.form.ignoreCase.isChecked()
        save_is_checked(self.form.re, self.COMBO_NAME + "Regex")
        save_is_checked(self.form.ignoreCase, self.COMBO_NAME + "ignoreCase")

        if not self.form.selected_notes.isChecked():
            # an empty list means *all* notes
            self.note_ids = []

        # tags?
        if self.form.field.currentIndex() == 1:
            op = find_and_replace_tag(
                parent=self.parentWidget(),
                note_ids=self.note_ids,
                search=search,
                replacement=replace,
                regex=regex,
                match_case=match_case,
            )
        else:
            # fields
            if self.form.field.currentIndex() == 0:
                field = None
            else:
                field = self.field_names[self.form.field.currentIndex()]

            op = find_and_replace(
                parent=self.parentWidget(),
                note_ids=self.note_ids,
                search=search,
                replacement=replace,
                regex=regex,
                field_name=field,
                match_case=match_case,
            )

        if not self.note_ids:
            op.success(lambda out: tooltip(
                tr.browsing_notes_updated(count=out.count),
                parent=self.parentWidget(),
            ))
        op.run_in_background()

        super().accept()
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
    def accept(self) -> None:
        saveGeom(self, "findreplace")
        save_combo_index_for_session(self.form.field, self.COMBO_NAME + "Field")

        search = save_combo_history(
            self.form.find, self._find_history, self.COMBO_NAME + "Find"
        )
        replace = save_combo_history(
            self.form.replace, self._replace_history, self.COMBO_NAME + "Replace"
        )
        regex = self.form.re.isChecked()
        match_case = not self.form.ignoreCase.isChecked()
        save_is_checked(self.form.re, self.COMBO_NAME + "Regex")
        save_is_checked(self.form.ignoreCase, self.COMBO_NAME + "ignoreCase")

        if self.form.field.currentIndex() == 1:
            # tags
            find_and_replace_tag(
                mw=self.mw,
                parent=self.parentWidget(),
                note_ids=self.note_ids,
                search=search,
                replacement=replace,
                regex=regex,
                match_case=match_case,
            )
            return

        if self.form.field.currentIndex() == 0:
            field = None
        else:
            field = self.field_names[self.form.field.currentIndex() - 2]

        find_and_replace(
            mw=self.mw,
            parent=self.parentWidget(),
            note_ids=self.note_ids,
            search=search,
            replacement=replace,
            regex=regex,
            field_name=field,
            match_case=match_case,
        )

        super().accept()
Ejemplo n.º 4
0
 def save_history(self):
     save_combo_history(self.f.input_find, self.find_history,
                        self.combo + "Find")
     save_combo_history(self.f.input_replace, self.replace_history,
                        self.combo + "Replace")