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> 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/_FamilyView.py: use new Dbutils functions
* src/DataViews/_FamilyList.py: use new Dbutils functions * src/DataViews/_FamilyList.py: use new Dbutils functions
* src/GrampsDb/_DbUtils.py: new routines to remove families and * src/GrampsDb/_DbUtils.py: new routines to remove families and

View File

@ -68,12 +68,13 @@ import Spell
import GrampsDisplay import GrampsDisplay
import RelLib import RelLib
import AutoComp import AutoComp
from _EditPrimary import EditPrimary from _EditPrimary import EditPrimary
from PluginUtils import ReportUtils from PluginUtils import ReportUtils
from DdTargets import DdTargets from DdTargets import DdTargets
from DisplayTabs import * from DisplayTabs import *
from GrampsWidgets import * from GrampsWidgets import *
from ObjectSelector import PersonSelector,PersonFilterSpec from ObjectSelector import PersonSelector,PersonFilterSpec
class ChildEmbedList(EmbeddedList): class ChildEmbedList(EmbeddedList):
@ -455,25 +456,45 @@ class EditFamily(EditPrimary):
self.obj.set_father_handle(None) self.obj.set_father_handle(None)
self.update_father(None) self.update_father(None)
else: else:
filter_spec = PersonFilterSpec() from SelectPerson import SelectPerson
filter_spec.set_gender(RelLib.Person.MALE) import GenericFilter
child_birth_years = [] data_filter = GenericFilter.GenericFilter()
for person_handle in self.obj.get_child_handle_list(): data_filter.add_rule(GenericFilter.IsMale([]))
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: sel = SelectPerson(self.dbstate.db, "Select Father",
filter_spec.set_birth_year(min(child_birth_years)) filter=data_filter,
filter_spec.set_birth_criteria(PersonFilterSpec.BEFORE) skip=self.obj.get_child_handle_list())
person = sel.run()
selector = PersonSelector(self.dbstate,self.uistate, if person:
self.track,filter_spec=filter_spec) self.obj.set_father_handle(person.handle)
selector.connect('add-object',self.on_change_father) 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)
# 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): def edit_person(self,obj,event,handle):
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1: if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:

View File

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

View File

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