mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00

remove_note() now returns the count of removed cards, allowing us to unify the tooltip between browser and review screen I've left the old translation in - we'll need to write a script at one point that gathers all references to translations in the code, and shows ones that are unused.
36 lines
1 KiB
Python
36 lines
1 KiB
Python
# Copyright: Ankitects Pty Ltd and contributors
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Sequence
|
|
|
|
from anki.collection import OpChanges, OpChangesWithCount
|
|
from anki.decks import DeckId
|
|
from anki.notes import Note, NoteId
|
|
from aqt.operations import CollectionOp
|
|
from aqt.qt import QWidget
|
|
from aqt.utils import tooltip, tr
|
|
|
|
|
|
def add_note(
|
|
*,
|
|
parent: QWidget,
|
|
note: Note,
|
|
target_deck_id: DeckId,
|
|
) -> CollectionOp[OpChanges]:
|
|
return CollectionOp(parent, lambda col: col.add_note(note, target_deck_id))
|
|
|
|
|
|
def update_note(*, parent: QWidget, note: Note) -> CollectionOp[OpChanges]:
|
|
return CollectionOp(parent, lambda col: col.update_note(note))
|
|
|
|
|
|
def remove_notes(
|
|
*,
|
|
parent: QWidget,
|
|
note_ids: Sequence[NoteId],
|
|
) -> CollectionOp[OpChangesWithCount]:
|
|
return CollectionOp(parent, lambda col: col.remove_notes(note_ids)).success(
|
|
lambda out: tooltip(tr.browsing_cards_deleted(count=out.count)),
|
|
)
|