4436: FindDuplicated tool uses merging (fix by MD Nauta)

svn: r16254
This commit is contained in:
Jérôme Rapinat 2010-12-06 09:02:01 +00:00
parent 0fddfcfebb
commit 325bb5086e
2 changed files with 28 additions and 18 deletions

View File

@ -70,12 +70,14 @@ class MergePeople(ManagedWindow.ManagedWindow):
"""
Displays a dialog box that allows the persons to be combined into one.
"""
def __init__(self, dbstate, uistate, handle1, handle2):
def __init__(self, dbstate, uistate, handle1, handle2, cb_update=None,
expand_context_info=False):
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
self.dbstate = dbstate
database = dbstate.db
self.pr1 = database.get_person_from_handle(handle1)
self.pr2 = database.get_person_from_handle(handle2)
self.update = cb_update
self.define_glade('mergeperson', _GLADE_FILE)
self.set_window(self._gladeobj.toplevel,
@ -121,8 +123,9 @@ class MergePeople(ManagedWindow.ManagedWindow):
rbutton_label2.set_label(name2 + " [" + gramps2 + "]")
rbutton1.connect("toggled", self.on_handle1_toggled)
expander2 = self.get_widget("expander2")
self.expander_handler = \
expander2.connect("activate", self.on_expander2_activated)
self.expander_handler = expander2.connect("notify::expanded",
self.cb_expander2_activated)
expander2.set_expanded(expand_context_info)
self.connect_button("person_help", self.cb_help)
self.connect_button("person_ok", self.cb_merge)
@ -140,14 +143,14 @@ class MergePeople(ManagedWindow.ManagedWindow):
self.get_widget("gender_btn2").set_active(True)
self.get_widget("gramps_btn2").set_active(True)
def on_expander2_activated(self, obj):
def cb_expander2_activated(self, obj, param_spec):
"""Context Information expander is activated"""
text1 = self.get_widget('text1')
text2 = self.get_widget('text2')
self.display(text1.get_buffer(), self.pr1)
self.display(text2.get_buffer(), self.pr2)
expander2 = self.get_widget("expander2")
expander2.disconnect(self.expander_handler)
if obj.get_expanded():
text1 = self.get_widget('text1')
text2 = self.get_widget('text2')
self.display(text1.get_buffer(), self.pr1)
self.display(text2.get_buffer(), self.pr2)
obj.disconnect(self.expander_handler)
def add(self, tobj, tag, text):
"""Add text text to text buffer tobj with formatting tag."""
@ -328,6 +331,8 @@ class MergePeople(ManagedWindow.ManagedWindow):
unselect_path)
self.uistate.set_busy_cursor(False)
self.close()
if self.update:
self.update()
class MergePersonQuery(object):
"""

View File

@ -45,7 +45,7 @@ from gen.display.name import displayer as name_displayer
from QuestionDialog import OkDialog
import ListModel
import Errors
from Merge import PersonCompare
from Merge import MergePeople
import GrampsDisplay
import ManagedWindow
from QuestionDialog import RunDatabaseRepair
@ -599,16 +599,21 @@ class ShowMatches(ManagedWindow.ManagedWindow):
return
(self.p1,self.p2) = self.list.get_object(iter)
pn1 = self.db.get_person_from_handle(self.p1)
pn2 = self.db.get_person_from_handle(self.p2)
PersonCompare(self.dbstate,self.uistate,pn1,pn2,self.on_update)
MergePeople(self.dbstate, self.uistate, self.p1, self.p2,
self.on_update, True)
def on_update(self):
self.dellist[self.p2] = self.p1
if self.db.has_person_handle(self.p1):
phoenix = self.p1
titanic = self.p2
else:
phoenix = self.p2
titanic = self.p1
self.dellist[titanic] = phoenix
for key, data in self.dellist.iteritems():
if data == self.p2:
self.dellist[key] = self.p1
if data == titanic:
self.dellist[key] = phoenix
self.update()
self.redraw()