diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index d1cf5d9bf..819077e68 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,7 @@ 2006-01-07 Don Allingham + * src/FamilyList.py: new family list view + * src/DisplayModels.py: model for family list + * src/GrampsDb/_GrampsDbBase.py: column order for family view * src/PageView.py: support for ctrl-j for jump to person by gramps id * src/PersonView.py: support for ctrl-j for jump to person by gramps id * src/ToolTips.py: fix spacing diff --git a/gramps2/src/DisplayModels.py b/gramps2/src/DisplayModels.py index 4459745b3..30ed65d69 100644 --- a/gramps2/src/DisplayModels.py +++ b/gramps2/src/DisplayModels.py @@ -340,6 +340,9 @@ class SourceModel(BaseModel): DisplayTrace.DisplayTrace() return t +#------------------------------------------------------------------------- +# +# PlaceModel # #------------------------------------------------------------------------- class PlaceModel(BaseModel): @@ -446,6 +449,96 @@ class PlaceModel(BaseModel): DisplayTrace.DisplayTrace() return t +#------------------------------------------------------------------------- +# +# FamilyModel +# +#------------------------------------------------------------------------- +class FamilyModel(BaseModel): + + def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING): + self.gen_cursor = db.get_family_cursor + self.map = db.get_raw_family_data + self.fmap = [ + self.column_father, + self.column_mother, + self.column_id, + self.column_type, + self.column_change, + self.column_handle, + self.column_tooltip + ] + self.smap = [ + self.sort_father, + self.sort_mother, + self.column_id, + self.column_type, + self.sort_change, + self.column_handle, + self.column_tooltip + ] + BaseModel.__init__(self,db,scol,order,tooltip_column=6) + + def on_get_n_columns(self): + return len(self.fmap)+1 + + def column_handle(self,data): + return unicode(data[0]) + + def column_father(self,data): + if data[2]: + person = self.db.get_person_from_handle(data[2]) + return unicode(NameDisplay.displayer.sorted_name(person.primary_name)) + else: + return u"" + + def sort_father(self,data): + if data[2]: + person = self.db.get_person_from_handle(data[2]) + return person.primary_name.get_sort_name() + else: + return u"" + + def column_mother(self,data): + if data[3]: + person = self.db.get_person_from_handle(data[3]) + return unicode(NameDisplay.displayer.sorted_name(person.primary_name)) + else: + return u"" + + def sort_mother(self,data): + if data[3]: + person = self.db.get_person_from_handle(data[3]) + return person.primary_name.get_sort_name() + else: + return u"" + + def column_type(self,data): + t = data[5] + if t[0] == RelLib.Family.CUSTOM: + val = t[1] + else: + val = Utils.family_relations[t[0]] + return unicode(val) + + def column_id(self,data): + return unicode(data[1]) + + def sort_change(self,data): + return time.localtime(data[13]) + + def column_change(self,data): + return unicode(time.strftime('%x %X',time.localtime(data[13])), + _codeset) + + def column_tooltip(self,data): + try: + t = ToolTips.TipFromFunction(self.db, lambda: self.db.get_family_from_handle(data[0])) + except: + DisplayTrace.DisplayTrace() + return t + + #------------------------------------------------------------------------- # # MediaModel diff --git a/gramps2/src/FamilyList.py b/gramps2/src/FamilyList.py new file mode 100644 index 000000000..8a628af77 --- /dev/null +++ b/gramps2/src/FamilyList.py @@ -0,0 +1,120 @@ +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2001-2005 Donald N. Allingham +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id$ + +#------------------------------------------------------------------------- +# +# GTK/Gnome modules +# +#------------------------------------------------------------------------- +import gtk +import gtk.gdk + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +import RelLib +import PageView +#import EditPlace +import DisplayModels +import const +import Utils +from QuestionDialog import QuestionDialog, ErrorDialog + +#------------------------------------------------------------------------- +# +# internationalization +# +#------------------------------------------------------------------------- +from gettext import gettext as _ + +column_names = [ + _('Father'), + _('Mother'), + _('ID'), + _('Relationship'), + _('Last Changed'), + ] + +#------------------------------------------------------------------------- +# +# FamilyListView +# +#------------------------------------------------------------------------- +class FamilyListView(PageView.ListView): + def __init__(self,dbstate,uistate): + + signal_map = { + 'family-add' : self.row_add, + 'family-update' : self.row_update, + 'family-delete' : self.row_delete, + 'family-rebuild' : self.build_tree, + } + + PageView.ListView.__init__(self,'Family List View',dbstate,uistate, + column_names,len(column_names), + DisplayModels.FamilyModel, + signal_map) + + def column_order(self): + return self.dbstate.db.get_family_list_column_order() + + def get_stock(self): + return 'gramps-family-list' + + def ui_definition(self): + return ''' + + + + + + + + + + + + + + + + + + + + + + ''' + + def on_double_click(self,obj,event): + return + + def add(self,obj): + return + + def remove(self,obj): + return + + def edit(self,obj): + return + diff --git a/gramps2/src/GrampsDb/_GrampsDbBase.py b/gramps2/src/GrampsDb/_GrampsDbBase.py index b227b9b44..0530c68f6 100644 --- a/gramps2/src/GrampsDb/_GrampsDbBase.py +++ b/gramps2/src/GrampsDb/_GrampsDbBase.py @@ -72,6 +72,7 @@ SOURCE_COL_KEY = 'source_columns' MEDIA_COL_KEY = 'media_columns' REPOSITORY_COL_KEY = 'repository_columns' EVENT_COL_KEY = 'event_columns' +FAMILY_COL_KEY = 'family_columns' # The following two dictionaries provide fast translation @@ -1463,6 +1464,13 @@ class GrampsDbBase(GrampsDBCallback): """ self._set_column_order(col_list,PERSON_COL_KEY) + def set_family_list_column_order(self,col_list): + """ + Stores the Person display common information in the + database's metadata. + """ + self._set_column_order(col_list,FAMILY_COL_KEY) + def set_child_column_order(self,col_list): """ Stores the Person display common information in the @@ -1523,6 +1531,14 @@ class GrampsDbBase(GrampsDBCallback): default = [(1,1),(1,2),(1,3),(0,4),(1,5),(0,6),(0,7),(0,8),(0,9,)] return self._get_column_order(PERSON_COL_KEY,default) + def get_family_list_column_order(self): + """ + Returns the Person display common information stored in the + database's metadata. + """ + default = [(1,1),(1,2),(1,3),(1,4),(0,5)] + return self._get_column_order(FAMILY_COL_KEY,default) + def get_child_column_order(self): """ Returns the Person display common information stored in the diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index 3ebad666d..116815688 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -37,6 +37,7 @@ log = logging.getLogger(".") #------------------------------------------------------------------------- import ViewManager import PersonView +import FamilyList import RepositoryView import GrampsDisplay import RelLib @@ -67,6 +68,7 @@ def register_stock_icons (): items = [ ('people48.png',('gramps-person','Person',gtk.gdk.CONTROL_MASK,0,'')), ('family48.png',('gramps-family','Family',gtk.gdk.CONTROL_MASK,0,'')), + ('family48.png',('gramps-family-list','Family List',gtk.gdk.CONTROL_MASK,0,'')), ('media.png',('gramps-media','Media',gtk.gdk.CONTROL_MASK,0,'')), ('ped24.png',('gramps-pedigree','Pedigree',gtk.gdk.CONTROL_MASK,0,'')), ('repos.png',('gramps-repository','Repositories', @@ -146,6 +148,7 @@ class Gramps: vm = ViewManager.ViewManager(state) vm.register_view(PersonView.PersonView) vm.register_view(FamilyView.FamilyView) + vm.register_view(FamilyList.FamilyListView) vm.register_view(PedView.PedView) vm.register_view(EventView.EventView) vm.register_view(SourceView.SourceView)