List sorting

svn: r1219
This commit is contained in:
Don Allingham 2002-12-06 03:37:31 +00:00
parent 37b8945a47
commit 3484056b38
3 changed files with 16 additions and 14 deletions

Binary file not shown.

View File

@ -33,6 +33,8 @@ class ListModel:
self.data_index = l self.data_index = l
self.cids = []
cnum = 0 cnum = 0
for name in dlist: for name in dlist:
renderer = gtk.CellRendererText() renderer = gtk.CellRendererText()
@ -46,21 +48,15 @@ class ListModel:
column.set_clickable(gtk.FALSE) column.set_clickable(gtk.FALSE)
else: else:
column.set_clickable(gtk.TRUE) column.set_clickable(gtk.TRUE)
column.set_sort_column_id(name[1])
cnum = cnum + 1 cnum = cnum + 1
self.cids.append(name[1])
if name[1] != -1:
self.tree.append_column(column) self.tree.append_column(column)
self.column = None self.model.set_sort_column_id(self.cids[0],gtk.SORT_ASCENDING)
num = 0
for name in dlist:
column = self.tree.get_column(num)
if name[1] != -1:
column.set_sort_column_id(name[1])
if not self.column:
self.column = column
num = num + 1
self.connect_model() self.connect_model()
self.model.set_sort_column_id(0,gtk.SORT_ASCENDING)
if select_func: if select_func:
self.selection.connect('changed',select_func) self.selection.connect('changed',select_func)
@ -73,11 +69,15 @@ class ListModel:
def connect_model(self): def connect_model(self):
self.tree.set_model(self.model) self.tree.set_model(self.model)
self.model.set_sort_column_id(0,gtk.SORT_ASCENDING) self.sort()
def sort(self): def sort(self):
val = self.model.get_sort_column_id() val = self.model.get_sort_column_id()
self.model.set_sort_column_id(val[0],val[1]) col = val[0]
if col > 0:
self.model.set_sort_column_id(col,val[1])
else:
self.model.set_sort_column_id(self.cids[0],val[1])
self.model.sort_column_changed() self.model.sort_column_changed()
def get_selected(self): def get_selected(self):

View File

@ -1387,6 +1387,8 @@ class Gramps:
if self.id2col.has_key(key): if self.id2col.has_key(key):
(model,iter,page) = self.id2col[key] (model,iter,page) = self.id2col[key]
model.remove(iter) model.remove(iter)
for i in self.pl_page:
i.sort()
def on_home_clicked(self,obj): def on_home_clicked(self,obj):
temp = self.db.getDefaultPerson() temp = self.db.getDefaultPerson()