From 9619daa316010fe41deba0de11596bb434f43626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Stadler?= Date: Wed, 14 Nov 2007 16:56:35 +0200 Subject: [PATCH] Change model design to be more filter friendly --- debug-viewer/GstDebugViewer/GUI.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/debug-viewer/GstDebugViewer/GUI.py b/debug-viewer/GstDebugViewer/GUI.py index 8496008f71..762254c400 100755 --- a/debug-viewer/GstDebugViewer/GUI.py +++ b/debug-viewer/GstDebugViewer/GUI.py @@ -92,10 +92,13 @@ class LogModelBase (gtk.GenericTreeModel): def on_get_iter (self, path): if len (path) > 1: - raise ValueError ("flat model") + return None line_index = path[0] + if line_index > len (self.line_offsets) - 1: + return None + return line_index def on_get_path (self, line_index): @@ -114,7 +117,7 @@ class LogModelBase (gtk.GenericTreeModel): def on_iter_next (self, line_index): - if line_index > len (self.line_offsets) - 1: + if line_index >= len (self.line_offsets) - 1: return None else: return line_index + 1 @@ -123,7 +126,7 @@ class LogModelBase (gtk.GenericTreeModel): return self.on_iter_nth_child (parent, 0) - def on_iter_has_child (self, line_index): + def on_iter_has_child (self, rowref): return False @@ -227,14 +230,11 @@ class FilteredLogModel (LogModelBase): LogModelBase.__init__ (self) self.parent_model = lazy_log_model + self.ensure_cached = lazy_log_model.ensure_cached - self.line_offsets = [] self.line_cache = lazy_log_model.line_cache - def ensure_cached (self, line_index): - - line_offset = self.line_offsets[line_index] - self.parent_model.ensure_cached (line_offset) + self.line_offsets += lazy_log_model.line_offsets # Sync with gst-inspector! class Column (object): @@ -985,7 +985,8 @@ class Window (object): sentinel () def idle_set (): - self.log_view.props.model = self.log_model + #self.log_view.props.model = self.log_model + self.log_view.props.model = FilteredLogModel (self.log_model) return False gobject.idle_add (idle_set)