From 0af13cb550b6db03a4073d6aa9f5774709df2fd8 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 6 Feb 2009 19:12:21 +0900 Subject: [PATCH] refresh after undo/redo, don't reset session on active tag change --- ankiqt/ui/cardlist.py | 15 +++++++++------ ankiqt/ui/main.py | 5 +++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ankiqt/ui/cardlist.py b/ankiqt/ui/cardlist.py index c4f8c3a17..c295b5152 100644 --- a/ankiqt/ui/cardlist.py +++ b/ankiqt/ui/cardlist.py @@ -16,7 +16,7 @@ from ankiqt.ui.utils import saveGeom, restoreGeom, saveSplitter, restoreSplitter from anki.errors import * from anki.db import * from anki.stats import CardStats -from anki.hooks import runHook +from anki.hooks import runHook, addHook # Deck editor ########################################################################## @@ -226,6 +226,7 @@ class EditDeck(QMainWindow): self.setupFilter() self.setupSort() self.setupHeaders() + self.setupUndo() self.setupEditor() self.setupCardInfo() self.dialog.filterEdit.setFocus() @@ -683,17 +684,19 @@ where id in %s""" % ids2str(sf)) # Edit: undo/redo ###################################################################### - def onUndo(self): - self.deck.undo() + def setupUndo(self): + addHook("postUndoRedo", self.postUndoRedo) + + def postUndoRedo(self): self.updateFilterLabel() self.updateSearch() self.updateAfterCardChange() + def onUndo(self): + self.deck.undo() + def onRedo(self): self.deck.redo() - self.updateFilterLabel() - self.updateSearch() - self.updateAfterCardChange() # Jumping ###################################################################### diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index b401991e5..458d53e6d 100644 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -180,9 +180,10 @@ Please do not file a bug report with Anki.

""") self.views = self.viewsBackup self.viewsBackup = None - def reset(self, count=True): + def reset(self, count=True, refresh=False): if self.deck: - self.deck.refresh() + if refresh: + self.deck.refresh() if count: self.deck.updateAllPriorities() self.deck.rebuildCounts()