* 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
This commit is contained in:
Alex Roitman 2005-05-25 18:51:10 +00:00
parent b444385631
commit 27e22a5b21
4 changed files with 35 additions and 10 deletions

View File

@ -1,6 +1,11 @@
2005-05-25 Alex Roitman <shura@gramps-project.org>
* 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 <rjt-gramps@thegrindstone.me.uk>
* src/plugins/ScratchPad.py: disabled search because it does not do
what the user expects.

View File

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

View File

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

View File

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