connect current card editor; ensure same card is reviewed

This commit is contained in:
Damien Elmes 2011-12-01 15:41:24 +09:00
parent cecec92934
commit 5dd5ab710a
8 changed files with 22 additions and 89 deletions

View file

@ -23,8 +23,9 @@ class EditCurrent(QDialog):
self.connect(self, self.connect(self,
SIGNAL("rejected()"), SIGNAL("rejected()"),
self.onSave) self.onSave)
self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea) self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea, self)
self.editor.setNote(self.mw.reviewer.card.note()) self.editor.setNote(self.mw.reviewer.card.note())
self.mw.reviewer.cardQueue.append(self.mw.reviewer.card)
restoreGeom(self, "editcurrent") restoreGeom(self, "editcurrent")
addHook("closeEditCurrent", self.onSave) addHook("closeEditCurrent", self.onSave)
self.mw.requireReset(modal=True) self.mw.requireReset(modal=True)
@ -39,8 +40,6 @@ class EditCurrent(QDialog):
r = self.mw.reviewer r = self.mw.reviewer
r.card.load() r.card.load()
r.keep = True r.keep = True
# we don't need to reset the col, but there may be new groups
self.mw.col.sched._resetConf()
self.mw.moveToState("review") self.mw.moveToState("review")
saveGeom(self, "editcurrent") saveGeom(self, "editcurrent")
self.close() self.close()

View file

