From 27e22a5b21542b55715572f29bd40d8f368de756 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 25 May 2005 18:51:10 +0000 Subject: [PATCH] * src/NameDisplay.py (sorted): Use sorted name, not display name flag. * src/Sort.py (by_sorted_name): Add method. * src/WebPage (dump_index): Proper sorting, for both last name sections and the names within each section. svn: r4679 --- gramps2/ChangeLog | 5 +++++ gramps2/src/NameDisplay.py | 2 +- gramps2/src/Sort.py | 26 ++++++++++++++++++++++---- gramps2/src/plugins/WebPage.py | 12 +++++++----- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 8536b3a54..a00c94cf2 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,6 +1,11 @@ 2005-05-25 Alex Roitman * src/WriteGedcom.py (write_person): Typo. + * src/NameDisplay.py (sorted): Use sorted name, not display name flag. + * src/Sort.py (by_sorted_name): Add method. + * src/WebPage (dump_index): Proper sorting, for both last name + sections and the names within each section. + 2005-05-25 Richard Taylor * src/plugins/ScratchPad.py: disabled search because it does not do what the user expects. diff --git a/gramps2/src/NameDisplay.py b/gramps2/src/NameDisplay.py index d0b3e0563..b88da928c 100644 --- a/gramps2/src/NameDisplay.py +++ b/gramps2/src/NameDisplay.py @@ -83,7 +83,7 @@ class NameDisplay: @rtype: str """ name = person.get_primary_name() - if name.display_as == RelLib.Name.FNLN: + if name.get_sort_as() == RelLib.Name.FNLN: return self._fnln(name) else: return self._lnfn(name) diff --git a/gramps2/src/Sort.py b/gramps2/src/Sort.py index fc935c98b..9d692b168 100644 --- a/gramps2/src/Sort.py +++ b/gramps2/src/Sort.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2004 Donald N. Allingham +# Copyright (C) 2000-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 @@ -27,18 +27,24 @@ and directly use class members. For this reason, care needs to be taken to make sure these remain in sync with the rest of the design. """ +#------------------------------------------------------------------------- +# +# Standard python modules +# +#------------------------------------------------------------------------- import locale #------------------------------------------------------------------------- # -# Imported Modules +# GRAMPS Modules # #------------------------------------------------------------------------- import Date +from NameDisplay import displayer as _nd #------------------------------------------------------------------------- # -# Functions +# Constants # #------------------------------------------------------------------------- @@ -52,7 +58,6 @@ class Sort: def __init__(self,database): self.database = database - def by_last_name(self,first_id,second_id): """Sort routine for comparing two last names. If last names are equal, uses the given name and suffix""" @@ -75,6 +80,19 @@ class Sort: else: return locale.strcoll(fsn, ssn) + def by_sorted_name(self,first_id,second_id): + """ + Sort routine for comparing two displayed names. + """ + + first = self.database.get_person_from_handle(first_id) + second = self.database.get_person_from_handle(second_id) + + name1 = _nd.sorted(first) + name2 = _nd.sorted(second) + + return locale.strcoll(name1,name2) + def by_birthdate(self,first_id,second_id): """Sort routine for comparing two people by birth dates. If the birth dates are equal, sorts by name""" diff --git a/gramps2/src/plugins/WebPage.py b/gramps2/src/plugins/WebPage.py index f7dc8632c..25f89cb01 100644 --- a/gramps2/src/plugins/WebPage.py +++ b/gramps2/src/plugins/WebPage.py @@ -29,6 +29,7 @@ #------------------------------------------------------------------------ import os import shutil +import locale from gettext import gettext as _ #------------------------------------------------------------------------ @@ -57,6 +58,7 @@ import Errors import Utils from QuestionDialog import ErrorDialog import ReportOptions +from NameDisplay import displayer as _nd #------------------------------------------------------------------------ # @@ -943,8 +945,6 @@ class WebReport(Report.Report): doc.write_text(_("Family Tree Index")) doc.end_paragraph() - person_handle_list.sort(self.sort.by_last_name) - a = {} for person_handle in person_handle_list: person = self.database.get_person_from_handle(person_handle) @@ -956,7 +956,7 @@ class WebReport(Report.Report): section_number = 1 link_keys = a.keys() - link_keys.sort() + link_keys.sort(locale.strcoll) for n in link_keys: a[n] = section_number section_number = section_number + 1 @@ -980,6 +980,7 @@ class WebReport(Report.Report): p_id_list = [ p_id for p_id in person_handle_list if \ (self.database.get_person_from_handle(p_id).get_primary_name().get_surname() \ and (self.database.get_person_from_handle(p_id).get_primary_name().get_surname()[0] == n) ) ] + p_id_list.sort(self.sort.by_sorted_name) doc = HtmlLinkDoc(self.selected_style,None,template,None) doc.set_extension(self.ext) doc.set_title(_("Section %s") % n) @@ -998,7 +999,7 @@ class WebReport(Report.Report): for person_handle in p_id_list: the_person = self.database.get_person_from_handle(person_handle) - name = the_person.get_primary_name().get_name() + name = _nd.sorted(the_person) if self.birth_dates: birth_handle = self.database.get_person_from_handle(person_handle).get_birth_handle() @@ -1040,6 +1041,7 @@ class WebReport(Report.Report): p_id_list = [ p_id for p_id in person_handle_list if \ (self.database.get_person_from_handle(p_id).get_primary_name().get_surname() \ and (self.database.get_person_from_handle(p_id).get_primary_name().get_surname()[0] == n) ) ] + p_id_list.sort(self.sort.by_sorted_name) doc.start_paragraph('IndexLabel') if self.include_alpha_links: doc.write_linktarget("%03d" % a[n]) @@ -1049,7 +1051,7 @@ class WebReport(Report.Report): for person_handle in p_id_list: the_person = self.database.get_person_from_handle(person_handle) - name = the_person.get_primary_name().get_name() + name = _nd.sorted(the_person) if self.birth_dates: birth_handle = self.database.get_person_from_handle(person_handle).get_birth_handle()