Skip to content

Commit

Permalink
Always show tags with zero tasks.
Browse files Browse the repository at this point in the history
'TagEmptyFilter' checks for the correct 'self.pane' values
and considers the newly introduced 'show_zero' field.

This fixes GitHub issue #1007
  • Loading branch information
gycsaba96 authored and diegogangl committed May 12, 2024
1 parent ce4fd3c commit bfcb78a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions GTG/core/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,20 @@ def __init__(self, ds, pane):
super(TagEmptyFilter, self).__init__()
self.ds = ds
self.pane = pane
self.show_zero = True


def do_match(self, item) -> bool:
tag = unwrap(item, Tag)

if self.pane == 'open':
return tag.task_count_open > 0
if self.pane == 'open_view':
return self.show_zero or tag.task_count_open > 0

elif self.pane == 'closed':
return tag.task_count_closed > 0
elif self.pane == 'closed_view':
return self.show_zero or tag.task_count_closed > 0

elif self.pane == 'workview':
return tag.task_count_actionable > 0 and tag.actionable
elif self.pane == 'actionable_view':
return (self.show_zero or tag.task_count_actionable > 0) and tag.actionable

else:
return True
Expand Down
2 changes: 1 addition & 1 deletion GTG/gtk/browser/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def __init__(self, app, ds: Datastore, browser):
# -------------------------------------------------------------------------------
# Tags Section
# -------------------------------------------------------------------------------
self.tags_filter = TagEmptyFilter(ds, 'open')
self.tags_filter = TagEmptyFilter(ds, 'open_view')
self.filtered_tags = Gtk.FilterListModel()
self.filtered_tags.set_model(ds.tags.tree_model)
self.filtered_tags.set_filter(self.tags_filter)
Expand Down

0 comments on commit bfcb78a

Please sign in to comment.