mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Do not show "Uncategorized" cardsets list if all cardsets have been categorized.
This commit is contained in:
parent
05fc7a8baa
commit
7741fa7dcc
3 changed files with 36 additions and 20 deletions
|
@ -485,6 +485,10 @@ class CardsetManager(ResourceManager):
|
|||
self.registered_nationalities = {}
|
||||
self.registered_dates = {}
|
||||
|
||||
self.uncategorized_styles = False
|
||||
self.uncategorized_nationalities = False
|
||||
self.uncategorized_dates = False
|
||||
|
||||
def _check(self, cs):
|
||||
s = cs.type
|
||||
if s not in CSI.TYPE:
|
||||
|
@ -571,12 +575,18 @@ class CardsetManager(ResourceManager):
|
|||
#
|
||||
keys = cs.styles[:]
|
||||
cs.si.styles = tuple([s for s in keys if s in CSI.STYLE])
|
||||
if len(cs.si.styles) == 0:
|
||||
self.uncategorized_styles = True
|
||||
for s in cs.si.styles:
|
||||
self.registered_styles[s] = self.registered_styles.get(s, 0) + 1
|
||||
cs.si.nationalities = tuple([s for s in keys if s in CSI.NATIONALITY])
|
||||
if len(cs.si.nationalities) == 0:
|
||||
self.uncategorized_nationalities = True
|
||||
for s in cs.si.nationalities:
|
||||
self.registered_nationalities[s] = \
|
||||
self.registered_nationalities.get(s, 0) + 1
|
||||
if cs.year == 0:
|
||||
self.uncategorized_dates = True
|
||||
keys = (cs.year // 100,)
|
||||
cs.si.dates = tuple([s for s in keys if s in CSI.DATE])
|
||||
for s in cs.si.dates:
|
||||
|
|
|
@ -93,9 +93,10 @@ class SelectCardsetData(SelectDialogTreeData):
|
|||
SelectCardsetNode(
|
||||
None, name, lambda cs, key=key: key in cs.si.styles))
|
||||
if nodes:
|
||||
nodes.append(
|
||||
SelectCardsetNode(
|
||||
None, _("Uncategorized"), lambda cs: not cs.si.styles))
|
||||
if manager.uncategorized_styles:
|
||||
nodes.append(
|
||||
SelectCardsetNode(
|
||||
None, _("Uncategorized"), lambda cs: not cs.si.styles))
|
||||
select_by_style = SelectCardsetNode(
|
||||
None, _("by Style"), tuple(nodes))
|
||||
#
|
||||
|
@ -110,10 +111,11 @@ class SelectCardsetData(SelectDialogTreeData):
|
|||
None, name,
|
||||
lambda cs, key=key: key in cs.si.nationalities))
|
||||
if nodes:
|
||||
nodes.append(
|
||||
SelectCardsetNode(
|
||||
None, _("Uncategorized"),
|
||||
lambda cs: not cs.si.nationalities))
|
||||
if manager.uncategorized_nationalities:
|
||||
nodes.append(
|
||||
SelectCardsetNode(
|
||||
None, _("Uncategorized"),
|
||||
lambda cs: not cs.si.nationalities))
|
||||
select_by_nationality = SelectCardsetNode(
|
||||
None, _("by Nationality"), tuple(nodes))
|
||||
#
|
||||
|
@ -127,9 +129,10 @@ class SelectCardsetData(SelectDialogTreeData):
|
|||
SelectCardsetNode(
|
||||
None, name, lambda cs, key=key: key in cs.si.dates))
|
||||
if nodes:
|
||||
nodes.append(
|
||||
SelectCardsetNode(
|
||||
None, _("Uncategorized"), lambda cs: not cs.si.dates))
|
||||
if manager.uncategorized_dates:
|
||||
nodes.append(
|
||||
SelectCardsetNode(
|
||||
None, _("Uncategorized"), lambda cs: not cs.si.dates))
|
||||
select_by_date = SelectCardsetNode(
|
||||
None, _("by Date"), tuple(nodes))
|
||||
#
|
||||
|
|
|
@ -92,9 +92,10 @@ class SelectCardsetData(SelectDialogTreeData):
|
|||
SelectCardsetNode(
|
||||
None, name, lambda cs, key=key: key in cs.si.styles))
|
||||
if nodes:
|
||||
nodes.append(
|
||||
SelectCardsetNode(
|
||||
None, _("Uncategorized"), lambda cs: not cs.si.styles))
|
||||
if manager.uncategorized_styles:
|
||||
nodes.append(
|
||||
SelectCardsetNode(
|
||||
None, _("Uncategorized"), lambda cs: not cs.si.styles))
|
||||
select_by_style = SelectCardsetNode(
|
||||
None, _("by Style"), tuple(nodes))
|
||||
#
|
||||
|
@ -109,10 +110,11 @@ class SelectCardsetData(SelectDialogTreeData):
|
|||
None, name,
|
||||
lambda cs, key=key: key in cs.si.nationalities))
|
||||
if nodes:
|
||||
nodes.append(
|
||||
SelectCardsetNode(
|
||||
None, _("Uncategorized"),
|
||||
lambda cs: not cs.si.nationalities))
|
||||
if manager.uncategorized_nationalities:
|
||||
nodes.append(
|
||||
SelectCardsetNode(
|
||||
None, _("Uncategorized"),
|
||||
lambda cs: not cs.si.nationalities))
|
||||
select_by_nationality = SelectCardsetNode(
|
||||
None, _("by Nationality"), tuple(nodes))
|
||||
#
|
||||
|
@ -126,9 +128,10 @@ class SelectCardsetData(SelectDialogTreeData):
|
|||
SelectCardsetNode(
|
||||
None, name, lambda cs, key=key: key in cs.si.dates))
|
||||
if nodes:
|
||||
nodes.append(
|
||||
SelectCardsetNode(
|
||||
None, _("Uncategorized"), lambda cs: not cs.si.dates))
|
||||
if manager.uncategorized_dates:
|
||||
nodes.append(
|
||||
SelectCardsetNode(
|
||||
None, _("Uncategorized"), lambda cs: not cs.si.dates))
|
||||
select_by_date = SelectCardsetNode(
|
||||
None, _("by Date"), tuple(nodes))
|
||||
#
|
||||
|
|
Loading…
Add table
Reference in a new issue