* src/DataViews/_PersonView.py: merge functionality
* src/ViewManager.py: merge functionality * src/MergePeople.py: fix merge (ui and birth/death events) * src/GrampsDb/_WriteXML.py: remove redundant birth/death entries svn: r6773
This commit is contained in:
parent
57bb0ce78c
commit
00a5154a67
@ -1,4 +1,8 @@
|
|||||||
2006-05-24 Don Allingham <don@gramps-project.org>
|
2006-05-24 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/DataViews/_PersonView.py: merge functionality
|
||||||
|
* src/ViewManager.py: merge functionality
|
||||||
|
* src/MergePeople.py: fix merge (ui and birth/death events)
|
||||||
|
* src/GrampsDb/_WriteXML.py: remove redundant birth/death entries
|
||||||
* src/GrampsDb/_DbUtils.py: fix index setting of death index
|
* src/GrampsDb/_DbUtils.py: fix index setting of death index
|
||||||
* src/GrampsDb/_WriteGedcom.py: remove redundant birth/death
|
* src/GrampsDb/_WriteGedcom.py: remove redundant birth/death
|
||||||
references
|
references
|
||||||
|
@ -136,6 +136,59 @@ class PersonView(PageView.PersonNavView):
|
|||||||
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
|
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
|
||||||
_('_Column Editor'), callback=self.column_editor,)
|
_('_Column Editor'), callback=self.column_editor,)
|
||||||
|
|
||||||
|
self.add_action('CmpMerge', None, _('_Compare and merge'),
|
||||||
|
callback=self.cmp_merge)
|
||||||
|
self.add_action('FastMerge', None, _('_Fast merge'),
|
||||||
|
callback=self.fast_merge)
|
||||||
|
|
||||||
|
def cmp_merge(self, obj):
|
||||||
|
mlist = self.get_selected_objects()
|
||||||
|
|
||||||
|
if len(mlist) != 2:
|
||||||
|
from QuestionDialog import ErrorDialog
|
||||||
|
|
||||||
|
msg = _("Cannot merge people")
|
||||||
|
msg2 = _("Exactly two people must be selected to perform a merge. "
|
||||||
|
"A second person can be selected by holding down the "
|
||||||
|
"control key while clicking on the desired person.")
|
||||||
|
ErrorDialog(msg,msg2)
|
||||||
|
else:
|
||||||
|
from QuestionDialog import ErrorDialog
|
||||||
|
import MergePeople
|
||||||
|
p1 = self.db.get_person_from_handle(mlist[0])
|
||||||
|
p2 = self.db.get_person_from_handle(mlist[1])
|
||||||
|
if p1 and p2:
|
||||||
|
merger = MergePeople.Compare(self.dbstate, self.uistate, p1, p2)
|
||||||
|
else:
|
||||||
|
msg = _("Cannot merge people")
|
||||||
|
msg2 = _("Exactly two people must be selected to perform a merge. "
|
||||||
|
"A second person can be selected by holding down the "
|
||||||
|
"control key while clicking on the desired person.")
|
||||||
|
ErrorDialog(msg,msg2)
|
||||||
|
|
||||||
|
def fast_merge(self, obj):
|
||||||
|
mlist = self.get_selected_objects()
|
||||||
|
|
||||||
|
if len(mlist) != 2:
|
||||||
|
msg = _("Cannot merge people")
|
||||||
|
msg2 = _("Exactly two people must be selected to perform a merge. "
|
||||||
|
"A second person can be selected by holding down the "
|
||||||
|
"control key while clicking on the desired person.")
|
||||||
|
ErrorDialog(msg,msg2)
|
||||||
|
else:
|
||||||
|
from MergePeople import MergePeopleUI
|
||||||
|
|
||||||
|
p1 = self.db.get_person_from_handle(mlist[0])
|
||||||
|
p2 = self.db.get_person_from_handle(mlist[1])
|
||||||
|
if p1 and p2:
|
||||||
|
MergePeopleUI(self.dbstate, self.uistate, p1, p2)
|
||||||
|
else:
|
||||||
|
msg = _("Cannot merge people")
|
||||||
|
msg2 = _("Exactly two people must be selected to perform a merge. "
|
||||||
|
"A second person can be selected by holding down the "
|
||||||
|
"control key while clicking on the desired person.")
|
||||||
|
ErrorDialog(msg,msg2)
|
||||||
|
|
||||||
def column_editor(self,obj):
|
def column_editor(self,obj):
|
||||||
import ColumnOrder
|
import ColumnOrder
|
||||||
|
|
||||||
@ -254,6 +307,10 @@ class PersonView(PageView.PersonNavView):
|
|||||||
</placeholder>
|
</placeholder>
|
||||||
<menuitem action="SetActive"/>
|
<menuitem action="SetActive"/>
|
||||||
<menuitem action="ColumnEdit"/>
|
<menuitem action="ColumnEdit"/>
|
||||||
|
<placeholder name="Merge">
|
||||||
|
<menuitem action="CmpMerge"/>
|
||||||
|
<menuitem action="FastMerge"/>
|
||||||
|
</placeholder>
|
||||||
</menu>
|
</menu>
|
||||||
</menubar>
|
</menubar>
|
||||||
<toolbar name="ToolBar">
|
<toolbar name="ToolBar">
|
||||||
|
@ -404,8 +404,8 @@ class XmlWriter(UpdateCallback):
|
|||||||
for name in person.get_alternate_names():
|
for name in person.get_alternate_names():
|
||||||
self.dump_name(name,True,index+1)
|
self.dump_name(name,True,index+1)
|
||||||
|
|
||||||
self.dump_event_ref(person.get_birth_ref(),index+1)
|
#self.dump_event_ref(person.get_birth_ref(),index+1)
|
||||||
self.dump_event_ref(person.get_death_ref(),index+1)
|
#self.dump_event_ref(person.get_death_ref(),index+1)
|
||||||
for event_ref in person.get_event_ref_list():
|
for event_ref in person.get_event_ref_list():
|
||||||
self.dump_event_ref(event_ref,index+1)
|
self.dump_event_ref(event_ref,index+1)
|
||||||
|
|
||||||
|
@ -50,12 +50,13 @@ import QuestionDialog
|
|||||||
import GrampsDisplay
|
import GrampsDisplay
|
||||||
import ManagedWindow
|
import ManagedWindow
|
||||||
import Utils
|
import Utils
|
||||||
|
import GrampsDb
|
||||||
|
|
||||||
sex = ( _("female"), _("male"), _("unknown"))
|
sex = ( _("female"), _("male"), _("unknown"))
|
||||||
|
|
||||||
class Compare(ManagedWindow.ManagedWindow):
|
class Compare(ManagedWindow.ManagedWindow):
|
||||||
|
|
||||||
def __init__(self, dbstate, uistate, person1, person2, update) :
|
def __init__(self, dbstate, uistate, person1, person2, update=None) :
|
||||||
|
|
||||||
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
|
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
|
||||||
|
|
||||||
@ -102,6 +103,7 @@ class Compare(ManagedWindow.ManagedWindow):
|
|||||||
merge = MergePeople(self.db,self.p2,self.p1)
|
merge = MergePeople(self.db,self.p2,self.p1)
|
||||||
self.close()
|
self.close()
|
||||||
merge.merge()
|
merge.merge()
|
||||||
|
if self.update:
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def add(self, tobj, tag, text):
|
def add(self, tobj, tag, text):
|
||||||
@ -256,11 +258,17 @@ def check_for_child(p1, p2):
|
|||||||
# Merge People UI
|
# Merge People UI
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class MergePeopleUI:
|
class MergePeopleUI(ManagedWindow.ManagedWindow):
|
||||||
|
|
||||||
|
def __init__(self, dbstate, uistate, person1, person2, update=None):
|
||||||
|
|
||||||
|
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
|
||||||
|
|
||||||
def __init__(self,db,person1,person2,update):
|
|
||||||
glade = gtk.glade.XML(const.merge_glade, 'merge_people')
|
glade = gtk.glade.XML(const.merge_glade, 'merge_people')
|
||||||
window = glade.get_widget('merge_people')
|
window = glade.get_widget('merge_people')
|
||||||
|
|
||||||
|
self.set_window(window, glade.get_widget('title'), _("Merge People"))
|
||||||
|
|
||||||
p1 = glade.get_widget('person1')
|
p1 = glade.get_widget('person1')
|
||||||
p2 = glade.get_widget('person2')
|
p2 = glade.get_widget('person2')
|
||||||
n1 = name_of(person1)
|
n1 = name_of(person1)
|
||||||
@ -268,12 +276,12 @@ class MergePeopleUI:
|
|||||||
|
|
||||||
p1.set_label(n1)
|
p1.set_label(n1)
|
||||||
p2.set_label(n2)
|
p2.set_label(n2)
|
||||||
Utils.set_titles(top,glade.get_widget('title'),_("Merge People"))
|
|
||||||
glade.get_widget('help').connect('clicked',self.help)
|
glade.get_widget('help').connect('clicked',self.help)
|
||||||
|
|
||||||
ret = gtk.RESPONSE_HELP
|
ret = gtk.RESPONSE_HELP
|
||||||
while ret == gtk.RESPONSE_HELP:
|
while ret == gtk.RESPONSE_HELP:
|
||||||
ret = top.run()
|
ret = window.run()
|
||||||
|
|
||||||
if ret == gtk.RESPONSE_OK:
|
if ret == gtk.RESPONSE_OK:
|
||||||
|
|
||||||
@ -290,12 +298,16 @@ class MergePeopleUI:
|
|||||||
"them."))
|
"them."))
|
||||||
else:
|
else:
|
||||||
if p1.get_active():
|
if p1.get_active():
|
||||||
merge = MergePeople(db,person1,person2)
|
merge = MergePeople(dbstate.db,person1,person2)
|
||||||
else:
|
else:
|
||||||
merge = MergePeople(db,person2,person1)
|
merge = MergePeople(dbstate.db,person2,person1)
|
||||||
merge.merge()
|
merge.merge()
|
||||||
|
if update:
|
||||||
update()
|
update()
|
||||||
top.destroy()
|
window.destroy()
|
||||||
|
|
||||||
|
def build_menu_names(self,obj):
|
||||||
|
return (_('Merge People'),None)
|
||||||
|
|
||||||
def help(self,obj):
|
def help(self,obj):
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
"""Display the relevant portion of GRAMPS manual"""
|
||||||
@ -395,15 +407,11 @@ class MergePeople:
|
|||||||
# copy names
|
# copy names
|
||||||
self.merge_names(new)
|
self.merge_names(new)
|
||||||
|
|
||||||
# copy the birth event
|
|
||||||
self.merge_birth(new,trans)
|
|
||||||
|
|
||||||
# copy the death event
|
|
||||||
self.merge_death(new,trans)
|
|
||||||
|
|
||||||
# merge the event lists
|
# merge the event lists
|
||||||
self.merge_event_lists(new)
|
self.merge_event_lists(new)
|
||||||
|
|
||||||
|
GrampsDb.set_birth_death_index(self.db, new)
|
||||||
|
|
||||||
# copy attributes
|
# copy attributes
|
||||||
new.set_attribute_list(self.p1.get_attribute_list() +
|
new.set_attribute_list(self.p1.get_attribute_list() +
|
||||||
self.p2.get_attribute_list())
|
self.p2.get_attribute_list())
|
||||||
@ -483,17 +491,8 @@ class MergePeople:
|
|||||||
ref1 = self.p1.get_birth_ref()
|
ref1 = self.p1.get_birth_ref()
|
||||||
ref2 = self.p2.get_birth_ref()
|
ref2 = self.p2.get_birth_ref()
|
||||||
|
|
||||||
if ref1:
|
if not ref1.is_equal(ref2):
|
||||||
new.set_birth_ref(ref1)
|
new.add_event_ref(ref2)
|
||||||
if ref2:
|
|
||||||
event = self.db.get_event_from_handle(ref2.ref)
|
|
||||||
event.set_name('Alternate Birth')
|
|
||||||
self.db.add_event(event,trans)
|
|
||||||
event_ref = RelLib.EventRef()
|
|
||||||
event_ref.ref = event.get_handle()
|
|
||||||
new.add_event_ref(event_ref)
|
|
||||||
elif not ref1 and ref2:
|
|
||||||
new.set_birth_ref(ref2)
|
|
||||||
|
|
||||||
def merge_death(self, new, trans):
|
def merge_death(self, new, trans):
|
||||||
"""
|
"""
|
||||||
@ -507,18 +506,8 @@ class MergePeople:
|
|||||||
ref1 = self.p1.get_death_ref()
|
ref1 = self.p1.get_death_ref()
|
||||||
ref2 = self.p2.get_death_ref()
|
ref2 = self.p2.get_death_ref()
|
||||||
|
|
||||||
if ref1:
|
if not ref1.is_equal(ref2):
|
||||||
new.set_death_ref(ref1)
|
new.add_event_ref(ref2)
|
||||||
if ref2:
|
|
||||||
event = self.db.get_event_from_handle(ref2)
|
|
||||||
event.set_handle(Utils.create_id())
|
|
||||||
event.set_name('Alternate Death')
|
|
||||||
event_ref = RelLib.EventRef()
|
|
||||||
event_ref.ref = event.get_handle()
|
|
||||||
new.add_event_ref(event_ref)
|
|
||||||
self.db.add_event(event,trans)
|
|
||||||
elif not ref1 and ref2:
|
|
||||||
new.set_death_ref(ref2)
|
|
||||||
|
|
||||||
def merge_event_lists(self, new):
|
def merge_event_lists(self, new):
|
||||||
"""
|
"""
|
||||||
|
@ -116,8 +116,7 @@ uidefault = '''<ui>
|
|||||||
<placeholder name="CommonEdit"/>
|
<placeholder name="CommonEdit"/>
|
||||||
<separator/>
|
<separator/>
|
||||||
<menuitem action="ScratchPad"/>
|
<menuitem action="ScratchPad"/>
|
||||||
<menuitem action="CmpMerge"/>
|
<placeholder name="Merge"/>
|
||||||
<menuitem action="FastMerge"/>
|
|
||||||
<separator/>
|
<separator/>
|
||||||
<menuitem action="Preferences"/>
|
<menuitem action="Preferences"/>
|
||||||
</menu>
|
</menu>
|
||||||
@ -343,8 +342,6 @@ class ViewManager:
|
|||||||
self.export_data),
|
self.export_data),
|
||||||
('Abandon', gtk.STOCK_REVERT_TO_SAVED,
|
('Abandon', gtk.STOCK_REVERT_TO_SAVED,
|
||||||
_('_Abandon changes and quit'), None, None, self.abort),
|
_('_Abandon changes and quit'), None, None, self.abort),
|
||||||
('CmpMerge', None, _('_Compare and merge')),
|
|
||||||
('FastMerge', None, _('_Fast merge')),
|
|
||||||
('ScratchPad', gtk.STOCK_PASTE, _('_ScratchPad'), "",
|
('ScratchPad', gtk.STOCK_PASTE, _('_ScratchPad'), "",
|
||||||
_("Open the ScratchPad dialog"), self.scratchpad),
|
_("Open the ScratchPad dialog"), self.scratchpad),
|
||||||
('Import', gtk.STOCK_CONVERT, _('_Import'), "<control>i", None,
|
('Import', gtk.STOCK_CONVERT, _('_Import'), "<control>i", None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user