mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
'change deck' now undoable
This commit is contained in:
parent
7b7d7e8330
commit
2ffc055487
3 changed files with 13 additions and 10 deletions
|
@ -55,7 +55,6 @@ from aqt.utils import (
|
|||
shortcut,
|
||||
show_invalid_search_error,
|
||||
showInfo,
|
||||
showWarning,
|
||||
tooltip,
|
||||
tr,
|
||||
)
|
||||
|
@ -1185,15 +1184,17 @@ where id in %s"""
|
|||
if not ret.name:
|
||||
return
|
||||
did = self.col.decks.id(ret.name)
|
||||
deck = self.col.decks.get(did)
|
||||
if deck["dyn"]:
|
||||
showWarning(tr(TR.BROWSING_CARDS_CANT_BE_MANUALLY_MOVED_INTO))
|
||||
return
|
||||
self.model.beginReset()
|
||||
self.mw.checkpoint(tr(TR.BROWSING_CHANGE_DECK))
|
||||
self.col.set_deck(cids, did)
|
||||
self.model.endReset()
|
||||
self.mw.requireReset(reason=ResetReason.BrowserSetDeck, context=self)
|
||||
|
||||
def do_move() -> None:
|
||||
self.col.set_deck(cids, did)
|
||||
|
||||
def on_done(fut: Future) -> None:
|
||||
self.model.endReset()
|
||||
fut.result()
|
||||
self.mw.requireReset(reason=ResetReason.BrowserSetDeck, context=self)
|
||||
|
||||
self.mw.taskman.with_progress(do_move, on_done)
|
||||
|
||||
# Tags
|
||||
######################################################################
|
||||
|
|
|
@ -211,7 +211,7 @@ impl Collection {
|
|||
self.storage.set_search_table_to_card_ids(cards, false)?;
|
||||
let sched = self.scheduler_version();
|
||||
let usn = self.usn()?;
|
||||
self.transact(None, |col| {
|
||||
self.transact(Some(UndoableOpKind::SetDeck), |col| {
|
||||
for mut card in col.storage.all_searched_cards()? {
|
||||
if card.deck_id == deck_id {
|
||||
continue;
|
||||
|
|
|
@ -21,6 +21,7 @@ pub enum UndoableOpKind {
|
|||
UpdateNote,
|
||||
UpdatePreferences,
|
||||
UpdateTag,
|
||||
SetDeck,
|
||||
}
|
||||
|
||||
impl UndoableOpKind {
|
||||
|
@ -48,6 +49,7 @@ impl Collection {
|
|||
UndoableOpKind::UpdateNote => TR::UndoUpdateNote,
|
||||
UndoableOpKind::UpdatePreferences => TR::PreferencesPreferences,
|
||||
UndoableOpKind::UpdateTag => TR::UndoUpdateTag,
|
||||
UndoableOpKind::SetDeck => TR::BrowsingChangeDeck,
|
||||
};
|
||||
|
||||
self.i18n.tr(key).to_string()
|
||||
|
|
Loading…
Reference in a new issue