* src/DataViews/_PedigreeView.py: Fix ChildRef, Show person references

* src/Editors/_EditFamily.py: Typo
* src/GrampsDb/_GrampsDbBase.py (get_active_person): Handle case of no active person
* src/plugins/TestcaseGenerator.py: really generate shared events; use new GrampsType; randomize name type
* src/DataViews/_PersonView.py: DnD only for lines of persons; Fix set for python 2.3; fix get_parent_family_handle_list usage



svn: r6342
This commit is contained in:
Martin Hawlisch 2006-04-14 12:39:17 +00:00
parent 3eda5ea7df
commit 71dcdd9c07
6 changed files with 61 additions and 28 deletions

View File

@ -1,3 +1,13 @@
2006-04-13 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/DataViews/_PedigreeView.py: Fix ChildRef, Show person references
* src/Editors/_EditFamily.py: Typo
* src/GrampsDb/_GrampsDbBase.py (get_active_person): Handle case of no
active person
* src/plugins/TestcaseGenerator.py: really generate shared events; use
new GrampsType; randomize name type
* src/DataViews/_PersonView.py: DnD only for lines of persons; Fix set
for python 2.3; fix get_parent_family_handle_list usage
2006-04-13 Don Allingham <don@gramps-project.org>
* src/DataViews/_FamilyView.py: Type class support
* src/DataViews/_PedigreeView.py: Type class support

View File

@ -990,7 +990,9 @@ class PedigreeView(PageView.PersonNavView):
family = self.dbstate.db.get_family_from_handle(family_handle)
else: # no parents -> create new family
family = RelLib.Family()
family.add_child_handle(person_handle)
childref = RelLib.ChildRef()
childref.set_reference_handle(person_handle)
family.add_child_ref(childref)
try:
EditFamily(self.dbstate,self.uistate,[],family)
except Errors.WindowActiveError:
@ -1540,23 +1542,26 @@ def find_witnessed_people(db,p):
people = []
for event_ref in p.get_event_ref_list():
for l in db.find_backlink_handles( event_ref.ref):
if l[0] == 'Person' and l[1] != p.get_handle():
if l[0] == 'Person' and l[1] != p.get_handle() and l[1] not in people:
people.append(l[1])
if l[0] == 'Family':
fam = db.get_family_from_handle(l[1])
if fam:
father_handle = fam.get_father_handle()
if father_handle and father_handle != p.get_handle():
if father_handle and father_handle != p.get_handle() and father_handle not in people:
people.append(father_handle)
mother_handle = fam.get_mother_handle()
if mother_handle and mother_handle != p.get_handle():
if mother_handle and mother_handle != p.get_handle() and mother_handle not in people:
people.append(mother_handle)
for f in p.get_family_handle_list():
family = db.get_family_from_handle(f)
for event_ref in family.get_event_ref_list():
for l in db.find_backlink_handles( event_ref.ref):
if l[0] == 'Person' and l[1] != p.get_handle():
if l[0] == 'Person' and l[1] != p.get_handle() and l[1] not in people:
people.append(l[1])
for pref in p.get_person_ref_list():
if pref.ref != p.get_handle and pref.ref not in people:
people.append(pref.ref)
return people
#-------------------------------------------------------------------------

View File

@ -30,6 +30,11 @@
from gettext import gettext as _
import cPickle as pickle
try:
set()
except:
from sets import Set as set
#-------------------------------------------------------------------------
#
# gtk
@ -431,7 +436,7 @@ class PersonView(PageView.PersonNavView):
else:
self.dbstate.db.commit_family(family,trans)
for (family_handle,mrel,frel) in self.active_person.get_parent_family_handle_list():
for family_handle in self.active_person.get_parent_family_handle_list():
if family_handle:
family = self.dbstate.db.get_family_from_handle(family_handle)
family.remove_child_handle(self.active_person.get_handle())
@ -504,9 +509,9 @@ class PersonView(PageView.PersonNavView):
def drag_data_get(self, widget, context, sel_data, info, time):
selected_ids = self.get_selected_objects()
data = (DdTargets.PERSON_LINK.drag_type, id(self), selected_ids[0], 0)
nonempty_ids = [h for h in selected_ids if h]
if nonempty_ids:
data = (DdTargets.PERSON_LINK.drag_type, id(self), nonempty_ids[0], 0)
sel_data.set(sel_data.target, 8 ,pickle.dumps(data))
def person_added(self,handle_list):

View File

@ -826,9 +826,9 @@ class EditFamily(EditPrimary):
# for each child, add the family handle to the child
for ref in self.obj.get_child_ref_list():
child = self.db.get_person_from_handle(handle)
child = self.db.get_person_from_handle(ref.ref)
# fix - relationships need to be extracted from the list
child.add_parent_family_ref(ref)
child.add_parent_family_handle(self.obj.handle)
self.db.commit_person(child,trans)
self.db.add_family(self.obj,trans)
@ -878,4 +878,3 @@ class EditFamily(EditPrimary):
self.db.transaction_commit(trans,_("Edit Family"))
self.close_window()

View File

@ -26,7 +26,7 @@ from this class.
"""
__author__ = "Donald N. Allingham"
__revision__ = "$Revision:$"
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
@ -2072,6 +2072,7 @@ class DbState(GrampsDBCallback):
self.change_active_person(self.db.get_person_from_handle(handle))
def get_active_person(self):
if self.active: # Fetch a fresh version from DB to not return a stale one
self.active = self.db.get_person_from_handle(self.active.handle)
return self.active
@ -2097,4 +2098,3 @@ class DbState(GrampsDBCallback):
def get_place_completion(self):
return self.places

View File

@ -821,10 +821,11 @@ class TestcaseGenerator(Tool.Tool):
if self.generated_events:
while randint(0,5) == 1:
e_h = choice(self.generated_events)
ref = RelLib.EventRef()
self.fill_object( ref)
ref.set_reference_handle(e_h)
ref.set_role( self.rand_type(Utils.event_roles))
eref = RelLib.EventRef()
self.fill_object( eref)
eref.set_reference_handle(e_h)
eref.set_role( self.rand_type(Utils.event_roles))
np.add_event_ref(eref)
person_handle = self.db.add_person(np,self.trans)
@ -1050,9 +1051,9 @@ class TestcaseGenerator(Tool.Tool):
if isinstance(o,RelLib.ChildRef):
if randint(0,3) == 1:
o.set_mother_relation( self.rand_type( Utils.child_relations))
o.set_mother_relation( self.rand_type( RelLib.ChildRefType()))
if randint(0,3) == 1:
o.set_father_relation( self.rand_type( Utils.child_relations))
o.set_father_relation( self.rand_type( RelLib.ChildRefType()))
if issubclass(o.__class__,RelLib._DateBase.DateBase):
if randint(0,1) == 1:
@ -1113,6 +1114,9 @@ class TestcaseGenerator(Tool.Tool):
if randint(0,1) == 1:
o.set_rectangle( (randint(0,200),randint(0,200),randint(0,200),randint(0,200)))
if isinstance(o,RelLib.Name):
o.set_type( self.rand_type( RelLib.NameType()))
if issubclass(o.__class__,RelLib._NoteBase.NoteBase):
o.set_note( self.rand_text(self.NOTE))
o.set_note_format( choice( (True,False)))
@ -1233,11 +1237,21 @@ class TestcaseGenerator(Tool.Tool):
return (year, event_ref)
def rand_type( self, list):
if type(list) == dict:
key = choice(list.keys())
value = list[key]
if value == _("Custom"):
value = self.rand_text(self.SHORT)
return( (key,value))
elif issubclass( list.__class__, RelLib.GrampsType):
map = list.get_map()
key = choice( map.keys())
if key == list.get_custom():
value = self.rand_text(self.SHORT)
else:
value = ''
list.set( (key,value))
return list
def rand_place( self):
if not self.generated_places or randint(0,10) == 1:
@ -1306,7 +1320,7 @@ class TestcaseGenerator(Tool.Tool):
maxsyllables = 3
if type == self.NOTE:
result = result + "Geberated by TestcaseGenerator."
result = result + "Generated by TestcaseGenerator."
minwords = 20
maxwords = 100