From 2367107d898a0c0c050261d7a7822bdd5603f683 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 29 Sep 2004 03:19:01 +0000 Subject: [PATCH] * src/PeopleModel.py: sort based of "group as" value * src/GrampsInMem.py: used "group as" value for surname list * src/GrampsBSDDB.py: used "group as" value for surname list * src/GrampsDbBase.py: accept "" and None for empty id values svn: r3584 --- gramps2/ChangeLog | 4 ++ gramps2/src/EditPerson.py | 5 +- gramps2/src/GrampsBSDDB.py | 2 +- gramps2/src/GrampsDbBase.py | 6 +-- gramps2/src/GrampsInMemDB.py | 2 +- gramps2/src/NameEdit.py | 2 +- gramps2/src/PeopleModel.py | 2 +- gramps2/src/RelLib.py | 101 ++++++++++++++++++++++++++--------- 8 files changed, 92 insertions(+), 32 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index bfadce60f..00ac48495 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -6,6 +6,10 @@ * src/NameEdit.py: support for patronymic names * src/gramps.glade: NameEditor and EditPerson changes for enhanced name support + * src/PeopleModel.py: sort based of "group as" value + * src/GrampsInMem.py: used "group as" value for surname list + * src/GrampsBSDDB.py: used "group as" value for surname list + * src/GrampsDbBase.py: accept "" and None for empty id values 2004-09-27 Don Allingham * src/PeopleModel.py: remove unused map diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index 68de0645f..17a43218d 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -1618,10 +1618,13 @@ class EditPerson: self.person.set_source_reference_list(self.srcreflist) self.update_lists() - if self.person.get_handle() == None: + if not self.person.get_handle(): self.db.add_person(self.person, trans) else: + if not self.person.get_gramps_id(): + self.person.set_gramps_id(self.db.find_next_person_gramps_id()) self.db.commit_person(self.person, trans) + print "id",self.person.get_gramps_id() n = self.person.get_primary_name().get_regular_name() self.db.transaction_commit(trans,_("Edit Person (%s)") % n) if self.callback: diff --git a/gramps2/src/GrampsBSDDB.py b/gramps2/src/GrampsBSDDB.py index 66cffb0f2..0b6dc3443 100644 --- a/gramps2/src/GrampsBSDDB.py +++ b/gramps2/src/GrampsBSDDB.py @@ -29,7 +29,7 @@ from GrampsDbBase import * from bsddb import dbshelve, db def find_surname(key,data): - return str(data[3].get_surname()) + return str(data[3].get_group_as()) def find_idmap(key,data): return str(data[1]) diff --git a/gramps2/src/GrampsDbBase.py b/gramps2/src/GrampsDbBase.py index eeee88437..4506af72e 100644 --- a/gramps2/src/GrampsDbBase.py +++ b/gramps2/src/GrampsDbBase.py @@ -1,4 +1,4 @@ - +# # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2004 Donald N. Allingham @@ -483,9 +483,9 @@ class GrampsDbBase: Adds a Person to the database, assigning internal IDs if they have not already been defined. """ - if person.get_gramps_id() == None: + if not person.get_gramps_id(): person.set_gramps_id(self.find_next_person_gramps_id()) - if person.get_handle() == None: + if not person.get_handle(): person.set_handle(Utils.create_id()) self.commit_person(person,transaction) self.genderStats.count_person (person, self) diff --git a/gramps2/src/GrampsInMemDB.py b/gramps2/src/GrampsInMemDB.py index 295d0a92d..76f1b4945 100644 --- a/gramps2/src/GrampsInMemDB.py +++ b/gramps2/src/GrampsInMemDB.py @@ -61,7 +61,7 @@ class GrampsInMemDB(GrampsDbBase): a = {} for person_id in self.get_person_handles(sort_handles=False): p = self.get_person_from_handle(person_id) - a[p.get_primary_name().get_surname()] = 1 + a[p.get_primary_name().get_group_as()] = 1 vals = a.keys() vals.sort() return vals diff --git a/gramps2/src/NameEdit.py b/gramps2/src/NameEdit.py index a486aa197..c183a7d86 100644 --- a/gramps2/src/NameEdit.py +++ b/gramps2/src/NameEdit.py @@ -244,7 +244,7 @@ class NameEditor: if self.name.get_group_as() != self.surname_field.get_text(): self.name.set_group_as("") self.parent.lists_changed = 1 - elif self.name.set_group_as() != self.group_as.get_text(): + elif self.name.get_group_as() != self.group_as.get_text(): self.name.set_group_as(self.group_as.get_text()) self.parent.lists_changed = 1 diff --git a/gramps2/src/PeopleModel.py b/gramps2/src/PeopleModel.py index 19c68a0c6..bea2fbb21 100644 --- a/gramps2/src/PeopleModel.py +++ b/gramps2/src/PeopleModel.py @@ -97,7 +97,7 @@ class PeopleModel(gtk.GenericTreeModel): for person_handle in self.db.get_person_handles(sort_handles=False): person = self.db.get_person_from_handle(person_handle) - surname = unicode(person.get_primary_name().get_surname()) + surname = unicode(person.get_primary_name().get_group_as()) if self.sname_sub.has_key(surname): self.sname_sub[surname].append(person_handle) diff --git a/gramps2/src/RelLib.py b/gramps2/src/RelLib.py index 08b57f457..0858809a9 100644 --- a/gramps2/src/RelLib.py +++ b/gramps2/src/RelLib.py @@ -30,12 +30,13 @@ __version__ = "$Revision$" # standard python modules # #------------------------------------------------------------------------- +from gettext import gettext as _ from re import compile + import os import os.path import time import types -from gettext import gettext as _ #------------------------------------------------------------------------- # @@ -1855,34 +1856,70 @@ class Name(DataObj): self.sort_as = self.DEF self.display_as = self.DEF - def get_group_as(self): - if self.group_as: - return self.group_as - else: - return self.surname - def set_group_as(self,name): + """ + Sets the grouping name for a person. Normally, this is the person's + surname. However, some locales group equivalent names (e.g. Ivanova + and Ivanov in Russian are usually considered equivalent. + """ if name == self.surname: self.group_as = "" else: self.group_as = name + def get_group_as(self): + """ + Returns the grouping name, which is used to group equivalent surnames. + """ + if self.group_as: + return self.group_as + else: + return self.surname + def set_sort_as(self,value): + """ + Specifies the sorting method for the specified name. Typically the + locale's default should be used. However, there may be names where + a specific sorting structure is desired for a name. + """ self.sort_as = value def get_sort_as(self): + """ + Returns the selected sorting method for the name. The options are + DEF (default for the current locale), LNFN (last name, first name), + or FNLN (first name, last name). + """ return self.sort_as def set_display_as(self,value): + """ + Specifies the display format for the specified name. Typically the + locale's default should be used. However, there may be names where + a specific display format is desired for a name. + """ self.display_as = value def get_display_as(self): + """ + Returns the selected display format for the name. The options are + DEF (default for the current locale), LNFN (last name, first name), + or FNLN (first name, last name). + """ return self.display_as def get_surname_prefix(self): + """ + Returns the prefix (or article) of a surname. The prefix is not + used for sorting or grouping. + """ return self.prefix def set_surname_prefix(self,val): + """ + Sets the prefix (or article) of a surname. Examples of articles + would be 'de' or 'van'. + """ self.prefix = val def set_type(self,type): @@ -1944,60 +1981,76 @@ class Name(DataObj): def get_name(self): """returns a name string built from the components of the Name instance, in the form of surname, Firstname""" - + + if self.patronymic: + first = "%s %s" % (self.first_name, self.patronymic) + else: + first = self.first_name if self.suffix: if self.prefix: - return "%s %s, %s %s" % (self.prefix, self.surname, self.first_name, self.suffix) + return "%s %s, %s %s" % (self.prefix, self.surname, first, self.suffix) else: - return "%s, %s %s" % (self.surname, self.first_name, self.suffix) + return "%s, %s %s" % (self.surname, first, self.suffix) else: if self.prefix: - return "%s %s, %s" % (self.prefix,self.surname, self.first_name) + return "%s %s, %s" % (self.prefix,self.surname, first) else: - return "%s, %s" % (self.surname, self.first_name) + return "%s, %s" % (self.surname, first) def get_upper_name(self): """returns a name string built from the components of the Name instance, in the form of surname, Firstname""" + if self.patronymic: + first = "%s %s" % (self.first_name, self.patronymic) + else: + first = self.first_name if self.suffix: if self.prefix: - return "%s %s, %s %s" % (self.prefix.upper(), self.surname.upper(), self.first_name, self.suffix) + return "%s %s, %s %s" % (self.prefix.upper(), self.surname.upper(), first, self.suffix) else: - return "%s, %s %s" % (self.surname.upper(), self.first_name, self.suffix) + return "%s, %s %s" % (self.surname.upper(), first, self.suffix) else: if self.prefix: - return "%s %s, %s" % (self.prefix.upper(), self.surname.upper(), self.first_name) + return "%s %s, %s" % (self.prefix.upper(), self.surname.upper(), first) else: - return "%s, %s" % (self.surname.upper(), self.first_name) + return "%s, %s" % (self.surname.upper(), first) def get_regular_name(self): """returns a name string built from the components of the Name instance, in the form of Firstname surname""" + if self.patronymic: + first = "%s %s" % (self.first_name, self.patronymic) + else: + first = self.first_name if (self.suffix == ""): if self.prefix: - return "%s %s %s" % (self.first_name, self.prefix, self.surname) + return "%s %s %s" % (first, self.prefix, self.surname) else: - return "%s %s" % (self.first_name, self.surname) + return "%s %s" % (first, self.surname) else: if self.prefix: - return "%s %s %s, %s" % (self.first_name, self.prefix, self.surname, self.suffix) + return "%s %s %s, %s" % (first, self.prefix, self.surname, self.suffix) else: - return "%s %s, %s" % (self.first_name, self.surname, self.suffix) + return "%s %s, %s" % (first, self.surname, self.suffix) def get_regular_upper_name(self): """returns a name string built from the components of the Name instance, in the form of Firstname surname""" + if self.patronymic: + first = "%s %s" % (self.first_name, self.patronymic) + else: + first = self.first_name if (self.suffix == ""): if self.prefix: - return "%s %s %s" % (self.first_name, self.prefix.upper(), self.surname.upper()) + return "%s %s %s" % (first, self.prefix.upper(), self.surname.upper()) else: - return "%s %s" % (self.first_name, self.surname.upper()) + return "%s %s" % (first, self.surname.upper()) else: if self.prefix: - return "%s %s %s, %s" % (self.first_name, self.prefix.upper(), self.surname.upper(), self.suffix) + return "%s %s %s, %s" % (first, self.prefix.upper(), self.surname.upper(), self.suffix) else: - return "%s %s, %s" % (self.first_name, self.surname.upper(), self.suffix) + return "%s %s, %s" % (first, self.surname.upper(), self.suffix) def are_equal(self,other): """compares to names to see if they are equal, return 0 if they