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,
|
shortcut,
|
||||||
show_invalid_search_error,
|
show_invalid_search_error,
|
||||||
showInfo,
|
showInfo,
|
||||||
showWarning,
|
|
||||||
tooltip,
|
tooltip,
|
||||||
tr,
|
tr,
|
||||||
)
|
)
|
||||||
|
@ -1185,16 +1184,18 @@ where id in %s"""
|
||||||
if not ret.name:
|
if not ret.name:
|
||||||
return
|
return
|
||||||
did = self.col.decks.id(ret.name)
|
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.model.beginReset()
|
||||||
self.mw.checkpoint(tr(TR.BROWSING_CHANGE_DECK))
|
|
||||||
|
def do_move() -> None:
|
||||||
self.col.set_deck(cids, did)
|
self.col.set_deck(cids, did)
|
||||||
|
|
||||||
|
def on_done(fut: Future) -> None:
|
||||||
self.model.endReset()
|
self.model.endReset()
|
||||||
|
fut.result()
|
||||||
self.mw.requireReset(reason=ResetReason.BrowserSetDeck, context=self)
|
self.mw.requireReset(reason=ResetReason.BrowserSetDeck, context=self)
|
||||||
|
|
||||||
|
self.mw.taskman.with_progress(do_move, on_done)
|
||||||
|
|
||||||
# Tags
|
# Tags
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ impl Collection {
|
||||||
self.storage.set_search_table_to_card_ids(cards, false)?;
|
self.storage.set_search_table_to_card_ids(cards, false)?;
|
||||||
let sched = self.scheduler_version();
|
let sched = self.scheduler_version();
|
||||||
let usn = self.usn()?;
|
let usn = self.usn()?;
|
||||||
self.transact(None, |col| {
|
self.transact(Some(UndoableOpKind::SetDeck), |col| {
|
||||||
for mut card in col.storage.all_searched_cards()? {
|
for mut card in col.storage.all_searched_cards()? {
|
||||||
if card.deck_id == deck_id {
|
if card.deck_id == deck_id {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -21,6 +21,7 @@ pub enum UndoableOpKind {
|
||||||
UpdateNote,
|
UpdateNote,
|
||||||
UpdatePreferences,
|
UpdatePreferences,
|
||||||
UpdateTag,
|
UpdateTag,
|
||||||
|
SetDeck,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UndoableOpKind {
|
impl UndoableOpKind {
|
||||||
|
@ -48,6 +49,7 @@ impl Collection {
|
||||||
UndoableOpKind::UpdateNote => TR::UndoUpdateNote,
|
UndoableOpKind::UpdateNote => TR::UndoUpdateNote,
|
||||||
UndoableOpKind::UpdatePreferences => TR::PreferencesPreferences,
|
UndoableOpKind::UpdatePreferences => TR::PreferencesPreferences,
|
||||||
UndoableOpKind::UpdateTag => TR::UndoUpdateTag,
|
UndoableOpKind::UpdateTag => TR::UndoUpdateTag,
|
||||||
|
UndoableOpKind::SetDeck => TR::BrowsingChangeDeck,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.i18n.tr(key).to_string()
|
self.i18n.tr(key).to_string()
|
||||||
|
|
Loading…
Reference in a new issue