Redraw optimizations
svn: r1566
This commit is contained in:
parent
1cf00e2a8a
commit
7488907aa2
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000 Donald N. Allingham
|
# Copyright (C) 2000-2003 Donald N. Allingham
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -107,7 +107,7 @@ class ChooseParents:
|
|||||||
self.mother_list = self.glade.get_widget("mother_list")
|
self.mother_list = self.glade.get_widget("mother_list")
|
||||||
self.flabel = self.glade.get_widget("flabel")
|
self.flabel = self.glade.get_widget("flabel")
|
||||||
self.mlabel = self.glade.get_widget("mlabel")
|
self.mlabel = self.glade.get_widget("mlabel")
|
||||||
self.showallf = self.glade.get_widget('showall')
|
self.showallf = self.glade.get_widget('showallf')
|
||||||
self.showallm = self.glade.get_widget('showallm')
|
self.showallm = self.glade.get_widget('showallm')
|
||||||
|
|
||||||
self.fcombo.set_popdown_strings(const.familyRelations)
|
self.fcombo.set_popdown_strings(const.familyRelations)
|
||||||
@ -133,92 +133,181 @@ class ChooseParents:
|
|||||||
self.type = "Married"
|
self.type = "Married"
|
||||||
|
|
||||||
self.prel.set_text(_(self.type))
|
self.prel.set_text(_(self.type))
|
||||||
self.redraw()
|
self.redrawf()
|
||||||
|
self.redrawm()
|
||||||
|
|
||||||
self.glade.signal_autoconnect({
|
self.glade.signal_autoconnect({
|
||||||
"on_save_parents_clicked" : self.save_parents_clicked,
|
"on_save_parents_clicked" : self.save_parents_clicked,
|
||||||
"on_add_parent_clicked" : self.add_parent_clicked,
|
"on_add_parent_clicked" : self.add_parent_clicked,
|
||||||
"on_prel_changed" : self.parent_relation_changed,
|
"on_prel_changed" : self.parent_relation_changed,
|
||||||
"on_showall_toggled" : self.showall_toggled,
|
"on_showallf_toggled" : self.showallf_toggled,
|
||||||
|
"on_showallm_toggled" : self.showallm_toggled,
|
||||||
"destroy_passed_object" : Utils.destroy_passed_object
|
"destroy_passed_object" : Utils.destroy_passed_object
|
||||||
})
|
})
|
||||||
|
|
||||||
def redraw(self):
|
def redrawf(self):
|
||||||
"""Redraws the potential father and mother lists"""
|
"""Redraws the potential father list"""
|
||||||
|
|
||||||
self.fmodel.clear()
|
self.fmodel.clear()
|
||||||
self.mmodel.clear()
|
|
||||||
|
|
||||||
self.fmodel.new_model()
|
self.fmodel.new_model()
|
||||||
self.mmodel.new_model()
|
|
||||||
|
|
||||||
pkey = self.person.getId()
|
pkey = self.person.getId()
|
||||||
gender = self.person.getGender()
|
|
||||||
if self.father:
|
if self.father:
|
||||||
fid = self.father.getId()
|
fid = self.father.getId()
|
||||||
else:
|
else:
|
||||||
fid = None
|
fid = None
|
||||||
|
|
||||||
|
bday = self.person.getBirth().getDateObj()
|
||||||
|
dday = self.person.getDeath().getDateObj()
|
||||||
|
|
||||||
|
person_list = []
|
||||||
|
for key in self.db.getPersonKeys():
|
||||||
|
if pkey == key:
|
||||||
|
continue
|
||||||
|
|
||||||
|
person = self.db.getPerson(key)
|
||||||
|
if person.getGender() != person.male:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not self.showallf.get_active():
|
||||||
|
|
||||||
|
pdday = person.getDeath().getDateObj()
|
||||||
|
pbday = person.getBirth().getDateObj()
|
||||||
|
|
||||||
|
if bday.getYearValid():
|
||||||
|
if pbday.getYearValid():
|
||||||
|
# reject if parents birthdate + 10 > child birthdate
|
||||||
|
if pbday.getLowYear()+10 > bday.getHighYear():
|
||||||
|
continue
|
||||||
|
|
||||||
|
# reject if parents birthdate + 90 < child birthdate
|
||||||
|
if pbday.getHighYear()+90 < bday.getLowYear():
|
||||||
|
continue
|
||||||
|
|
||||||
|
if pdday.getYearValid():
|
||||||
|
# reject if parents birthdate + 10 > child deathdate
|
||||||
|
if pbday.getLowYear()+10 > dday.getHighYear():
|
||||||
|
continue
|
||||||
|
|
||||||
|
if dday.getYearValid():
|
||||||
|
if pbday.getYearValid():
|
||||||
|
# reject if parents deathday + 3 < childs birth date
|
||||||
|
if pdday.getHighYear()+3 < bday.getLowYear():
|
||||||
|
continue
|
||||||
|
|
||||||
|
if pdday.getYearValid():
|
||||||
|
# reject if parents deathday + 150 < childs death date
|
||||||
|
if pdday.getHighYear() + 150 < dday.getLowYear():
|
||||||
|
continue
|
||||||
|
|
||||||
|
person_list.append(person.getId())
|
||||||
|
|
||||||
|
for idval in person_list:
|
||||||
|
d = self.db.getPersonDisplay(idval)
|
||||||
|
info = [d[0],d[1],d[3],d[5],d[6]]
|
||||||
|
if self.type == "Partners":
|
||||||
|
self.fmodel.add(info,None,fid==d[1])
|
||||||
|
elif d[2] == const.male:
|
||||||
|
self.fmodel.add(info,None,fid==d[1])
|
||||||
|
|
||||||
|
if self.type == "Partners":
|
||||||
|
self.flabel.set_label("<b>%s</b>" % _("Parent"))
|
||||||
|
else:
|
||||||
|
self.flabel.set_label("<b>%s</b>" % _("Father"))
|
||||||
|
|
||||||
|
self.fmodel.connect_model()
|
||||||
|
|
||||||
|
|
||||||
|
def redrawm(self):
|
||||||
|
"""Redraws the potential mother list"""
|
||||||
|
|
||||||
|
self.mmodel.clear()
|
||||||
|
self.mmodel.new_model()
|
||||||
|
|
||||||
|
pkey = self.person.getId()
|
||||||
|
|
||||||
if self.mother:
|
if self.mother:
|
||||||
mid = self.mother.getId()
|
mid = self.mother.getId()
|
||||||
else:
|
else:
|
||||||
mid = None
|
mid = None
|
||||||
|
|
||||||
comparef = self.date.isValid() and not self.showallf.get_active()
|
bday = self.person.getBirth().getDateObj()
|
||||||
comparem = self.date.isValid() and not self.showallm.get_active()
|
dday = self.person.getDeath().getDateObj()
|
||||||
|
|
||||||
|
person_list = []
|
||||||
for key in self.db.getPersonKeys():
|
for key in self.db.getPersonKeys():
|
||||||
if pkey == key:
|
if pkey == key:
|
||||||
continue
|
continue
|
||||||
if gender == const.unknown:
|
|
||||||
|
person = self.db.getPerson(key)
|
||||||
|
if person.getGender() != person.female:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
p = self.db.getPerson(key)
|
person = self.db.getPerson(key)
|
||||||
|
|
||||||
d = self.db.getPersonDisplay(key)
|
if not self.showallm.get_active():
|
||||||
|
|
||||||
|
pdday = person.getDeath().getDateObj()
|
||||||
|
pbday = person.getBirth().getDateObj()
|
||||||
|
|
||||||
|
if bday.getYearValid():
|
||||||
|
if pbday.getYearValid():
|
||||||
|
# reject if parents birthdate + 10 > child birthdate
|
||||||
|
if pbday.getLowYear()+10 > bday.getHighYear():
|
||||||
|
continue
|
||||||
|
|
||||||
|
# reject if parents birthdate + 90 < child birthdate
|
||||||
|
if pbday.getHighYear()+90 < bday.getLowYear():
|
||||||
|
continue
|
||||||
|
|
||||||
|
if pdday.getYearValid():
|
||||||
|
# reject if parents birthdate + 10 > child deathdate
|
||||||
|
if pbday.getLowYear()+10 > dday.getHighYear():
|
||||||
|
continue
|
||||||
|
|
||||||
|
if dday.getYearValid():
|
||||||
|
if pbday.getYearValid():
|
||||||
|
# reject if parents deathday + 3 < childs birth date
|
||||||
|
if pdday.getHighYear()+3 < bday.getLowYear():
|
||||||
|
continue
|
||||||
|
|
||||||
|
if pdday.getYearValid():
|
||||||
|
# reject if parents deathday + 150 < childs death date
|
||||||
|
if pdday.getHighYear() + 150 < dday.getLowYear():
|
||||||
|
continue
|
||||||
|
|
||||||
|
person_list.append(person.getId())
|
||||||
|
|
||||||
|
for idval in person_list:
|
||||||
|
d = self.db.getPersonDisplay(idval)
|
||||||
info = [d[0],d[1],d[3],d[5],d[6]]
|
info = [d[0],d[1],d[3],d[5],d[6]]
|
||||||
if self.type == "Partners":
|
if self.type == "Partners":
|
||||||
if not(comparef and self.not_likely(p)):
|
self.mmodel.add(info,None,mid==d[1])
|
||||||
self.fmodel.add(info,None,fid==d[1])
|
elif d[2] == const.female:
|
||||||
if not(comparem and self.not_likely(p)):
|
|
||||||
self.mmodel.add(info,None,mid==d[1])
|
|
||||||
elif d[2] == const.male:
|
|
||||||
if comparef and self.not_likely(p):
|
|
||||||
continue
|
|
||||||
self.fmodel.add(info,None,fid==d[1])
|
|
||||||
else:
|
|
||||||
if comparem and self.not_likely(p):
|
|
||||||
continue
|
|
||||||
self.mmodel.add(info,None,mid==d[1])
|
self.mmodel.add(info,None,mid==d[1])
|
||||||
|
|
||||||
if self.type == "Partners":
|
if self.type == "Partners":
|
||||||
self.mlabel.set_label("<b>%s</b>" % _("Parent"))
|
self.mlabel.set_label("<b>%s</b>" % _("Parent"))
|
||||||
self.flabel.set_label("<b>%s</b>" % _("Parent"))
|
|
||||||
else:
|
else:
|
||||||
self.mlabel.set_label("<b>%s</b>" % _("Mother"))
|
self.mlabel.set_label("<b>%s</b>" % _("Mother"))
|
||||||
self.flabel.set_label("<b>%s</b>" % _("Father"))
|
|
||||||
|
|
||||||
self.fmodel.connect_model()
|
|
||||||
self.mmodel.connect_model()
|
self.mmodel.connect_model()
|
||||||
|
|
||||||
def not_likely(self,person):
|
|
||||||
"""
|
|
||||||
Rough attempt to eliminate a few non-realistic relationships. If the person
|
|
||||||
was born after the primary person, he or she can't be a parent.
|
|
||||||
"""
|
|
||||||
bdate = person.getBirth().getDateObj()
|
|
||||||
if bdate.isValid() and Date.compare_dates(self.date,bdate) < 1:
|
|
||||||
return 1
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def parent_relation_changed(self,obj):
|
def parent_relation_changed(self,obj):
|
||||||
"""Called everytime the parent relationship information is changegd"""
|
"""Called everytime the parent relationship information is changegd"""
|
||||||
self.old_type = self.type
|
self.old_type = self.type
|
||||||
self.type = const.save_frel(obj.get_text())
|
self.type = const.save_frel(obj.get_text())
|
||||||
if self.old_type == "Partners" or self.type == "Partners":
|
if self.old_type == "Partners" or self.type == "Partners":
|
||||||
self.redraw()
|
self.redrawf()
|
||||||
|
self.redrawm()
|
||||||
|
|
||||||
def showall_toggled(self,obj):
|
def showallf_toggled(self,obj):
|
||||||
self.redraw()
|
self.redrawf()
|
||||||
|
|
||||||
|
def showallm_toggled(self,obj):
|
||||||
|
self.redrawm()
|
||||||
|
|
||||||
def find_family(self,father,mother):
|
def find_family(self,father,mother):
|
||||||
"""
|
"""
|
||||||
|
@ -3264,7 +3264,7 @@
|
|||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkCheckButton" id="showall">
|
<widget class="GtkCheckButton" id="showallf">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">_Show all</property>
|
<property name="label" translatable="yes">_Show all</property>
|
||||||
@ -3276,7 +3276,7 @@
|
|||||||
<accessibility>
|
<accessibility>
|
||||||
<atkproperty name="AtkObject::accessible_name" translatable="yes">Show all</atkproperty>
|
<atkproperty name="AtkObject::accessible_name" translatable="yes">Show all</atkproperty>
|
||||||
</accessibility>
|
</accessibility>
|
||||||
<signal name="toggled" handler="on_showall_toggled" last_modification_time="Mon, 20 Jan 2003 02:45:10 GMT"/>
|
<signal name="toggled" handler="on_showallf_toggled" last_modification_time="Mon, 20 Jan 2003 02:45:10 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="padding">0</property>
|
<property name="padding">0</property>
|
||||||
@ -3426,7 +3426,7 @@
|
|||||||
<property name="active">False</property>
|
<property name="active">False</property>
|
||||||
<property name="inconsistent">False</property>
|
<property name="inconsistent">False</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
<signal name="toggled" handler="on_showall_toggled" last_modification_time="Mon, 20 Jan 2003 02:45:10 GMT"/>
|
<signal name="toggled" handler="on_showallm_toggled" last_modification_time="Mon, 20 Jan 2003 02:45:10 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="padding">0</property>
|
<property name="padding">0</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user