hide the default deck if it's empty and there are other decks

This commit is contained in:
Damien Elmes 2012-09-06 04:42:28 +09:00
parent bbbff0ca32
commit 125518a9ed

View file

@ -171,13 +171,17 @@ where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
else: else:
buf = "" buf = ""
for node in nodes: for node in nodes:
buf += self._deckRow(node, depth) buf += self._deckRow(node, depth, len(nodes))
if depth == 0: if depth == 0:
buf += self._topLevelDragRow() buf += self._topLevelDragRow()
return buf return buf
def _deckRow(self, node, depth): def _deckRow(self, node, depth, cnt):
name, did, due, lrn, new, children = node name, did, due, lrn, new, children = node
if did == 1 and cnt > 1 and not children:
# if the default deck is empty, hide it
if not self.mw.col.db.scalar("select 1 from cards where did = 1"):
return ""
# parent toggled for collapsing # parent toggled for collapsing
for parent in self.mw.col.decks.parents(did): for parent in self.mw.col.decks.parents(did):
if parent['collapsed']: if parent['collapsed']: