Add preliminary log level filtering support

This commit is contained in:
René Stadler 2007-11-30 17:13:12 +02:00 committed by Stefan Sauer
parent 3087edd7f8
commit 406eb80d03

View file

@ -411,11 +411,15 @@ class FilteredLogModel (FilteredLogModelBase):
def add_filter (self, filter): def add_filter (self, filter):
del self.line_offsets[:]
del self.line_levels[:]
level_id = self.COL_LEVEL
func = filter.filter_func func = filter.filter_func
#enum = self.super_model.iter_rows_offset () enum = self.super_model.iter_rows_offset ()
enum = self.iter_rows_offset () for row, offset in enum:
self.line_offsets[:] = (offset for row, offset in enum if func (row):
if func (row)) self.line_offsets.append (offset)
self.line_levels.append (row[level_id])
def line_index_from_super (self, super_line_index): def line_index_from_super (self, super_line_index):
@ -439,7 +443,7 @@ class DebugLevelFilter (Filter):
col_id = LogModelBase.COL_LEVEL col_id = LogModelBase.COL_LEVEL
def filter_func (row): def filter_func (row):
return row[col_id] < debug_level return row[col_id] != debug_level
self.filter_func = filter_func self.filter_func = filter_func
class SubRange (object): class SubRange (object):
@ -1486,20 +1490,14 @@ class Window (object):
def handle_hide_log_level_action_activate (self, action): def handle_hide_log_level_action_activate (self, action):
return # FIXME
row = self.get_active_line () row = self.get_active_line ()
debug_level = row[LogModelBase.COL_LEVEL] debug_level = row[LogModelBase.COL_LEVEL]
try: model = FilteredLogModel (self.log_model)
target_level = debug_level.higher_level () model.add_filter (DebugLevelFilter (debug_level))
except ValueError: self.model_filter = model
return self.change_model (self.model_filter)
self.log_filter.add_filter (DebugLevelFilter (target_level)) self.actions.show_hidden_lines.props.sensitive = True
# FIXME:
self.log_view.props.model = gtk.TreeStore (str)
self.log_view.props.model = self.log_filter
def handle_hide_log_category_action_activate (self, action): def handle_hide_log_category_action_activate (self, action):