summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpazz <patricktotzke@gmail.com>2011-05-27 10:48:44 +0100
committerpazz <patricktotzke@gmail.com>2011-05-27 10:48:44 +0100
commit31aaff7d7a436570f5364954e71d07da19c994df (patch)
treeabf81500c841e19242c9e2105bf082e7f9bf5fb9
parentc2cbc549b69e8548e886caaf0a0a10d0964d1a82 (diff)
refresh search results if toggletag removes a hit
-rw-r--r--alot/buffer.py6
-rw-r--r--alot/command.py14
-rw-r--r--alot/db.py3
-rw-r--r--alot/walker.py5
4 files changed, 18 insertions, 10 deletions
diff --git a/alot/buffer.py b/alot/buffer.py
index 03e0cf8a..c25e0b66 100644
--- a/alot/buffer.py
+++ b/alot/buffer.py
@@ -110,10 +110,10 @@ class SearchBuffer(Buffer):
self.isinitialized = True
self.result_count = self.dbman.count_messages(self.querystring)
- tids = self.dbman.search_thread_ids(self.querystring)
- self.threadlist = IteratorWalker(tids.__iter__(), widgets.ThreadlineWidget,
+ self.tids = self.dbman.search_thread_ids(self.querystring)
+ self.threadlist = IteratorWalker(self.tids.__iter__(), widgets.ThreadlineWidget,
dbman=self.dbman)
- self.ui.logger.debug(self.threadlist.lines)
+ self.ui.logger.debug(len(self.tids))
self.original_widget = urwid.ListBox(self.threadlist)
self.ui.logger.debug(self.threadlist.lines)
diff --git a/alot/command.py b/alot/command.py
index 64d0ba03..a83556d8 100644
--- a/alot/command.py
+++ b/alot/command.py
@@ -224,12 +224,14 @@ class ToggleThreadTagCommand(Command):
threadwidget = sbuffer.get_selected_threadline()
#threadwidget.reload_tag(ui.dbman) #threads seem to cache their tags
threadwidget.rebuild() #rebuild and redraw the line
- #TODO: remove line from searchlist if thread doesn't match the query
- #qs="(%s) AND thread:%s"%(sbuffer.querystring,self.thread.get_thread_id())
- #if ui.dbman.count_messages(qs) == 0:
- # ui.logger.debug('remove: %s'%self.thread)
- # #sbuffer.threadlist.remove(threadwidget)
- #sbuffer.rebuild()
+ #remove line from searchlist if thread doesn't match the query
+ qs="(%s) AND thread:%s"%(sbuffer.querystring,self.thread.get_thread_id())
+ msg_count = ui.dbman.count_messages(qs)
+ if ui.dbman.count_messages(qs) == 0:
+ ui.logger.debug('remove: %s'%self.thread)
+ sbuffer.threadlist.remove(threadwidget)
+ sbuffer.result_count -= self.thread.get_total_messages()
+ ui.update_footer()
diff --git a/alot/db.py b/alot/db.py
index 18104ee2..94b4568f 100644
--- a/alot/db.py
+++ b/alot/db.py
@@ -75,6 +75,9 @@ class Thread:
msg.thaw()
self.tags = [t for t in self.tags if t not in tags]
+ def get_thread_id(self):
+ return self.tid
+
def get_tags(self):
return self.tags
diff --git a/alot/walker.py b/alot/walker.py
index b3cedffd..b4efb228 100644
--- a/alot/walker.py
+++ b/alot/walker.py
@@ -28,7 +28,7 @@ class IteratorWalker(urwid.ListWalker):
def remove(self, obj):
self.lines.remove(obj)
self.set_focus(self.focus % len(self.lines))
-
+ self._modified()
def _get_at_pos(self, pos):
if pos < 0: # pos too low
@@ -56,3 +56,6 @@ class IteratorWalker(urwid.ListWalker):
next_widget = None
self.empty = True
return next_widget
+
+ def get_lines(self):
+ return self.lines