add/delete families better

svn: r6124
This commit is contained in:
Don Allingham 2006-03-09 22:37:19 +00:00
parent c7b1781575
commit 064ad83c6a
6 changed files with 55 additions and 41 deletions

View File

@ -1,3 +1,10 @@
2006-03-09 Don Allingham <don@gramps-project.org>
* src/DataViews/_FamilyView.py: avoid reentry
* src/DataViews/_PedigreeView.py: handle PluginUtils
* src/DataViews/_PersonView.py: handle remove person better
* src/Editors/_EditFamily.py: connect children up properly
* src/PeopleModel.py: handle delete properly
2006-03-09 Alex Roitman <shura@gramps-project.org>
* PluginUtils: Add module with Report and Tool utils.

View File

@ -28,10 +28,10 @@ import NameDisplay
import Utils
import DateHandler
import ImgManip
import ReportUtils
import Config
import GrampsWidgets
import Errors
from PluginUtils import ReportUtils
_GenderCode = {
RelLib.Person.MALE : u'\u2642',
@ -105,28 +105,34 @@ class FamilyView(PageView.PersonNavView):
def person_update(self,handle_list):
if self.dbstate.active:
self.change_person(self.dbstate.active.handle)
while not self.change_person(self.dbstate.active.handle):
pass
def person_rebuild(self):
if self.dbstate.active:
self.change_person(self.dbstate.active.handle)
while not self.change_person(self.dbstate.active.handle):
pass
def family_update(self,handle_list):
if self.dbstate.active:
self.change_person(self.dbstate.active.handle)
while not self.change_person(self.dbstate.active.handle):
pass
def family_add(self,handle_list):
if self.dbstate.active:
self.change_person(self.dbstate.active.handle)
while not self.change_person(self.dbstate.active.handle):
pass
def family_delete(self,handle_list):
if self.dbstate.active:
self.change_person(self.dbstate.active.handle)
while not self.change_person(self.dbstate.active.handle):
pass
def family_rebuild(self):
if self.dbstate.active:
self.change_person(self.dbstate.active.handle)
while not self.change_person(self.dbstate.active.handle):
pass
def get_stock(self):
"""
Returns the name of the stock icon to use for the display.
@ -231,7 +237,8 @@ class FamilyView(PageView.PersonNavView):
def change_person(self,obj):
if self.redrawing:
return
return False
print "DRAW"
self.redrawing = True
old_child = self.child
@ -244,6 +251,7 @@ class FamilyView(PageView.PersonNavView):
self.row = 5
family_handle_list = person.get_parent_family_handle_list()
print family_handle_list
if family_handle_list:
for (family_handle,mrel,frel) in family_handle_list:
if family_handle:
@ -301,6 +309,7 @@ class FamilyView(PageView.PersonNavView):
self.vbox.pack_start(self.child,False)
self.redrawing = False
return True
def write_title(self,person):
@ -429,6 +438,8 @@ class FamilyView(PageView.PersonNavView):
def write_parents(self,family_handle):
family = self.dbstate.db.get_family_from_handle(family_handle)
if not family:
return
self.write_label("%s:" % _('Parents'),family,True),
self.write_person(_('Father'),family.get_father_handle())
if self.show_details:

View File

@ -54,7 +54,7 @@ import NameDisplay
import Utils
import DateHandler
import ImgManip
import ReportUtils
from PluginUtils import ReportUtils
from Editors import EditPerson
#-------------------------------------------------------------------------

View File

@ -525,22 +525,21 @@ class PersonView(PageView.PersonNavView):
def person_removed(self,handle_list):
self.model.clear_cache()
self.build_tree()
# for node in handle_list:
# person = self.dbstate.db.get_person_from_handle(node)
# top = person.get_primary_name().get_group_name()
# mylist = self.model.sname_sub.get(top,[])
# self.model.calculate_data()
# if mylist:
# try:
# path = self.model.on_get_path(node)
# self.model.row_deleted(path)
# if len(mylist) == 1:
# path = self.model.on_get_path(top)
# self.model.row_deleted(path)
# except KeyError:
# pass
# self.model.assign_data()
for node in handle_list:
person = self.dbstate.db.get_person_from_handle(node)
top = person.get_primary_name().get_group_name()
mylist = self.model.sname_sub.get(top,[])
self.model.calculate_data(skip=set(handle_list))
if mylist:
try:
path = self.model.on_get_path(node)
self.model.row_deleted(path)
if len(mylist) == 1:
path = self.model.on_get_path(top)
self.model.row_deleted(path)
except KeyError:
pass
self.model.assign_data()
def person_updated(self,handle_list):
self.model.clear_cache()

View File

@ -67,10 +67,10 @@ import NameDisplay
import Spell
import GrampsDisplay
import RelLib
import ReportUtils
import AutoComp
from _EditPrimary import EditPrimary
from PluginUtils import ReportUtils
from DdTargets import DdTargets
from DisplayTabs import *
from GrampsWidgets import *
@ -415,9 +415,8 @@ class EditFamily(EditPrimary):
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()
event_handle = event_ref.ref
if event_handle:
event = self.db.get_event_from_handle(event_handle)
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:
@ -463,11 +462,9 @@ class EditFamily(EditPrimary):
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:
event_handle = event_ref.ref
if event_handle:
event = self.db.get_event_from_handle(event_handle)
child_birth_years.append(event.get_date_object().get_year())
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))
@ -570,7 +567,7 @@ class EditFamily(EditPrimary):
for handle in self.obj.get_child_handle_list():
child = self.db.get_person_from_handle(handle)
# fix - relationships need to be extracted from the list
child.add_parent_family_handle(handle,
child.add_parent_family_handle(self.obj.handle,
(RelLib.Person.CHILD_BIRTH,''),
(RelLib.Person.CHILD_BIRTH,''),
)

View File

@ -127,11 +127,11 @@ class PeopleModel(gtk.GenericTreeModel):
self.prev_data = None
self.rebuild_data(data_filter)
def rebuild_data(self,data_filter=None,skip=None):
self.calculate_data(data_filter)
def rebuild_data(self,data_filter=None,skip=[]):
self.calculate_data(data_filter,skip)
self.assign_data()
def calculate_data(self,data_filter=None):
def calculate_data(self,data_filter=None,skip=[]):
if data_filter:
self.data_filter = data_filter
self.temp_top_path2iter = []
@ -159,7 +159,7 @@ class PeopleModel(gtk.GenericTreeModel):
ngn = NameDisplay.displayer.name_grouping_name
nsn = NameDisplay.displayer.sorted_name
flist = set(keys)
flist = set([key for key in keys if key not in skip])
while node:
n,d = node