Commit 4e0a9ad1 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Column mode can show IDs longer than 4 characters

The defaults / fallbacks are such that it cannot exceed 6 characters.
parent 894edaad
......@@ -16,6 +16,7 @@
import urwid
from topydo.lib.HashListValues import max_id_length
from topydo.lib.Utils import translate_key_to_config
from topydo.ui.columns.TodoWidget import TodoWidget
......@@ -89,6 +90,7 @@ class TodoListWidget(urwid.LineBox):
with this list.
"""
old_focus_position = self.todolist.focus
id_length = max_id_length(self.view.todolist.count())
del self.todolist[:]
......@@ -99,7 +101,7 @@ class TodoListWidget(urwid.LineBox):
self.todolist.append(urwid.Divider('-'))
for todo in todos:
todowidget = TodoWidget.create(todo)
todowidget = TodoWidget.create(todo, id_length)
todowidget.number = self.view.todolist.number(todo)
self.todolist.append(todowidget)
self.todolist.append(urwid.Divider('-'))
......
......@@ -53,7 +53,7 @@ def _markup(p_todo, p_focus):
class TodoWidget(urwid.WidgetWrap):
def __init__(self, p_todo):
def __init__(self, p_todo, p_id_width=4):
# clients use this to associate this widget with the given todo item
self.todo = p_todo
......@@ -101,7 +101,7 @@ class TodoWidget(urwid.WidgetWrap):
self.columns = urwid.Columns(
[
(1, self.progress_bar),
(4, self.id_widget),
(p_id_width, self.id_widget),
(3, priority_widget),
('weight', 1, self.text_widget),
],
......@@ -159,7 +159,7 @@ class TodoWidget(urwid.WidgetWrap):
cache = {}
@classmethod
def create(p_class, p_todo):
def create(p_class, p_todo, p_id_width=4):
"""
Creates a TodoWidget instance for the given todo. Widgets are
cached, the same object is returned for the same todo item.
......@@ -187,7 +187,7 @@ class TodoWidget(urwid.WidgetWrap):
if parent_progress_may_have_changed(p_todo):
widget.update_progress()
else:
widget = p_class(p_todo)
widget = p_class(p_todo, p_id_width)
p_class.cache[source] = widget
return widget
......
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