diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2013-01-25 14:53:03 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2013-03-03 13:48:20 +0000 |
commit | adb78a57816403da22a18ccaebae2d38149e1af3 (patch) | |
tree | 7132d5275c0f4b252fd86bfc66ed4fe9bcbed796 /alot | |
parent | f9fd1953e2b550e7c50064b02889684113321b22 (diff) |
use ThreadTree in thread buffer
Diffstat (limited to 'alot')
-rw-r--r-- | alot/buffers.py | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/alot/buffers.py b/alot/buffers.py index 8777e246..99eb7e67 100644 --- a/alot/buffers.py +++ b/alot/buffers.py @@ -16,7 +16,8 @@ from alot.widgets.globals import HeadersList from alot.widgets.globals import AttachmentWidget from alot.widgets.bufferlist import BufferlineWidget from alot.widgets.search import ThreadlineWidget -from alot.widgets.thread import MessageWidget +from alot.walker import ThreadTree +from alot.foreign.urwidtrees import ArrowTree, TreeBox class Buffer(object): @@ -324,34 +325,8 @@ class ThreadBuffer(Buffer): self.body = urwid.SolidFill() self.message_count = 0 return - # depth-first traversing the thread-tree, thereby - # 1) build a list of tuples (parentmsg, depth, message) in DF order - # 2) create a dict that counts no. of direct replies per message - messages = list() # accumulator for 1, - childcount = {None: 0} # accumulator for 2) - for msg, replies in self.thread.get_messages().items(): - childcount[msg] = len(replies) - # start with all toplevel msgs, then recursively call _build_pile - for msg in self.thread.get_toplevel_messages(): - self._build_pile(messages, msg, None, 0) - childcount[None] += 1 - - # go through list from 1) and pile up message widgets for all msgs. - # each one will be given its depth, if siblings follow and where to - # draw bars (siblings follow at lower depths) - msglines = list() - bars = [] - for (num, (p, depth, m)) in enumerate(messages): - bars = bars[:depth] - childcount[p] -= 1 - - bars.append(childcount[p] > 0) - mwidget = MessageWidget(m, even=(num % 2 == 0), - depth=depth, - bars_at=bars) - msglines.append(mwidget) - - self.body = urwid.ListBox(urwid.SimpleListWalker(msglines)) + + self.body = TreeBox(ArrowTree(ThreadTree(self.thread))) self.message_count = self.thread.get_total_messages() def get_selection(self): |