diff --git a/aqt/main.py b/aqt/main.py
index e3f3416b9..381a8f104 100755
--- a/aqt/main.py
+++ b/aqt/main.py
@@ -135,16 +135,9 @@ class AnkiQt(QMainWindow):
self.disableCardMenuItems()
self.showStudyScreen()
- def reset(self, runHooks=True):
- # two kinds of resets: partial, which causes objects dealing with
- # cards or facts to reload them and notice deletions, and full, which
- # is called when models have changed, and reloads everything
- if self.deck:
- self.deck.reset()
- if runHooks:
- runHook("guiReset")
- self.moveToState("initial")
-
+ def reset(self):
+ self.deck.reset()
+ runHook("reset")
# HTML helpers
##########################################################################
@@ -2262,28 +2255,13 @@ is next loaded."""))
def onCheckDB(self):
"True if no problems"
if not aqt.utils.askUser(_("""\
-This operation will find and fix some common problems.
-
-On the next sync, all cards will be sent to the server.
-Any changes on the server since your last sync will be lost.
-
-This operation is not undoable.
-Proceed?""")):
+This operation will find and fix some common problems.
+On the next sync, all cards will be sent to the server. \
+Any changes on the server since your last sync will be lost.
+This operation is not undoable. Proceed?""")):
return
ret = self.deck.fixIntegrity()
- diag = QDialog(self)
- diag.setWindowTitle("Anki")
- layout = QVBoxLayout(diag)
- diag.setLayout(layout)
- text = QTextEdit()
- text.setReadOnly(True)
- text.setPlainText(ret)
- layout.addWidget(text)
- box = QDialogButtonBox(QDialogButtonBox.Close)
- layout.addWidget(box)
- self.connect(box, SIGNAL("rejected()"), diag, SLOT("reject()"))
- diag.exec_()
- ret = False
+ aqt.utils.showText(ret)
self.reset()
return ret
diff --git a/aqt/overview.py b/aqt/overview.py
index 615b8906f..70337ff36 100644
--- a/aqt/overview.py
+++ b/aqt/overview.py
@@ -6,6 +6,7 @@ import simplejson
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from anki.consts import NEW_CARDS_RANDOM
+from anki.hooks import addHook
class Overview(object):
"Deck overview."
@@ -13,11 +14,16 @@ class Overview(object):
def __init__(self, mw):
self.mw = mw
self.web = mw.web
+ addHook("reset", self.refresh)
def show(self):
self._setupToolbar()
self.web.setKeyHandler(self._keyHandler)
self.web.setLinkHandler(self._linkHandler)
+ self.refresh()
+
+ def refresh(self):
+ print "refreshing"
self._renderPage()
# Handlers
@@ -25,34 +31,34 @@ class Overview(object):
def _keyHandler(self, evt):
txt = evt.text()
- if txt == "1" or evt.key() in (Qt.Key_Enter,
- Qt.Key_Return,
- Qt.Key_Space):
- self._linkHandler("studysel")
- elif txt == "2":
- self._linkHandler("studyall")
- elif txt == "3":
- self._linkHandler("cramsel")
- elif txt == "4":
- self._linkHandler("cramall")
+ if evt.key() == Qt.Key_Space:
+ self._linkHandler("study")
+ elif txt == "c":
+ self._linkHandler("cram")
elif txt == "o":
self._linkHandler("opts")
elif txt == "d":
self._linkHandler("list")
+ elif txt == "g":
+ self._linkHandler("chgrp")
else:
return
return True
def _linkHandler(self, url):
print "link", url
- if url == "studysel":
- self.mw.deck.sched.useGroups = True
+ if url == "study":
self.mw.deck.reset()
self.mw.moveToState("review")
+ elif url == "cram":
+ self.mw.deck.cramGroups(self.mw.deck.qconf['revGroups'])
+ self.mw.moveToState("review")
elif url == "opts":
- pass
+ print "study options"
elif url == "list":
self.mw.close()
+ elif url == "chgrp":
+ print "change groups"
# HTML
############################################################
@@ -62,22 +68,17 @@ class Overview(object):
fc = self._ovForecast()
tbl = self._overviewTable()
but = self.mw.button
- buts = (but("list", _("Deck List"), "d") +
- but("refr", _("Refresh"), "r") +
- but("opts", _("Study Options"), "o"))
self.web.stdHtml(self._overviewBody % dict(
title=_("Overview"),
table=tbl,
fcsub=_("Reviews over next two weeks"),
fcdata=fc,
- buts=buts,
opts=self._ovOpts(),
), css)
_overviewBody = """
%(table)s
@@ -121,13 +122,12 @@ $(function () { buf += line % ( "%s" % _("Selected Groups"), counts[0], counts[1], - but("studysel", _("Study"), _("1, enter, space"), "gbut") + - but("cramsel", _("Cram"), "3")) + but("study", _("Study"), _("space"), "gbut") + + but("cram", _("Cram"), "c")) buf += line % ( _("Whole Deck"), counts[2], counts[3], - but("studyall", _("Study"), "2", "gbut") + - but("cramall", _("Cram"), "4")) + but("opts", _("Study Options"), "o")) buf += "" return buf diff --git a/aqt/reviewer.py b/aqt/reviewer.py index 761864f29..fb66f3276 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -139,13 +139,13 @@ $(".ansbut").focus(); return buf def _defaultEase(self): - if self.card.queue == 2: + if self.mw.deck.sched.answerButtons(self.card) == 4: return 3 else: return 2 def _answerButtons(self): - if self.card.queue == 2: + if self.mw.deck.sched.answerButtons(self.card) == 4: labels = (_("Again"), _("Hard"), _("Good"), _("Easy")) else: labels = (_("Again"), _("Good"), _("Easy"))