Faster sorting and improved web page generation
svn: r228
This commit is contained in:
parent
f3512e24fd
commit
96cd065266
@ -19,7 +19,6 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard python modules
|
||||
@ -107,7 +106,7 @@ family_window = None
|
||||
queryTop = None
|
||||
prefsTop = None
|
||||
pv = {}
|
||||
sortFunc = sort.by_last_name2
|
||||
sortFunc = sort.fast_name_sort
|
||||
sbar_active = 1
|
||||
DataFilter = Filter.create("")
|
||||
|
||||
@ -1194,31 +1193,31 @@ def on_person_list_click_column(obj,column):
|
||||
dateArrow.hide()
|
||||
deathArrow.hide()
|
||||
nameArrow.show()
|
||||
if sortFunc != sort.by_last_name2:
|
||||
sortFunc = sort.by_last_name2
|
||||
if sortFunc != sort.fast_name_sort:
|
||||
sortFunc = sort.fast_name_sort
|
||||
nameArrow.set(GTK.ARROW_DOWN,2)
|
||||
else:
|
||||
sortFunc = sort.by_last_name_backwards2
|
||||
sortFunc = sort.reverse_name_sort
|
||||
nameArrow.set(GTK.ARROW_UP,2)
|
||||
elif column == 2:
|
||||
nameArrow.hide()
|
||||
deathArrow.hide()
|
||||
dateArrow.show()
|
||||
if sortFunc != sort.by_birthdate2:
|
||||
sortFunc = sort.by_birthdate2
|
||||
if sortFunc != sort.fast_birth_sort:
|
||||
sortFunc = sort.fast_birth_sort
|
||||
dateArrow.set(GTK.ARROW_DOWN,2)
|
||||
else:
|
||||
sortFunc = sort.by_birthdate_backwards2
|
||||
sortFunc = reverse_birth_sort
|
||||
dateArrow.set(GTK.ARROW_UP,2)
|
||||
elif column == 3:
|
||||
nameArrow.hide()
|
||||
deathArrow.show()
|
||||
dateArrow.hide()
|
||||
if sortFunc != sort.by_deathdate2:
|
||||
sortFunc = sort.by_deathdate2
|
||||
if sortFunc != sort.fast_death_sort:
|
||||
sortFunc = sort.fast_death_sort
|
||||
deathArrow.set(GTK.ARROW_DOWN,2)
|
||||
else:
|
||||
sortFunc = sort.by_deathdate_backwards2
|
||||
sortFunc = sort.reverse_death_sort
|
||||
deathArrow.set(GTK.ARROW_UP,2)
|
||||
apply_filter()
|
||||
|
||||
@ -2008,7 +2007,7 @@ def apply_filter():
|
||||
if Config.hide_altnames == 0:
|
||||
names = names + altnames
|
||||
|
||||
names.sort(sortFunc)
|
||||
names = sortFunc(names)
|
||||
|
||||
person_list.freeze()
|
||||
person_list.clear()
|
||||
|
@ -98,17 +98,14 @@ class IndividualPage:
|
||||
self.photos = (photos == 2) or (photos == 1 and not self.alive)
|
||||
self.dir = dir_name
|
||||
self.link = link
|
||||
self.slist = []
|
||||
self.scnt = 1
|
||||
|
||||
tbl = TableStyle()
|
||||
tbl.set_width(100)
|
||||
tbl.set_column_widths([15,85])
|
||||
self.doc.add_table_style("IndTable",tbl)
|
||||
|
||||
tbl = TableStyle()
|
||||
tbl.set_width(100)
|
||||
tbl.set_column_widths([15,15,70])
|
||||
self.doc.add_table_style("FamTable",tbl)
|
||||
|
||||
cell = TableCellStyle()
|
||||
self.doc.add_cell_style("NormalCell",cell)
|
||||
|
||||
@ -120,19 +117,25 @@ class IndividualPage:
|
||||
#
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def write_normal_row(self,list):
|
||||
def write_normal_row(self,label,data,sref):
|
||||
self.doc.start_row()
|
||||
first = 1
|
||||
for i in list:
|
||||
self.doc.start_cell("NormalCell")
|
||||
if first == 1:
|
||||
self.doc.start_paragraph("Label")
|
||||
else:
|
||||
self.doc.start_paragraph("Data")
|
||||
first = 0
|
||||
self.doc.write_text(i)
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.start_cell("NormalCell")
|
||||
self.doc.start_paragraph("Label")
|
||||
self.doc.write_text(label)
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
|
||||
self.doc.start_cell("NormalCell")
|
||||
self.doc.start_paragraph("Data")
|
||||
self.doc.write_text(data)
|
||||
if sref != None and sref.getBase() != None :
|
||||
self.doc.start_link("#s%d" % self.scnt)
|
||||
self.doc.write_text("<SUP>%d</SUP>" % self.scnt)
|
||||
self.doc.end_link()
|
||||
self.scnt = self.scnt + 1
|
||||
self.slist.append(sref)
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
@ -145,18 +148,13 @@ class IndividualPage:
|
||||
|
||||
self.doc.start_cell("NormalCell")
|
||||
self.doc.start_paragraph("Label")
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
|
||||
self.doc.start_cell("NormalCell")
|
||||
self.doc.start_paragraph("Label")
|
||||
self.doc.write_text(list[1])
|
||||
self.doc.write_text(list[0])
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
|
||||
self.doc.start_cell("NormalCell")
|
||||
self.doc.start_paragraph("Data")
|
||||
self.doc.write_text(list[2])
|
||||
self.doc.write_text(list[1])
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
|
||||
@ -187,6 +185,30 @@ class IndividualPage:
|
||||
self.doc.end_paragraph()
|
||||
self.doc.end_cell()
|
||||
self.doc.end_row()
|
||||
|
||||
def write_sources(self):
|
||||
self.doc.start_paragraph("SourcesTitle")
|
||||
self.doc.write_text(_("Sources"))
|
||||
self.doc.end_paragraph()
|
||||
|
||||
index = 0
|
||||
for sref in self.slist:
|
||||
self.doc.start_paragraph("Data")
|
||||
self.doc.write_text('<A NAME="#s%d">%d. ' % (index,index))
|
||||
index = index + 1
|
||||
self.doc.write_text("%s. " % sref.getBase().getTitle())
|
||||
author = sref.getBase().getAuthor()
|
||||
if author != "":
|
||||
self.doc.write_text("%s. " % author)
|
||||
pubinfo = sref.getBase().getPubInfo()
|
||||
if pubinfo != "":
|
||||
self.doc.write_text("%s. " % pubinfo)
|
||||
if sref.getDate() != "":
|
||||
self.doc.write_text("%s. " % sref.getDate())
|
||||
if sref.getPage() != "":
|
||||
self.doc.write_text("%s. " % sref.getPage())
|
||||
self.doc.end_paragraph()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -197,7 +219,8 @@ class IndividualPage:
|
||||
self.doc.open("%s%s%s" % (self.dir,os.sep,filebase))
|
||||
|
||||
photo_list = self.person.getPhotoList()
|
||||
name = self.person.getPrimaryName().getRegularName()
|
||||
name_obj = self.person.getPrimaryName()
|
||||
name = name_obj.getRegularName()
|
||||
|
||||
self.doc.start_paragraph("Title")
|
||||
self.doc.write_text(_("Summary of %s") % name)
|
||||
@ -213,11 +236,11 @@ class IndividualPage:
|
||||
self.doc.end_paragraph()
|
||||
|
||||
self.doc.start_table("one","IndTable")
|
||||
self.write_normal_row([ "%s:" % _("Name"), name])
|
||||
self.write_normal_row("%s:" % _("Name"), name, name_obj.getSourceRef())
|
||||
if self.person.getGender() == Person.male:
|
||||
self.write_normal_row([ "%s:" % _("Gender"), _("Male")])
|
||||
self.write_normal_row("%s:" % _("Gender"), _("Male"),None)
|
||||
else:
|
||||
self.write_normal_row([ "%s:" % _("Gender"), _("Female")])
|
||||
self.write_normal_row("%s:" % _("Gender"), _("Female"),None)
|
||||
|
||||
family = self.person.getMainFamily()
|
||||
if family:
|
||||
@ -234,6 +257,8 @@ class IndividualPage:
|
||||
self.write_facts()
|
||||
self.write_notes()
|
||||
self.write_families()
|
||||
if self.scnt > 1:
|
||||
self.write_sources()
|
||||
|
||||
if self.link:
|
||||
self.doc.start_paragraph("Data")
|
||||
@ -280,9 +305,9 @@ class IndividualPage:
|
||||
if place == "":
|
||||
val = "%s. %s" % (date,description)
|
||||
else:
|
||||
val = _("%s in %s. %s") % (date,place,description)
|
||||
val = "%s, %s. %s" % (date,place,description)
|
||||
|
||||
self.write_normal_row([name, val])
|
||||
self.write_normal_row(name, val, event.getSourceRef())
|
||||
|
||||
self.doc.end_table()
|
||||
|
||||
@ -328,7 +353,7 @@ class IndividualPage:
|
||||
else:
|
||||
val = "%s, %s. %s" % (date,place,description)
|
||||
|
||||
self.write_marriage_row(["",name, val])
|
||||
self.write_marriage_row([name, val])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
@ -340,7 +365,7 @@ class IndividualPage:
|
||||
self.doc.write_text(_("Marriages/Children"))
|
||||
self.doc.end_paragraph()
|
||||
|
||||
self.doc.start_table("three","FamTable")
|
||||
self.doc.start_table("three","IndTable")
|
||||
|
||||
for family in self.person.getFamilyList():
|
||||
if self.person == family.getFather():
|
||||
@ -348,7 +373,7 @@ class IndividualPage:
|
||||
else:
|
||||
spouse = family.getFather()
|
||||
self.doc.start_row()
|
||||
self.doc.start_cell("NormalCell",3)
|
||||
self.doc.start_cell("NormalCell",2)
|
||||
self.doc.start_paragraph("Spouse")
|
||||
if spouse:
|
||||
self.doc.start_link("i%s.html" % str(spouse.getId()))
|
||||
@ -553,6 +578,12 @@ def report(database,person):
|
||||
p.set(font=font,bborder=1)
|
||||
styles.add_style("NotesTitle",p)
|
||||
|
||||
font = FontStyle()
|
||||
font.set(bold=1,face=FONT_SANS_SERIF,size=12,italic=1)
|
||||
p = ParagraphStyle()
|
||||
p.set(font=font,bborder=1)
|
||||
styles.add_style("SourcesTitle",p)
|
||||
|
||||
font = FontStyle()
|
||||
font.set(bold=1,face=FONT_SANS_SERIF,size=12,italic=1)
|
||||
p = ParagraphStyle()
|
||||
|
@ -75,3 +75,11 @@ def runTool(database,active_person,callback):
|
||||
#-------------------------------------------------------------------------
|
||||
def get_description():
|
||||
return _("Generates SoundEx codes for names")
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def get_name():
|
||||
return _("Utilities/Generate SoundEx codes")
|
||||
|
1765
gramps/src/po/sv.po
1765
gramps/src/po/sv.po
File diff suppressed because it is too large
Load Diff
@ -26,18 +26,113 @@ from Date import *
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def by_last_name2(first, second) :
|
||||
def build_sort_name(person):
|
||||
n = person[0]
|
||||
nm = "%-25s%-30s%s" % (n.Surname,n.FirstName,n.Suffix)
|
||||
return (nm,person)
|
||||
|
||||
name1 = first[0]
|
||||
name2 = second[0]
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def build_sort_birth(person):
|
||||
n = person[1].birth.date.start
|
||||
|
||||
if name1.getSurname() == name2.getSurname() :
|
||||
if name1.getFirstName() == name2.getFirstName() :
|
||||
return cmp(name1.getSuffix(), name2.getSuffix())
|
||||
else :
|
||||
return cmp(name1.getFirstName(), name2.getFirstName())
|
||||
else :
|
||||
return cmp(name1.getSurname(), name2.getSurname())
|
||||
y = n.year
|
||||
if y == -1:
|
||||
y = 9999
|
||||
m = n.month
|
||||
if m == -1:
|
||||
m = 99
|
||||
d = n.day
|
||||
if d == -1:
|
||||
d = 99
|
||||
nm = "%04d%2d%2d" % (y,m,d)
|
||||
return (nm,person)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def build_sort_death(person):
|
||||
n = person[1].death.date.start
|
||||
|
||||
y = n.year
|
||||
if y == -1:
|
||||
y = 9999
|
||||
m = n.month
|
||||
if m == -1:
|
||||
m = 99
|
||||
d = n.day
|
||||
if d == -1:
|
||||
d = 99
|
||||
nm = "%04d%2d%2d" % (y,m,d)
|
||||
return (nm,person)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def fast_name_sort(list):
|
||||
nlist = map(build_sort_name,list)
|
||||
nlist.sort()
|
||||
return map(lambda(key,x): x, nlist)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def reverse_name_sort(list):
|
||||
nlist = map(build_sort_name,list)
|
||||
nlist.sort()
|
||||
nlist.reverse()
|
||||
return map(lambda(key,x): x, nlist)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def fast_birth_sort(list):
|
||||
nlist = map(build_sort_birth,list)
|
||||
nlist.sort()
|
||||
return map(lambda(key,x): x, nlist)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def reverse_birth_sort(list):
|
||||
nlist = map(build_sort_birth,list)
|
||||
nlist.sort()
|
||||
nlist.reverse()
|
||||
return map(lambda(key,x): x, nlist)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def fast_death_sort(list):
|
||||
nlist = map(build_sort_death,list)
|
||||
nlist.sort()
|
||||
return map(lambda(key,x): x, nlist)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def reverse_death_sort(list):
|
||||
nlist = map(build_sort_death,list)
|
||||
nlist.sort()
|
||||
nlist.reverse()
|
||||
return map(lambda(key,x): x, nlist)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -65,14 +160,6 @@ def by_last_name(first, second) :
|
||||
def by_last_name_backwards(first, second) :
|
||||
return by_last_name(second,first)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def by_last_name_backwards2(first, second) :
|
||||
return by_last_name2(second,first)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -87,78 +174,4 @@ def by_birthdate(first, second) :
|
||||
return by_last_name(first,second)
|
||||
return val
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def by_deathdate(first, second) :
|
||||
|
||||
date1 = first.getDeath().getDateObj()
|
||||
date2 = second.getDeath().getDateObj()
|
||||
val = compare_dates(date1,date2)
|
||||
if val == 0:
|
||||
return by_last_name(first,second)
|
||||
return val
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def by_birthdate_backwards(first, second) :
|
||||
return by_birthdate(second,first)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def by_deathdate_backwards(first, second) :
|
||||
return by_deathdate(second,first)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def by_birthdate2(first, second) :
|
||||
|
||||
date1 = first[1].getBirth().getDateObj()
|
||||
date2 = second[1].getBirth().getDateObj()
|
||||
val = compare_dates(date1,date2)
|
||||
if val == 0:
|
||||
return by_last_name2(first,second)
|
||||
return val
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def by_deathdate2(first, second) :
|
||||
|
||||
date1 = first[1].getDeath().getDateObj()
|
||||
date2 = second[1].getDeath().getDateObj()
|
||||
val = compare_dates(date1,date2)
|
||||
if val == 0:
|
||||
return by_last_name2(first,second)
|
||||
return val
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def by_birthdate_backwards2(first, second) :
|
||||
return by_birthdate2(second,first)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def by_deathdate_backwards2(first, second) :
|
||||
return by_deathdate2(second,first)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user