From adf6c47c96fa4df0c2569cb5ab392513db5ccfdf Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sat, 18 Oct 2003 02:39:55 +0000 Subject: [PATCH] * src/RelLib.py: Add a "sortbynames" to presort keys before adding to the tables * src/PeopleView.py: Presort names before adding, delay enabling of autosorting until data has been added * src/PeopleStore.py: Add enable sort task svn: r2267 --- src/PeopleStore.py | 6 ++++-- src/PeopleView.py | 4 ++-- src/RelLib.py | 10 +++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/PeopleStore.py b/src/PeopleStore.py index 34cbcd790..095aa32cc 100644 --- a/src/PeopleStore.py +++ b/src/PeopleStore.py @@ -85,8 +85,6 @@ class PeopleStore: self.cids.append(name[1]) self.tree.append_column(column) - if self.cids[0] != -1: - self.model.set_sort_column_id(self.cids[0],gtk.SORT_ASCENDING) self.connect_model() if select_func: @@ -95,6 +93,10 @@ class PeopleStore: self.double_click = event_func self.tree.connect('event',self.button_press) + def enable_sort(self): + if self.cids[0] != -1: + self.model.set_sort_column_id(self.cids[0],gtk.SORT_ASCENDING) + def unselect(self): self.selection.unselect_all() diff --git a/src/PeopleView.py b/src/PeopleView.py index 1ec592fc7..29156618d 100644 --- a/src/PeopleView.py +++ b/src/PeopleView.py @@ -206,7 +206,7 @@ class PeopleView: if change: self.parent.change_active_person(person) self.goto_active_person() - model.sort() + model.enable_sort() def goto_active_person(self,first=0): if not self.parent.active_person: @@ -269,7 +269,7 @@ class PeopleView: if current_model == None: self.id2col = {} - for key in self.parent.db.getPersonKeys(): + for key in self.parent.db.sortPersonKeys(): person = self.parent.db.getPerson(key) val = self.parent.db.getPersonDisplay(key) pg = val[5] diff --git a/src/RelLib.py b/src/RelLib.py index 8e877bb82..3e1574c96 100644 --- a/src/RelLib.py +++ b/src/RelLib.py @@ -2197,7 +2197,15 @@ class GrampsDB(Persistent): def getPersonKeys(self): return self.personTable.keys() - + + def sortbyname(self,f,s): + return cmp(self.personTable[f][5],self.personTable[s][5]) + + def sortPersonKeys(self): + keys = self.personTable.keys() + keys.sort(self.sortbyname) + return keys + def getPersonDisplay(self,key): return self.personTable[key]