@ -292,7 +292,6 @@ background: #f3f3f3;
margin: 2em; margin: 2em;
} }
h1 { margin-bottom: 0.2em; } h1 { margin-bottom: 0.2em; }
hr { background-color:#ccc; margin: 1em; }
""" """
def button(self, link, name, key=None, class_="", id=""): def button(self, link, name, key=None, class_="", id=""):

View file

@ -19,22 +19,18 @@ class Reviewer(object):
self.web = mw.web self.web = mw.web
self.card = None self.card = None
self.cardQueue = [] self.cardQueue = []
self.hadCardQueue = False
self._answeredIds = [] self._answeredIds = []
self.state = None self.state = None
self.keep = False
self.bottom = aqt.toolbar.BottomBar(mw, mw.bottomWeb) self.bottom = aqt.toolbar.BottomBar(mw, mw.bottomWeb)
addHook("leech", self.onLeech) addHook("leech", self.onLeech)
def show(self): def show(self):
self.web.setKeyHandler(self._keyHandler) self.web.setKeyHandler(self._keyHandler)
self.web.setLinkHandler(self._linkHandler) self.web.setLinkHandler(self._linkHandler)
if self.keep:
self._initWeb()
else:
self.nextCard()
self.keep = False
self.bottom.web.setFixedHeight(46) self.bottom.web.setFixedHeight(46)
self.bottom.web.setLinkHandler(self._linkHandler) self.bottom.web.setLinkHandler(self._linkHandler)
self.nextCard()
def lastCard(self): def lastCard(self):
if self._answeredIds: if self._answeredIds:
@ -49,14 +45,19 @@ class Reviewer(object):
def nextCard(self): def nextCard(self):
if self.cardQueue: if self.cardQueue:
# a card has been retrieved from undo # undone/edited cards to show
c = self.cardQueue.pop() c = self.cardQueue.pop()
self.hadCardQueue = True
else: else:
if self.hadCardQueue:
# the undone/edited cards may be sitting in the regular queue;
# need to reset
self.mw.col.reset()
self.hadCardQueue = False
c = self.mw.col.sched.getCard() c = self.mw.col.sched.getCard()
self.card = c self.card = c
clearAudioQueue() clearAudioQueue()
if c: if c:
#self.updateMarkAction()
self._initWeb() self._initWeb()
else: else:
self.mw.moveToState("overview") self.mw.moveToState("overview")
@ -208,16 +209,13 @@ function _typeAnsPress() {
def _linkHandler(self, url): def _linkHandler(self, url):
if url == "ans": if url == "ans":
print "show ans"
self._showAnswer() self._showAnswer()
elif url.startswith("ease"): elif url.startswith("ease"):
self._answerCard(int(url[4:])) self._answerCard(int(url[4:]))
elif url == "add": elif url == "edit":
self.mw.onAddCard() self.mw.onEditCurrent()
elif url == "dlist": elif url == "more":
self.mw.close() self.showContextMenu()
elif url == "ov":
self.mw.moveToState("overview")
elif url.startswith("typeans:"): elif url.startswith("typeans:"):
(cmd, arg) = url.split(":") (cmd, arg) = url.split(":")
self.processTypedAns(arg) self.processTypedAns(arg)
@ -228,76 +226,13 @@ function _typeAnsPress() {
########################################################################## ##########################################################################
_css = """ _css = """
.ansbut { hr { background-color:#ccc; margin: 1em; }
-webkit-box-shadow: 2px 2px 6px rgba(0,0,0,0.6);
-webkit-user-drag: none;
-webkit-user-select: none;
background-color: #ddd;
border-radius: 5px;
border: 1px solid #aaa;
color: #000;
display: inline-block;
font-size: 80%;
margin: 0 5 0 5;
padding: 3;
text-decoration: none;
text-align: center;
}
.but:focus, .but:hover { background-color: #aaa; }
.ansbutbig {
bottom: 1em;
height: 40px;
left: 50%;
margin-left: -125px !important;
position: fixed;
width: 250px;
font-size: 100%;
}
.ansbut:focus {
font-weight: bold;
}
div.ansbuttxt {
position: relative; top: 25%;
}
body { margin:1.5em; } body { margin:1.5em; }
#easebuts {
bottom: 1em;
height: 47px;
left: 50%;
margin-left: -200px;
position: fixed;
width: 400px;
font-size: 100%;
}
.easebut {
width: 60px;
font-size: 100%;
}
.time {
background: #eee;
padding: 5px;
border-radius: 10px;
}
div#filler {
height: 30px;
}
.q { margin-bottom: 1em; }
.a { margin-top: 1em; }
.inv { visibility: hidden; }
.cloze { font-weight: bold; color: blue; } .cloze { font-weight: bold; color: blue; }
""" """
def _styles(self): def _styles(self):
css = self.mw.sharedCSS return self._css
css += self._css
return css
# Type in the answer # Type in the answer
########################################################################## ##########################################################################
@ -417,7 +352,7 @@ padding-left: 5px; padding-right: 5px;
td { font-weight: bold; font-size: 12px; } td { font-weight: bold; font-size: 12px; }
.hitem { margin-top: 2px; } .hitem { margin-top: 2px; }
.stat { padding-top: 5px; } .stat { padding-top: 5px; }
.stattxt { padding-left: 5px; padding-right: 5px; } .stattxt { padding-left: 5px; padding-right: 5px; white-space: nowrap; }
.nobold { font-weight: normal; display: inline-block; padding-top: 3px; } .nobold { font-weight: normal; display: inline-block; padding-top: 3px; }
.spacer { height: 18px; } .spacer { height: 18px; }
.spacer2 { height: 16px; } .spacer2 { height: 16px; }
@ -429,17 +364,17 @@ button { font-weight: normal; }
<table width=100%% cellspacing=0 cellpadding=0> <table width=100%% cellspacing=0 cellpadding=0>
<tr> <tr>
<td align=left width=50 valign=top class=stat><span class=stattxt>1 + 7 + 3</span><br> <td align=left width=50 valign=top class=stat><span class=stattxt>1 + 7 + 3</span><br>
<button>Edit Note</button></td> <button onclick="py.link('edit');">%(edit)s</button></td>
<td align=center valign=top> <td align=center valign=top>
%(middle)s %(middle)s
</td> </td>
<td width=50 align=right valign=top class=stat><span class=stattxt>0:53</span><br> <td width=75 align=right valign=top class=stat><span class=stattxt>0:53</span><br>
<button>More &#9662;</button> <button onclick="py.link('more');">%(more)s &#9662;</button>
</td> </td>
</tr> </tr>
</table> </table>
<script>$(function () { $("#ansbut").focus(); });</script> <script>$(function () { $("#ansbut").focus(); });</script>
""" % dict(middle=middle) """ % dict(middle=middle, edit=_("Edit"), more=_("More"))
def _showAnswerButton(self): def _showAnswerButton(self):
self.bottom.web.setFocus() self.bottom.web.setFocus()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 273 B