Commit 7805d35a authored by Bram Schoenmakers's avatar Bram Schoenmakers

Add group support to the column UI

parent 902ee572
...@@ -30,6 +30,7 @@ def columns(p_alt_layout_path=None): ...@@ -30,6 +30,7 @@ def columns(p_alt_layout_path=None):
column_dict['title'] = p_cp.get(p_column, 'title') column_dict['title'] = p_cp.get(p_column, 'title')
column_dict['filterexpr'] = p_cp.get(p_column, 'filterexpr') column_dict['filterexpr'] = p_cp.get(p_column, 'filterexpr')
column_dict['sortexpr'] = p_cp.get(p_column, 'sortexpr') column_dict['sortexpr'] = p_cp.get(p_column, 'sortexpr')
column_dict['groupexpr'] = p_cp.get(p_column, 'groupexpr')
column_dict['show_all'] = p_cp.getboolean(p_column, 'show_all') column_dict['show_all'] = p_cp.getboolean(p_column, 'show_all')
return column_dict return column_dict
...@@ -38,6 +39,7 @@ def columns(p_alt_layout_path=None): ...@@ -38,6 +39,7 @@ def columns(p_alt_layout_path=None):
'title': 'Yet another column', 'title': 'Yet another column',
'filterexpr': '', 'filterexpr': '',
'sortexpr': config().sort_string(), 'sortexpr': config().sort_string(),
'groupexpr': config().group_string(),
'show_all': '0', 'show_all': '0',
} }
......
...@@ -413,7 +413,7 @@ class UIApplication(CLIApplicationBase): ...@@ -413,7 +413,7 @@ class UIApplication(CLIApplicationBase):
""" """
Converts a dictionary describing a view to an actual UIView instance. Converts a dictionary describing a view to an actual UIView instance.
""" """
sorter = Sorter(p_data['sortexpr']) sorter = Sorter(p_data['sortexpr'], p_data['groupexpr'])
filters = [] filters = []
if not p_data['show_all']: if not p_data['show_all']:
...@@ -607,6 +607,7 @@ class UIApplication(CLIApplicationBase): ...@@ -607,6 +607,7 @@ class UIApplication(CLIApplicationBase):
dummy = { dummy = {
"title": "All tasks", "title": "All tasks",
"sortexpr": "desc:prio", "sortexpr": "desc:prio",
"groupexpr": "",
"filterexpr": "", "filterexpr": "",
"show_all": True, "show_all": True,
} }
......
...@@ -92,11 +92,17 @@ class TodoListWidget(urwid.LineBox): ...@@ -92,11 +92,17 @@ class TodoListWidget(urwid.LineBox):
del self.todolist[:] del self.todolist[:]
for todo in self.view.todos: for group, todos in self.view.groups.items():
todowidget = TodoWidget.create(todo) if len(self.view.groups) > 1:
todowidget.number = self.view.todolist.number(todo) grouplabel = ", ".join(group)
self.todolist.append(todowidget) self.todolist.append(urwid.Text(grouplabel))
self.todolist.append(urwid.Divider('-')) self.todolist.append(urwid.Divider('-'))
for todo in todos:
todowidget = TodoWidget.create(todo)
todowidget.number = self.view.todolist.number(todo)
self.todolist.append(todowidget)
self.todolist.append(urwid.Divider('-'))
if old_focus_position: if old_focus_position:
try: try:
......
...@@ -24,16 +24,18 @@ class ViewWidget(urwid.LineBox): ...@@ -24,16 +24,18 @@ class ViewWidget(urwid.LineBox):
self.titleedit = urwid.Edit("Title: ", "") self.titleedit = urwid.Edit("Title: ", "")
self.sortedit = urwid.Edit("Sort expression: ", "") self.sortedit = urwid.Edit("Sort expression: ", "")
self.groupedit = urwid.Edit("Group expression: ", "")
self.filteredit = urwid.Edit("Filter expression: ", "") self.filteredit = urwid.Edit("Filter expression: ", "")
group = [] radiogroup = []
self.relevantradio = urwid.RadioButton(group, "Only show relevant todo items", True) self.relevantradio = urwid.RadioButton(radiogroup, "Only show relevant todo items", True)
self.allradio = urwid.RadioButton(group, "Show all todo items") self.allradio = urwid.RadioButton(radiogroup, "Show all todo items")
self.pile = urwid.Pile([ self.pile = urwid.Pile([
self.filteredit, self.filteredit,
self.titleedit, self.titleedit,
self.sortedit, self.sortedit,
self.groupedit,
self.relevantradio, self.relevantradio,
self.allradio, self.allradio,
urwid.Button("Save", lambda _: urwid.emit_signal(self, 'save')), urwid.Button("Save", lambda _: urwid.emit_signal(self, 'save')),
...@@ -51,6 +53,7 @@ class ViewWidget(urwid.LineBox): ...@@ -51,6 +53,7 @@ class ViewWidget(urwid.LineBox):
return { return {
'title': self.titleedit.edit_text or self.filteredit.edit_text, 'title': self.titleedit.edit_text or self.filteredit.edit_text,
'sortexpr': self.sortedit.edit_text or config().sort_string(), 'sortexpr': self.sortedit.edit_text or config().sort_string(),
'groupexpr': self.groupedit.edit_text or config().group_string(),
'filterexpr': self.filteredit.edit_text, 'filterexpr': self.filteredit.edit_text,
'show_all': self.allradio.state, 'show_all': self.allradio.state,
} }
...@@ -59,6 +62,7 @@ class ViewWidget(urwid.LineBox): ...@@ -59,6 +62,7 @@ class ViewWidget(urwid.LineBox):
def data(self, p_data): def data(self, p_data):
self.titleedit.edit_text = p_data['title'] self.titleedit.edit_text = p_data['title']
self.sortedit.edit_text = p_data['sortexpr'] self.sortedit.edit_text = p_data['sortexpr']
self.groupedit.edit_text = p_data['groupexpr']
self.filteredit.edit_text = p_data['filterexpr'] self.filteredit.edit_text = p_data['filterexpr']
self.relevantradio.set_state(not p_data['show_all']) self.relevantradio.set_state(not p_data['show_all'])
self.allradio.set_state(p_data['show_all']) self.allradio.set_state(p_data['show_all'])
......
[all] [all]
title = All tasks title = All tasks
filterexpr = filterexpr =
groupexpr = project
[today] [today]
title = Due today title = Due today
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment