* src/DisplayModels.py: Fix sorting

* src/FamilyList.py: Fix sorting
* src/PageView.py: Fix sorting
* src/GrampsDb/_GrampsDbBase.py: set default column sorting order


svn: r5697
This commit is contained in:
Don Allingham 2006-01-09 00:54:04 +00:00
parent 41e81a1034
commit f38901bc23
5 changed files with 27 additions and 28 deletions

View File

@ -1,3 +1,9 @@
2006-01-08 Don Allingham <don@gramps-project.org>
* src/DisplayModels.py: Fix sorting
* src/FamilyList.py: Fix sorting
* src/PageView.py: Fix sorting
* src/GrampsDb/_GrampsDbBase.py: set default column sorting order
2006-01-08 Richard Taylor <rjt-gramps@thegrindstone.me.uk> 2006-01-08 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/GrampsLogger/_ErrorReportAssistant.py: don't show excep twice * src/GrampsLogger/_ErrorReportAssistant.py: don't show excep twice
* src/GrampsLogger/_ErrorView.py: don't show excep twice * src/GrampsLogger/_ErrorView.py: don't show excep twice

View File

@ -58,6 +58,9 @@ _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
_codeset = GrampsLocale.codeset _codeset = GrampsLocale.codeset
def sfunc(a,b):
return locale.strcoll(a[0],b[0])
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# BaseModel # BaseModel
@ -86,7 +89,7 @@ class BaseModel(gtk.GenericTreeModel):
sarray.append((self.sort_func(data[1]),data[0])) sarray.append((self.sort_func(data[1]),data[0]))
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
sarray.sort() sarray.sort(sfunc)
if self.reverse: if self.reverse:
sarray.reverse() sarray.reverse()
return map(lambda x: x[1], sarray) return map(lambda x: x[1], sarray)
@ -460,18 +463,18 @@ class FamilyModel(BaseModel):
self.gen_cursor = db.get_family_cursor self.gen_cursor = db.get_family_cursor
self.map = db.get_raw_family_data self.map = db.get_raw_family_data
self.fmap = [ self.fmap = [
self.column_id,
self.column_father, self.column_father,
self.column_mother, self.column_mother,
self.column_id,
self.column_type, self.column_type,
self.column_change, self.column_change,
self.column_handle, self.column_handle,
self.column_tooltip self.column_tooltip
] ]
self.smap = [ self.smap = [
self.column_id,
self.sort_father, self.sort_father,
self.sort_mother, self.sort_mother,
self.column_id,
self.column_type, self.column_type,
self.sort_change, self.sort_change,
self.column_handle, self.column_handle,
@ -802,7 +805,6 @@ class RepositoryModel(BaseModel):
except: except:
return u'' return u''
def column_email(self,data): def column_email(self,data):
return unicode(data[5]) return unicode(data[5])

View File

@ -48,9 +48,9 @@ from QuestionDialog import QuestionDialog, ErrorDialog
from gettext import gettext as _ from gettext import gettext as _
column_names = [ column_names = [
_('ID'),
_('Father'), _('Father'),
_('Mother'), _('Mother'),
_('ID'),
_('Relationship'), _('Relationship'),
_('Last Changed'), _('Last Changed'),
] ]

View File

@ -1536,7 +1536,7 @@ class GrampsDbBase(GrampsDBCallback):
Returns the Person display common information stored in the Returns the Person display common information stored in the
database's metadata. database's metadata.
""" """
default = [(1,1),(1,2),(1,3),(1,4),(0,5)] default = [(1,0), (1,1),(1,2),(1,3),(0,4)]
return self._get_column_order(FAMILY_COL_KEY,default) return self._get_column_order(FAMILY_COL_KEY,default)
def get_child_column_order(self): def get_child_column_order(self):
@ -1552,7 +1552,7 @@ class GrampsDbBase(GrampsDBCallback):
Returns the Place display common information stored in the Returns the Place display common information stored in the
database's metadata. database's metadata.
""" """
default = [(1,1),(1,2),(0,3),(0,4),(1,5),(0,6),(1,7),(0,8),(0,9),(0,10)] default = [(1,0), (1,1),(1,2),(0,3),(0,4),(1,5),(0,6),(1,7),(0,8),(0,9),(0,10)]
return self._get_column_order(PLACE_COL_KEY,default) return self._get_column_order(PLACE_COL_KEY,default)
def get_source_column_order(self): def get_source_column_order(self):
@ -1560,7 +1560,7 @@ class GrampsDbBase(GrampsDBCallback):
Returns the Source display common information stored in the Returns the Source display common information stored in the
database's metadata. database's metadata.
""" """
default = [(1,1),(1,2),(0,3),(1,4),(0,5)] default = [(1,0),(1,1),(1,2),(0,3),(1,4),(0,5)]
return self._get_column_order(SOURCE_COL_KEY,default) return self._get_column_order(SOURCE_COL_KEY,default)
def get_media_column_order(self): def get_media_column_order(self):
@ -1568,7 +1568,7 @@ class GrampsDbBase(GrampsDBCallback):
Returns the MediaObject display common information stored in the Returns the MediaObject display common information stored in the
database's metadata. database's metadata.
""" """
default = [(1,1),(1,2),(1,3),(1,5),(0,4)] default = [(1,0),(1,1),(1,2),(1,3),(1,5),(0,4)]
return self._get_column_order(MEDIA_COL_KEY,default) return self._get_column_order(MEDIA_COL_KEY,default)
def get_event_column_order(self): def get_event_column_order(self):
@ -1576,7 +1576,7 @@ class GrampsDbBase(GrampsDBCallback):
Returns the Event display common information stored in the Returns the Event display common information stored in the
database's metadata. database's metadata.
""" """
default = [(1,1),(1,2),(1,3),(1,4),(1,5),(0,6)] default = [(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(0,6)]
return self._get_column_order(EVENT_COL_KEY,default) return self._get_column_order(EVENT_COL_KEY,default)
def get_repository_column_order(self): def get_repository_column_order(self):
@ -1584,7 +1584,7 @@ class GrampsDbBase(GrampsDBCallback):
Returns the Repository display common information stored in the Returns the Repository display common information stored in the
database's metadata. database's metadata.
""" """
default = [(1,1),(0,5),(0,6),(1,2),(1,3),(0,4),(0,7),(0,8),(0,9),(0,10)] default = [(1,0),(1,1),(0,5),(0,6),(1,2),(1,3),(0,4),(0,7),(0,8),(0,9),(0,10)]
return self._get_column_order(REPOSITORY_COL_KEY,default) return self._get_column_order(REPOSITORY_COL_KEY,default)
def _update_reference_map(self,obj): def _update_reference_map(self,obj):

View File

@ -357,8 +357,8 @@ class ListView(PageView):
path = self.model.on_get_path(handle) path = self.model.on_get_path(handle)
self.selection.select_path(path) self.selection.select_path(path)
self.list.scroll_to_cell(path,None,1,0.5,0) self.list.scroll_to_cell(path,None,1,0.5,0)
for i in range(0,len(self.columns)): for i in xrange(len(self.columns)):
self.columns[i].set_sort_indicator(i==colmap[data][1]-1) self.columns[i].set_sort_indicator(i==colmap[data][1])
self.columns[self.sort_col].set_sort_order(order) self.columns[self.sort_col].set_sort_order(order)
def build_columns(self): def build_columns(self):
@ -367,17 +367,8 @@ class ListView(PageView):
self.columns = [] self.columns = []
column = gtk.TreeViewColumn(self.colinfo[0], self.renderer,text=0)
column.set_resizable(True)
column.set_min_width(225)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
self.list.append_column(column)
self.columns = [column]
index = 0 index = 0
for pair in self.column_order(): for pair in [pair for pair in self.column_order() if pair[0]]:
if not pair[0]:
continue
name = self.colinfo[pair[1]] name = self.colinfo[pair[1]]
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1]) column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
column.connect('clicked',self.column_clicked,index) column.connect('clicked',self.column_clicked,index)
@ -388,14 +379,14 @@ class ListView(PageView):
self.list.append_column(column) self.list.append_column(column)
index += 1 index += 1
def build_tree(self): def build_tree(self):
self.model = self.make_model(self.dbstate.db,self.sort_col) self.model = self.make_model(self.dbstate.db,self.sort_col)
self.list.set_model(self.model) self.list.set_model(self.model)
self.selection = self.list.get_selection() self.selection = self.list.get_selection()
if self.model.tooltip_column != None: if self.model.tooltip_column != None:
self.tooltips = TreeTips.TreeTips(self.list,self.model.tooltip_column,True) self.tooltips = TreeTips.TreeTips(self.list,
self.model.tooltip_column,True)
def change_db(self,db): def change_db(self,db):
for sig in self.signal_map: for sig in self.signal_map: