Commit 93ac32e6 authored by Bram Schoenmakers's avatar Bram Schoenmakers Committed by GitHub

Merge pull request #175 from mruwek/select-all

Introduce new 'mark_all' action in Column UI
parents c6960e71 4bae3b95
...@@ -94,6 +94,7 @@ pp = postpone ...@@ -94,6 +94,7 @@ pp = postpone
ps = postpone_s ps = postpone_s
pr = pri pr = pri
m = mark m = mark
<C-a> = mark_all
0 = first_column 0 = first_column
$ = last_column $ = last_column
h = prev_column h = prev_column
......
...@@ -53,6 +53,7 @@ class _Config: ...@@ -53,6 +53,7 @@ class _Config:
'add', 'add',
'aliases', 'aliases',
'colorscheme', 'colorscheme',
'column_keymap',
'columns', 'columns',
'dep', 'dep',
'ls', 'ls',
...@@ -140,6 +141,7 @@ class _Config: ...@@ -140,6 +141,7 @@ class _Config:
'u': 'cmd revert', 'u': 'cmd revert',
'x': 'cmd do {}', 'x': 'cmd do {}',
'm': 'mark', 'm': 'mark',
'<C-a>': 'mark_all',
'.': 'repeat', '.': 'repeat',
'pp': 'postpone', 'pp': 'postpone',
'ps': 'postpone_s', 'ps': 'postpone_s',
......
...@@ -630,13 +630,21 @@ class UIApplication(CLIApplicationBase): ...@@ -630,13 +630,21 @@ class UIApplication(CLIApplicationBase):
def _has_marked_todos(self): def _has_marked_todos(self):
return len(self.marked_todos) > 0 return len(self.marked_todos) > 0
def _process_mark_toggle(self, p_todo_id): def _process_mark_toggle(self, p_todo_id, p_force=None):
""" """
Adds p_todo_id to marked_todos attribute and returns True if p_todo_id Adds p_todo_id to marked_todos attribute and returns True if p_todo_id
is not already present. Removes p_todo_id from marked_todos and returns is not already marked. Removes p_todo_id from marked_todos and returns
False otherwise. False otherwise.
p_force parameter accepting 'mark' or 'unmark' values, if set, can force
desired action without checking p_todo_id presence in marked_todos.
""" """
if p_todo_id not in self.marked_todos: if p_force in ['mark', 'unmark']:
action = p_force
else:
action = 'mark' if p_todo_id not in self.marked_todos else 'unmark'
if action == 'mark':
self.marked_todos.add(p_todo_id) self.marked_todos.add(p_todo_id)
return True return True
else: else:
......
...@@ -220,6 +220,13 @@ class TodoListWidget(urwid.LineBox): ...@@ -220,6 +220,13 @@ class TodoListWidget(urwid.LineBox):
# No todo item selected # No todo item selected
pass pass
def _mark_all(self):
for todo in self.listbox.body:
if isinstance(todo, TodoWidget):
todo_id = str(self.view.todolist.number(todo.todo))
urwid.emit_signal(self, 'toggle_mark', todo_id, 'mark')
todo.mark()
def _execute_on_selected(self, p_cmd_str, p_execute_signal): def _execute_on_selected(self, p_cmd_str, p_execute_signal):
""" """
Executes command specified by p_cmd_str on selected todo item. Executes command specified by p_cmd_str on selected todo item.
...@@ -272,7 +279,7 @@ class TodoListWidget(urwid.LineBox): ...@@ -272,7 +279,7 @@ class TodoListWidget(urwid.LineBox):
'first_column', 'last_column', 'prev_column', 'next_column', 'first_column', 'last_column', 'prev_column', 'next_column',
'append_column', 'insert_column', 'edit_column', 'delete_column', 'append_column', 'insert_column', 'edit_column', 'delete_column',
'copy_column', swap_right', 'swap_left', 'postpone', 'postpone_s', 'copy_column', swap_right', 'swap_left', 'postpone', 'postpone_s',
'pri', 'mark', 'reset' and 'repeat'. 'pri', 'mark', 'mark_all, 'reset' and 'repeat'.
""" """
column_actions = ['first_column', column_actions = ['first_column',
'last_column', 'last_column',
...@@ -302,6 +309,8 @@ class TodoListWidget(urwid.LineBox): ...@@ -302,6 +309,8 @@ class TodoListWidget(urwid.LineBox):
pass pass
elif p_action_str == 'mark': elif p_action_str == 'mark':
self._toggle_marked_status() self._toggle_marked_status()
elif p_action_str == 'mark_all':
self._mark_all()
elif p_action_str == 'repeat': elif p_action_str == 'repeat':
self._repeat_cmd() self._repeat_cmd()
......
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