* src/DataViews/_SourceView.py: source merge support
svn: r6777
This commit is contained in:
parent
a7e7146897
commit
f129939ab6
@ -1,4 +1,5 @@
|
||||
2006-05-25 Don Allingham <don@gramps-project.org>
|
||||
* src/DataViews/_SourceView.py: source merge support
|
||||
* src/DataViews/_PlaceView.py: place merge support
|
||||
* src/glade/mergedata.glade: place merge support
|
||||
* src/MergeData.py: place merge support
|
||||
|
@ -154,7 +154,7 @@ class PersonView(PageView.PersonNavView):
|
||||
ErrorDialog(msg,msg2)
|
||||
else:
|
||||
from QuestionDialog import ErrorDialog
|
||||
import MergePeople
|
||||
from Merge import MergePeople
|
||||
p1 = self.db.get_person_from_handle(mlist[0])
|
||||
p2 = self.db.get_person_from_handle(mlist[1])
|
||||
if p1 and p2:
|
||||
@ -176,12 +176,12 @@ class PersonView(PageView.PersonNavView):
|
||||
"control key while clicking on the desired person.")
|
||||
ErrorDialog(msg,msg2)
|
||||
else:
|
||||
from MergePeople import MergePeopleUI
|
||||
from Merge import MergePeople
|
||||
|
||||
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)
|
||||
MergePeople.MergePeopleUI(self.dbstate, self.uistate, p1, p2)
|
||||
else:
|
||||
msg = _("Cannot merge people")
|
||||
msg2 = _("Exactly two people must be selected to perform a merge. "
|
||||
@ -634,7 +634,8 @@ class PersonView(PageView.PersonNavView):
|
||||
sel_data.set(sel_data.target, 8 ,pickle.dumps(data))
|
||||
|
||||
def person_added(self,handle_list):
|
||||
self.model.clear_cache()
|
||||
if not self.model:
|
||||
return
|
||||
for node in handle_list:
|
||||
person = self.dbstate.db.get_person_from_handle(node)
|
||||
top = person.get_primary_name().get_group_name()
|
||||
@ -651,6 +652,9 @@ class PersonView(PageView.PersonNavView):
|
||||
self.model.row_inserted(path,pnode)
|
||||
|
||||
def person_removed(self,handle_list):
|
||||
if not self.model:
|
||||
return
|
||||
|
||||
self.model.clear_cache()
|
||||
for node in handle_list:
|
||||
person = self.dbstate.db.get_person_from_handle(node)
|
||||
@ -669,6 +673,9 @@ class PersonView(PageView.PersonNavView):
|
||||
self.model.assign_data()
|
||||
|
||||
def person_updated(self,handle_list):
|
||||
if not self.model:
|
||||
return
|
||||
|
||||
self.model.clear_cache()
|
||||
for node in handle_list:
|
||||
person = self.dbstate.db.get_person_from_handle(node)
|
||||
|
@ -217,12 +217,11 @@ class PlaceView(PageView.ListView):
|
||||
if len(mlist) != 2:
|
||||
msg = _("Cannot merge places.")
|
||||
msg2 = _("Exactly two places must be selected to perform a merge. "
|
||||
"A second place can be selected by holding down the "
|
||||
"control key while clicking on the desired place.")
|
||||
"A second place can be selected by holding down the "
|
||||
"control key while clicking on the desired place.")
|
||||
ErrorDialog(msg,msg2)
|
||||
else:
|
||||
import MergeData
|
||||
MergeData.MergePlaces(self.dbstate, self.uistate, mlist[0],
|
||||
mlist[1], self.build_tree)
|
||||
MergeData.MergePlaces(self.dbstate, self.uistate, mlist[0], mlist[1])
|
||||
|
||||
|
||||
|
@ -83,7 +83,7 @@ class SourceView(PageView.ListView):
|
||||
self, _('Sources'), dbstate, uistate, column_names,
|
||||
len(column_names), DisplayModels.SourceModel, signal_map,
|
||||
dbstate.db.get_source_bookmarks(),
|
||||
Bookmarks.SourceBookmarks)
|
||||
Bookmarks.SourceBookmarks, multiple=True)
|
||||
|
||||
def get_bookmarks(self):
|
||||
return self.dbstate.db.get_source_bookmarks()
|
||||
@ -95,6 +95,8 @@ class SourceView(PageView.ListView):
|
||||
PageView.ListView.define_actions(self)
|
||||
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
|
||||
_('_Column Editor'), callback=self.column_editor)
|
||||
self.add_action('FastMerge', None, _('_Merge'),
|
||||
callback=self.fast_merge)
|
||||
|
||||
def column_editor(self,obj):
|
||||
import ColumnOrder
|
||||
@ -132,6 +134,9 @@ class SourceView(PageView.ListView):
|
||||
<menuitem action="Remove"/>
|
||||
</placeholder>
|
||||
<menuitem action="ColumnEdit"/>
|
||||
<placeholder name="Merge">
|
||||
<menuitem action="FastMerge"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
</menubar>
|
||||
<toolbar name="ToolBar">
|
||||
@ -194,3 +199,17 @@ class SourceView(PageView.ListView):
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
|
||||
def fast_merge(self, obj):
|
||||
mlist = []
|
||||
self.selection.selected_foreach(self.blist,mlist)
|
||||
|
||||
if len(mlist) != 2:
|
||||
msg = _("Cannot merge sources.")
|
||||
msg2 = _("Exactly two sources must be selected to perform a merge. "
|
||||
"A second source can be selected by holding down the "
|
||||
"control key while clicking on the desired source.")
|
||||
ErrorDialog(msg,msg2)
|
||||
else:
|
||||
import MergeData
|
||||
MergeData.MergeSources(self.dbstate, self.uistate, mlist[0], mlist[1])
|
||||
|
||||
|
@ -7,6 +7,7 @@ SUBDIRS = \
|
||||
Editors \
|
||||
Filters \
|
||||
GrampsDb \
|
||||
Merge \
|
||||
DisplayTabs \
|
||||
DisplayModels \
|
||||
GrampsLogger \
|
||||
|
22
gramps2/src/Merge/Makefile.am
Normal file
22
gramps2/src/Merge/Makefile.am
Normal file
@ -0,0 +1,22 @@
|
||||
# This is the src/RelLib level Makefile for Gramps
|
||||
# We could use GNU make's ':=' syntax for nice wildcard use,
|
||||
# but that is not necessarily portable.
|
||||
# If not using GNU make, then list all .py files individually
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@/Merge
|
||||
|
||||
pkgdata_PYTHON = \
|
||||
__init__.py \
|
||||
_MergePerson.py \
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/Merge
|
||||
pkgpythondir = @pkgpythondir@/Merge
|
||||
|
||||
# Clean up all the byte-compiled files
|
||||
MOSTLYCLEANFILES = *pyc *pyo
|
||||
|
||||
GRAMPS_PY_MODPATH = "../"
|
||||
|
||||
pycheck:
|
||||
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
|
||||
pychecker $(pkgdata_PYTHON));
|
26
gramps2/src/Merge/__init__.py
Normal file
26
gramps2/src/Merge/__init__.py
Normal file
@ -0,0 +1,26 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id: __init__.py 6169 2006-03-18 01:30:23Z dallingham $
|
||||
|
||||
"""
|
||||
"""
|
||||
|
||||
from MergePeople import MergePeople
|
@ -39,7 +39,6 @@ import gtk
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Utils
|
||||
import const
|
||||
import GrampsDisplay
|
||||
import ManagedWindow
|
||||
@ -54,7 +53,7 @@ class MergePlaces(ManagedWindow.ManagedWindow):
|
||||
Merges to places into a single place. Displays a dialog box that
|
||||
allows the places to be combined into one.
|
||||
"""
|
||||
def __init__(self, dbstate, uistate, new_handle, old_handle, update):
|
||||
def __init__(self, dbstate, uistate, new_handle, old_handle):
|
||||
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||
|
||||
@ -63,7 +62,6 @@ class MergePlaces(ManagedWindow.ManagedWindow):
|
||||
self.old_handle = old_handle
|
||||
self.p1 = self.db.get_place_from_handle(self.new_handle)
|
||||
self.p2 = self.db.get_place_from_handle(self.old_handle)
|
||||
self.update = update
|
||||
|
||||
self.glade = gtk.glade.XML(const.merge_glade,"merge_places","gramps")
|
||||
self.set_window(self.glade.get_widget("merge_places"),
|
||||
@ -79,7 +77,7 @@ class MergePlaces(ManagedWindow.ManagedWindow):
|
||||
self.glade.get_widget('ok').connect('clicked', self.merge)
|
||||
self.glade.get_widget('help').connect('clicked', self.help)
|
||||
|
||||
self.window.show()
|
||||
self.show()
|
||||
|
||||
def close_window(self, obj):
|
||||
self.close()
|
||||
@ -169,7 +167,6 @@ class MergePlaces(ManagedWindow.ManagedWindow):
|
||||
self.db.commit_event(event,trans)
|
||||
|
||||
self.db.transaction_commit(trans,_("Merge Places"))
|
||||
self.update()
|
||||
self.close()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -177,23 +174,27 @@ class MergePlaces(ManagedWindow.ManagedWindow):
|
||||
# Merge Sources
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MergeSources:
|
||||
class MergeSources(ManagedWindow.ManagedWindow):
|
||||
"""
|
||||
Merges to sources into a single source. Displays a dialog box that
|
||||
allows the sources to be combined into one.
|
||||
"""
|
||||
def __init__(self,database,new_handle,old_handle,update):
|
||||
self.db = database
|
||||
def __init__(self, dbstate, uistate, new_handle, old_handle):
|
||||
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||
|
||||
self.db = dbstate.db
|
||||
|
||||
self.new_handle = new_handle
|
||||
self.old_handle = old_handle
|
||||
self.src1 = self.db.get_source_from_handle(self.new_handle)
|
||||
self.src2 = self.db.get_source_from_handle(self.old_handle)
|
||||
self.update = update
|
||||
|
||||
self.glade = gtk.glade.XML(const.merge_glade,"merge_sources","gramps")
|
||||
self.top = self.glade.get_widget("merge_sources")
|
||||
Utils.set_titles(self.top,self.glade.get_widget('title'),
|
||||
_("Merge Sources"))
|
||||
|
||||
self.set_window(self.glade.get_widget("merge_sources"),
|
||||
self.glade.get_widget('title'),
|
||||
_("Merge Sources"))
|
||||
|
||||
self.title1 = self.glade.get_widget("title1")
|
||||
self.title2 = self.glade.get_widget("title2")
|
||||
@ -221,13 +222,12 @@ class MergeSources:
|
||||
self.gramps2.set_text(self.src2.get_gramps_id())
|
||||
|
||||
self.glade.get_widget('ok').connect('clicked',self.merge)
|
||||
self.glade.get_widget('cancel').connect('clicked',self.close)
|
||||
self.glade.get_widget('cancel').connect('clicked',self.close_window)
|
||||
self.glade.get_widget('help').connect('clicked',self.help)
|
||||
trans = self.db.transaction_begin()
|
||||
self.top.show()
|
||||
self.show()
|
||||
|
||||
def close(self,obj):
|
||||
self.top.destroy()
|
||||
def close_window(self,obj):
|
||||
self.close()
|
||||
|
||||
def help(self,obj):
|
||||
"""Display the relevant portion of GRAMPS manual"""
|
||||
@ -278,8 +278,10 @@ class MergeSources:
|
||||
src1_map[key] = src2_map[key]
|
||||
|
||||
# replace references in other objetcs
|
||||
self.db.remove_source(self.old_handle,self.trans)
|
||||
self.db.commit_source(self.src1,self.trans)
|
||||
trans = self.db.transaction_begin()
|
||||
|
||||
self.db.remove_source(self.old_handle,trans)
|
||||
self.db.commit_source(self.src1,trans)
|
||||
|
||||
# replace handles
|
||||
|
||||
@ -288,42 +290,42 @@ class MergeSources:
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
if person.has_source_reference(self.old_handle):
|
||||
person.replace_source_references(self.old_handle,self.new_handle)
|
||||
self.db.commit_person(person,self.trans)
|
||||
self.db.commit_person(person,trans)
|
||||
|
||||
# family
|
||||
for handle in self.db.get_family_handles():
|
||||
family = self.db.get_family_from_handle(handle)
|
||||
if family.has_source_reference(self.old_handle):
|
||||
family.replace_source_references(self.old_handle,self.new_handle)
|
||||
self.db.commit_family(family,self.trans)
|
||||
self.db.commit_family(family,trans)
|
||||
|
||||
# events
|
||||
for handle in self.db.get_event_handles():
|
||||
event = self.db.get_event_from_handle(handle)
|
||||
if event.has_source_reference(self.old_handle):
|
||||
event.replace_source_references(self.old_handle,self.new_handle)
|
||||
self.db.commit_event(event,self.trans)
|
||||
self.db.commit_event(event,trans)
|
||||
|
||||
# sources
|
||||
for handle in self.db.get_source_handles():
|
||||
source = self.db.get_source_from_handle(handle)
|
||||
if source.has_source_reference(self.old_handle):
|
||||
source.replace_source_references(self.old_handle,self.new_handle)
|
||||
self.db.commit_source(source,self.trans)
|
||||
self.db.commit_source(source,trans)
|
||||
|
||||
# places
|
||||
for handle in self.db.get_place_handles():
|
||||
place = self.db.get_place_from_handle(handle)
|
||||
if place.has_source_reference(self.old_handle):
|
||||
place.replace_source_references(self.old_handle,self.new_handle)
|
||||
self.db.commit_place(place,self.trans)
|
||||
self.db.commit_place(place,trans)
|
||||
|
||||
# media
|
||||
for handle in self.db.get_media_object_handles():
|
||||
obj = self.db.get_object_from_handle(handle)
|
||||
if obj.has_source_reference(self.old_handle):
|
||||
obj.replace_source_references(self.old_handle,self.new_handle)
|
||||
self.db.commit_media_object(obj,self.trans)
|
||||
self.db.commit_media_object(obj,trans)
|
||||
|
||||
self.db.transaction_commit(self.trans,_("Merge Sources"))
|
||||
self.top.destroy()
|
||||
self.db.transaction_commit(trans,_("Merge Sources"))
|
||||
self.close()
|
||||
|
Loading…
Reference in New Issue
Block a user