use SelectPerson for father instead of Object Selector

svn: r6171
This commit is contained in:
Don Allingham 2006-03-18 05:47:39 +00:00
parent dd28ea78ab
commit 94686d5e25
4 changed files with 49 additions and 26 deletions

View File

@ -1,4 +1,8 @@
2006-03-17 Don Allingham <don@gramps-project.org>
* src/Editors/_EditFamily.py: convert father to use SelectPerson instead
of ObjectSelector
* src/PeopleModel.py: add skip capability
* src/SelectPerson.py: call person model correctly
* src/DataViews/_FamilyView.py: use new Dbutils functions
* src/DataViews/_FamilyList.py: use new Dbutils functions
* src/GrampsDb/_DbUtils.py: new routines to remove families and

View File

@ -68,12 +68,13 @@ import Spell
import GrampsDisplay
import RelLib
import AutoComp
from _EditPrimary import EditPrimary
from PluginUtils import ReportUtils
from DdTargets import DdTargets
from DisplayTabs import *
from GrampsWidgets import *
from ObjectSelector import PersonSelector,PersonFilterSpec
class ChildEmbedList(EmbeddedList):
@ -449,31 +450,51 @@ class EditFamily(EditPrimary):
selector_window.close()
def father_clicked(self,obj):
def father_clicked(self, obj):
handle = self.obj.get_father_handle()
if handle:
self.obj.set_father_handle(None)
self.update_father(None)
else:
filter_spec = PersonFilterSpec()
filter_spec.set_gender(RelLib.Person.MALE)
from SelectPerson import SelectPerson
import GenericFilter
child_birth_years = []
for person_handle in self.obj.get_child_handle_list():
person = self.db.get_person_from_handle(person_handle)
event_ref = person.get_birth_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
child_birth_years.append(event.get_date_object().get_year())
data_filter = GenericFilter.GenericFilter()
data_filter.add_rule(GenericFilter.IsMale([]))
sel = SelectPerson(self.dbstate.db, "Select Father",
filter=data_filter,
skip=self.obj.get_child_handle_list())
person = sel.run()
if person:
self.obj.set_father_handle(person.handle)
self.update_father(person.handle)
# def father_clicked(self,obj):
# handle = self.obj.get_father_handle()
# if handle:
# self.obj.set_father_handle(None)
# self.update_father(None)
# else:
# filter_spec = PersonFilterSpec()
# filter_spec.set_gender(RelLib.Person.MALE)
# child_birth_years = []
# for person_handle in self.obj.get_child_handle_list():
# person = self.db.get_person_from_handle(person_handle)
# event_ref = person.get_birth_ref()
# if event_ref and event_ref.ref:
# event = self.db.get_event_from_handle(event_ref.ref)
# child_birth_years.append(event.get_date_object().get_year())
if len(child_birth_years) > 0:
filter_spec.set_birth_year(min(child_birth_years))
filter_spec.set_birth_criteria(PersonFilterSpec.BEFORE)
# if len(child_birth_years) > 0:
# filter_spec.set_birth_year(min(child_birth_years))
# filter_spec.set_birth_criteria(PersonFilterSpec.BEFORE)
selector = PersonSelector(self.dbstate,self.uistate,
self.track,filter_spec=filter_spec)
selector.connect('add-object',self.on_change_father)
# selector = PersonSelector(self.dbstate,self.uistate,
# self.track,filter_spec=filter_spec)
# selector.connect('add-object',self.on_change_father)
def edit_person(self,obj,event,handle):
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:

View File

@ -114,7 +114,7 @@ else:
#-------------------------------------------------------------------------
class PeopleModel(gtk.GenericTreeModel):
def __init__(self,db,data_filter=None,invert_result=False):
def __init__(self,db,data_filter=None,invert_result=False,skip=[]):
gtk.GenericTreeModel.__init__(self)
self.db = db
@ -125,7 +125,7 @@ class PeopleModel(gtk.GenericTreeModel):
self.tooltip_column = 12
self.prev_handle = None
self.prev_data = None
self.rebuild_data(data_filter)
self.rebuild_data(data_filter,skip)
def rebuild_data(self,data_filter=None,skip=[]):
self.calculate_data(data_filter,skip)

View File

@ -26,7 +26,6 @@
#
#-------------------------------------------------------------------------
from TransUtils import sgettext as _
import gc
#-------------------------------------------------------------------------
#
@ -53,7 +52,7 @@ import PeopleModel
#-------------------------------------------------------------------------
class SelectPerson:
def __init__(self,db,title,parent_window=None):
def __init__(self, db, title, filter=None, skip=[], parent_window=None):
self.renderer = gtk.CellRendererText()
self.db = db
@ -62,11 +61,12 @@ class SelectPerson:
title_label = self.glade.get_widget('title')
self.plist = self.glade.get_widget('plist')
self.notebook = self.glade.get_widget('notebook')
self.use_filter = 0
Utils.set_titles(self.top,title_label,title)
self.model = PeopleModel.PeopleModel(self.db)
self.model = PeopleModel.PeopleModel(self.db,
data_filter=filter,
skip=skip)
self.add_columns(self.plist)
self.plist.set_model(self.model)
@ -110,9 +110,7 @@ class SelectPerson:
else:
return_value = None
self.top.destroy()
gc.collect()
return return_value
else:
self.top.destroy()
gc.collect()
return None