* 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
This commit is contained in:
Don Allingham 2004-09-29 03:19:01 +00:00
parent b79615e888
commit 6a6677e240
8 changed files with 92 additions and 32 deletions

View File

@ -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 <dallingham@users.sourceforge.net>
* src/PeopleModel.py: remove unused map

View File

@ -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:

View File

@ -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])

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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