diff --git a/ChangeLog b/ChangeLog index 58f44ce04..7ccee9042 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-01-22 Don Allingham + * src/DisplayModels/_BaseModel.py: avoid rebuild on delete + * src/PageView.py: avoid rebuild on delete + 2007-01-22 Alex Roitman * src/Editors/_EditSource.py (query_response): Remove sourcerefs from repos (indirectly, through secondary objects). diff --git a/src/DisplayModels/_BaseModel.py b/src/DisplayModels/_BaseModel.py index 64be96311..2649e6227 100644 --- a/src/DisplayModels/_BaseModel.py +++ b/src/DisplayModels/_BaseModel.py @@ -104,16 +104,13 @@ class BaseModel(gtk.GenericTreeModel): data = cursor.next() cursor.close() - sarray.sort() - - if self.reverse: - sarray.reverse() + sarray.sort(reverse=self.reverse) return [ x[1] for x in sarray ] def _rebuild_search(self,ignore=None): if self.db.is_open(): - if self.search: + if self.search and self.search.text: self.datalist = [h for h in self.sort_keys()\ if self.search.match(h) and \ h not in self.skip and h != ignore] @@ -123,9 +120,8 @@ class BaseModel(gtk.GenericTreeModel): i = 0 self.indexlist = {} for key in self.datalist: - if key not in self.skip and key != ignore: - self.indexlist[key] = i - i += 1 + self.indexlist[key] = i + i += 1 else: self.datalist = [] self.indexlist = {} @@ -150,16 +146,19 @@ class BaseModel(gtk.GenericTreeModel): self.datalist = [] self.indexlist = {} - def add_row_by_handle(self,handle): - self.rebuild_data() - index = self.indexlist.get(handle) - if index: - node = self.get_iter(index) - self.row_inserted(index, node) +# def add_row_by_handle(self,handle): +# self.build_tree() def delete_row_by_handle(self,handle): index = self.indexlist[handle] - self.rebuild_data(ignore=handle) + + del self.datalist[index] + del self.indexlist[handle] + + for key in self.indexlist: + if self.indexlist[key] > index: + self.indexlist[key] -= 1 + #self.rebuild_data(ignore=handle) self.row_deleted(index) def update_row_by_handle(self,handle): diff --git a/src/PageView.py b/src/PageView.py index e29e6a17a..759054a3c 100644 --- a/src/PageView.py +++ b/src/PageView.py @@ -739,8 +739,7 @@ class ListView(BookMarkView): def row_add(self,handle_list): if self.active: - for handle in handle_list: - self.model.add_row_by_handle(handle) + self.build_tree() else: self.dirty = True