def success(out: OpChangesWithCount) -> None: if out.count: tooltip(tr.browsing_notes_updated(count=out.count), parent=self) else: showInfo(tr.browsing_tag_rename_warning_empty(), parent=self)
def remove_tags_from_all_notes( *, parent: QWidget, space_separated_tags: str) -> CollectionOp[OpChangesWithCount]: return CollectionOp( parent, lambda col: col.tags.remove(space_separated_tags=space_separated_tags) ).success(lambda out: tooltip(tr.browsing_notes_updated(count=out.count), parent=parent))
def success(out: OpChangesWithCount) -> None: if out.count: tooltip(tr.browsing_notes_updated(count=out.count), parent=self) else: # revert renaming of sidebar item item.full_name = old_full_name item.name = old_name showInfo(tr.browsing_tag_rename_warning_empty(), parent=self)
def remove_tags_from_notes( *, parent: QWidget, note_ids: Sequence[NoteId], space_separated_tags: str, ) -> CollectionOp[OpChangesWithCount]: return CollectionOp( parent, lambda col: col.tags.bulk_remove( note_ids, space_separated_tags)).success(lambda out: tooltip( tr.browsing_notes_updated(count=out.count), parent=parent))
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()
def on_done(op: OpChanges) -> None: tooltip( tr.browsing_notes_updated(count=len(input.note_ids)), parent=self.parentWidget(), ) self.reject()
def reparent_tags(*, parent: QWidget, tags: Sequence[str], new_parent: str) -> CollectionOp[OpChangesWithCount]: return CollectionOp( parent, lambda col: col.tags.reparent(tags=tags, new_parent=new_parent) ).success(lambda out: tooltip(tr.browsing_notes_updated(count=out.count), parent=parent))