mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Merge pull request #24 from ccl09c/master
Collapsable deckview (part 1 of 2)
This commit is contained in:
commit
f38c3bfb5c
1 changed files with 18 additions and 2 deletions
|
@ -54,6 +54,8 @@ or importing text files."""))
|
||||||
elif cmd == "drag":
|
elif cmd == "drag":
|
||||||
draggedDeckDid, ontoDeckDid = arg.split(',')
|
draggedDeckDid, ontoDeckDid = arg.split(',')
|
||||||
self._dragDeckOnto(draggedDeckDid, ontoDeckDid)
|
self._dragDeckOnto(draggedDeckDid, ontoDeckDid)
|
||||||
|
elif cmd == "collapse":
|
||||||
|
self._collapse(arg)
|
||||||
|
|
||||||
def _keyHandler(self, evt):
|
def _keyHandler(self, evt):
|
||||||
key = unicode(evt.text())
|
key = unicode(evt.text())
|
||||||
|
@ -162,6 +164,14 @@ where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
|
||||||
|
|
||||||
def _deckRow(self, node, depth):
|
def _deckRow(self, node, depth):
|
||||||
name, did, due, lrn, new, children = node
|
name, did, due, lrn, new, children = node
|
||||||
|
# parent toggled for collapsing
|
||||||
|
for parent in self.mw.col.decks.parents(did):
|
||||||
|
if parent['collapsed']:
|
||||||
|
buff = ""
|
||||||
|
return buff
|
||||||
|
prefix = "(-)"
|
||||||
|
if self.mw.col.decks.get(did)['collapsed']:
|
||||||
|
prefix = "(+)"
|
||||||
due += lrn
|
due += lrn
|
||||||
def indent():
|
def indent():
|
||||||
return " "*6*depth
|
return " "*6*depth
|
||||||
|
@ -172,8 +182,8 @@ where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
|
||||||
buf = "<tr class='%s' id='%d'>" % (klass, did)
|
buf = "<tr class='%s' id='%d'>" % (klass, did)
|
||||||
# deck link
|
# deck link
|
||||||
buf += """
|
buf += """
|
||||||
<td class=decktd colspan=5>%s<a class=deck href='open:%d'>%s</a></td>"""% (
|
<td class=decktd colspan=5>%s<a class=collapse href='collapse:%d'>%s</a><a class=deck href='open:%d'>%s</a></td>"""% (
|
||||||
indent(), did, name)
|
indent(), did, prefix, did, name)
|
||||||
# due counts
|
# due counts
|
||||||
def nonzeroColour(cnt, colour):
|
def nonzeroColour(cnt, colour):
|
||||||
if not cnt:
|
if not cnt:
|
||||||
|
@ -208,6 +218,8 @@ where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
|
||||||
|
|
||||||
def _showOptions(self, did):
|
def _showOptions(self, did):
|
||||||
m = QMenu(self.mw)
|
m = QMenu(self.mw)
|
||||||
|
a = m.addAction(_("Collapse"))
|
||||||
|
a.connect(a, SIGNAL("triggered()"), lambda did=did: self._collapse(did))
|
||||||
a = m.addAction(_("Rename"))
|
a = m.addAction(_("Rename"))
|
||||||
a.connect(a, SIGNAL("triggered()"), lambda did=did: self._rename(did))
|
a.connect(a, SIGNAL("triggered()"), lambda did=did: self._rename(did))
|
||||||
a = m.addAction(_("Options"))
|
a = m.addAction(_("Options"))
|
||||||
|
@ -233,6 +245,10 @@ where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
|
||||||
def _options(self, did):
|
def _options(self, did):
|
||||||
self.mw.onDeckConf(self.mw.col.decks.get(did))
|
self.mw.onDeckConf(self.mw.col.decks.get(did))
|
||||||
|
|
||||||
|
def _collapse(self, did):
|
||||||
|
self.mw.col.decks.collapse(did)
|
||||||
|
self.show()
|
||||||
|
|
||||||
def _dragDeckOnto(self, draggedDeckDid, ontoDeckDid):
|
def _dragDeckOnto(self, draggedDeckDid, ontoDeckDid):
|
||||||
try:
|
try:
|
||||||
self.mw.col.decks.renameForDragAndDrop(draggedDeckDid, ontoDeckDid)
|
self.mw.col.decks.renameForDragAndDrop(draggedDeckDid, ontoDeckDid)
|
||||||
|
|
Loading…
Reference in a new issue