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
ps = postpone_s
pr = pri
m = mark
<C-a> = mark_all
0 = first_column
$ = last_column
h = prev_column
......
......@@ -53,6 +53,7 @@ class _Config:
'add',
'aliases',
'colorscheme',
'column_keymap',
'columns',
'dep',
'ls',
......@@ -140,6 +141,7 @@ class _Config:
'u': 'cmd revert',
'x': 'cmd do {}',
'm': 'mark',
'<C-a>': 'mark_all',
'.': 'repeat',
'pp': 'postpone',
'ps': 'postpone_s',
......
......@@ -630,13 +630,21 @@ class UIApplication(CLIApplicationBase):
def _has_marked_todos(self):
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
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.
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)
return True
else:
......
......@@ -220,6 +220,13 @@ class TodoListWidget(urwid.LineBox):
# No todo item selected
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):
"""
Executes command specified by p_cmd_str on selected todo item.
......@@ -272,7 +279,7 @@ class TodoListWidget(urwid.LineBox):
'first_column', 'last_column', 'prev_column', 'next_column',
'append_column', 'insert_column', 'edit_column', 'delete_column',
'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',
'last_column',
......@@ -302,6 +309,8 @@ class TodoListWidget(urwid.LineBox):
pass
elif p_action_str == 'mark':
self._toggle_marked_status()
elif p_action_str == 'mark_all':
self._mark_all()
elif p_action_str == 'repeat':
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