2006-05-25 Don Allingham <don@gramps-project.org>

* src/DataViews/_PlaceView.py: place merge support
	* src/glade/mergedata.glade: place merge support
	* src/MergeData.py: place merge support
	* src/PageView.py: add support for multiselection



svn: r6776
This commit is contained in:
Don Allingham 2006-05-25 19:39:44 +00:00
parent 32cca0759a
commit a7e7146897
5 changed files with 120 additions and 26 deletions

View File

@ -1,3 +1,9 @@
2006-05-25 Don Allingham <don@gramps-project.org>
* src/DataViews/_PlaceView.py: place merge support
* src/glade/mergedata.glade: place merge support
* src/MergeData.py: place merge support
* src/PageView.py: add support for multiselection
2006-05-24 Alex Roitman <shura@gramps-project.org> 2006-05-24 Alex Roitman <shura@gramps-project.org>
* src/plugins/Verify.py: Start major rework, still in progress. * src/plugins/Verify.py: Start major rework, still in progress.

View File

@ -88,7 +88,8 @@ class PlaceView(PageView.ListView):
self, _('Places'), dbstate, uistate, column_names, self, _('Places'), dbstate, uistate, column_names,
len(column_names), DisplayModels.PlaceModel, signal_map, len(column_names), DisplayModels.PlaceModel, signal_map,
dbstate.db.get_place_bookmarks(), dbstate.db.get_place_bookmarks(),
Bookmarks.PlaceBookmarks) Bookmarks.PlaceBookmarks,
multiple=True)
def get_bookmarks(self): def get_bookmarks(self):
return self.dbstate.db.get_place_bookmarks() return self.dbstate.db.get_place_bookmarks()
@ -97,6 +98,8 @@ class PlaceView(PageView.ListView):
PageView.ListView.define_actions(self) PageView.ListView.define_actions(self)
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('FastMerge', None, _('_Merge'),
callback=self.fast_merge)
def column_editor(self,obj): def column_editor(self,obj):
import ColumnOrder import ColumnOrder
@ -134,6 +137,9 @@ class PlaceView(PageView.ListView):
<menuitem action="Remove"/> <menuitem action="Remove"/>
</placeholder> </placeholder>
<menuitem action="ColumnEdit"/> <menuitem action="ColumnEdit"/>
<placeholder name="Merge">
<menuitem action="FastMerge"/>
</placeholder>
</menu> </menu>
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
@ -204,3 +210,19 @@ class PlaceView(PageView.ListView):
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass
def fast_merge(self, obj):
mlist = []
self.selection.selected_foreach(self.blist,mlist)
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.")
ErrorDialog(msg,msg2)
else:
import MergeData
MergeData.MergePlaces(self.dbstate, self.uistate, mlist[0],
mlist[1], self.build_tree)

View File

@ -42,47 +42,56 @@ import gtk
import Utils import Utils
import const import const
import GrampsDisplay import GrampsDisplay
import ManagedWindow
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Merge Places # Merge Places
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class MergePlaces: class MergePlaces(ManagedWindow.ManagedWindow):
""" """
Merges to places into a single place. Displays a dialog box that Merges to places into a single place. Displays a dialog box that
allows the places to be combined into one. allows the places to be combined into one.
""" """
def __init__(self,database,new_handle,old_handle,update): def __init__(self, dbstate, uistate, new_handle, old_handle, update):
self.db = database
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
self.db = dbstate.db
self.new_handle = new_handle self.new_handle = new_handle
self.old_handle = old_handle self.old_handle = old_handle
self.p1 = self.db.get_place_from_handle(self.new_handle) self.p1 = self.db.get_place_from_handle(self.new_handle)
self.p2 = self.db.get_place_from_handle(self.old_handle) self.p2 = self.db.get_place_from_handle(self.old_handle)
self.update = update self.update = update
self.trans = self.db.transaction_begin()
self.glade = gtk.glade.XML(const.merge_glade,"merge_places","gramps") self.glade = gtk.glade.XML(const.merge_glade,"merge_places","gramps")
self.top = self.glade.get_widget("merge_places") self.set_window(self.glade.get_widget("merge_places"),
Utils.set_titles(self.top,self.glade.get_widget('title'), self.glade.get_widget('title'),
_("Select title")) _("Select title"))
self.glade.get_widget("title1_text").set_text(self.p1.get_title()) self.glade.get_widget("title1_text").set_text(self.p1.get_title())
self.glade.get_widget("title2_text").set_text(self.p2.get_title()) self.glade.get_widget("title2_text").set_text(self.p2.get_title())
self.t3 = self.glade.get_widget("title3_text") self.t3 = self.glade.get_widget("title3_text")
self.t3.set_text(self.p1.get_title()) self.t3.set_text(self.p1.get_title())
self.glade.signal_autoconnect({ self.glade.get_widget('cancel').connect('clicked', self.close_window)
"destroy_passed_object" : Utils.destroy_passed_object, self.glade.get_widget('ok').connect('clicked', self.merge)
"on_merge_places_clicked" : self.on_merge_places_clicked, self.glade.get_widget('help').connect('clicked', self.help)
"on_help_places_clicked" : self.help,
}) self.window.show()
self.top.show()
def close_window(self, obj):
self.close()
def build_menu_names(self,obj):
return (_('Merge Places'),None)
def help(self,obj): def help(self,obj):
"""Display the relevant portion of GRAMPS manual""" """Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('adv-merge-places') GrampsDisplay.help('adv-merge-places')
def on_merge_places_clicked(self,obj): def merge(self,obj):
""" """
Performs the merge of the places when the merge button is clicked. Performs the merge of the places when the merge button is clicked.
""" """
@ -134,8 +143,10 @@ class MergePlaces:
self.p1.add_alternate_locations(l) self.p1.add_alternate_locations(l)
# remove old and commit new source # remove old and commit new source
self.db.remove_place(self.old_handle,self.trans) trans = self.db.transaction_begin()
self.db.commit_place(self.p1,self.trans)
self.db.remove_place(self.old_handle,trans)
self.db.commit_place(self.p1,trans)
# replace references in other objetcs # replace references in other objetcs
# people # people
@ -143,23 +154,23 @@ class MergePlaces:
person = self.db.get_person_from_handle(handle) person = self.db.get_person_from_handle(handle)
if person.has_handle_reference('Place',self.old_handle): if person.has_handle_reference('Place',self.old_handle):
person.replace_handle_reference('Place',self.old_handle,self.new_handle) person.replace_handle_reference('Place',self.old_handle,self.new_handle)
self.db.commit_person(person,self.trans) self.db.commit_person(person,trans)
# families # families
for handle in self.db.get_family_handles(): for handle in self.db.get_family_handles():
family = self.db.get_family_from_handle(handle) family = self.db.get_family_from_handle(handle)
if family.has_handle_reference('Place',self.old_handle): if family.has_handle_reference('Place',self.old_handle):
family.replace_handle_reference('Place',self.old_handle,self.new_handle) family.replace_handle_reference('Place',self.old_handle,self.new_handle)
self.db.commit_family(family,self.trans) self.db.commit_family(family,trans)
# events # events
for handle in self.db.get_event_handles(): for handle in self.db.get_event_handles():
event = self.db.get_event_from_handle(handle) event = self.db.get_event_from_handle(handle)
if event.has_handle_reference('Place',self.old_handle): if event.has_handle_reference('Place',self.old_handle):
event.replace_handle_reference('Place',self.old_handle,self.new_handle) event.replace_handle_reference('Place',self.old_handle,self.new_handle)
self.db.commit_event(event,self.trans) self.db.commit_event(event,trans)
self.db.transaction_commit(self.trans,_("Merge Places")) self.db.transaction_commit(trans,_("Merge Places"))
self.update() self.update()
Utils.destroy_passed_object(obj) self.close()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -212,7 +223,7 @@ class MergeSources:
self.glade.get_widget('ok').connect('clicked',self.merge) 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)
self.glade.get_widget('help').connect('clicked',self.help) self.glade.get_widget('help').connect('clicked',self.help)
self.trans = self.db.transaction_begin() trans = self.db.transaction_begin()
self.top.show() self.top.show()
def close(self,obj): def close(self,obj):

View File

@ -427,7 +427,7 @@ class ListView(BookMarkView):
DEL_MSG = "" DEL_MSG = ""
def __init__(self, title, dbstate, uistate, columns, handle_col, def __init__(self, title, dbstate, uistate, columns, handle_col,
make_model, signal_map, get_bookmarks, bm_type): make_model, signal_map, get_bookmarks, bm_type, multiple=False):
BookMarkView.__init__(self, title, dbstate, uistate, BookMarkView.__init__(self, title, dbstate, uistate,
get_bookmarks, bm_type) get_bookmarks, bm_type)
@ -440,6 +440,7 @@ class ListView(BookMarkView):
self.handle_col = handle_col self.handle_col = handle_col
self.make_model = make_model self.make_model = make_model
self.signal_map = signal_map self.signal_map = signal_map
self.multiple_selection = multiple
dbstate.connect('database-changed',self.change_db) dbstate.connect('database-changed',self.change_db)
def add_bookmark(self, obj): def add_bookmark(self, obj):
@ -503,6 +504,8 @@ class ListView(BookMarkView):
self.columns = [] self.columns = []
self.build_columns() self.build_columns()
self.selection = self.list.get_selection() self.selection = self.list.get_selection()
if self.multiple_selection:
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
self.selection.connect('changed',self.row_changed) self.selection.connect('changed',self.row_changed)
self.setup_filter() self.setup_filter()

View File

@ -16,6 +16,8 @@
<property name="skip_pager_hint">False</property> <property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property> <property name="has_separator">False</property>
<child internal-child="vbox"> <child internal-child="vbox">
@ -30,7 +32,7 @@
<property name="layout_style">GTK_BUTTONBOX_END</property> <property name="layout_style">GTK_BUTTONBOX_END</property>
<child> <child>
<widget class="GtkButton" id="button9"> <widget class="GtkButton" id="cancel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
@ -44,7 +46,7 @@
</child> </child>
<child> <child>
<widget class="GtkButton" id="button7"> <widget class="GtkButton" id="ok">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
@ -98,6 +100,10 @@
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="padding">6</property> <property name="padding">6</property>
@ -150,6 +156,10 @@
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -174,6 +184,10 @@
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -291,6 +305,8 @@
<property name="skip_pager_hint">False</property> <property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property> <property name="has_separator">False</property>
<child internal-child="vbox"> <child internal-child="vbox">
@ -388,6 +404,10 @@
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="padding">10</property> <property name="padding">10</property>
@ -555,6 +575,8 @@
<property name="skip_pager_hint">False</property> <property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property> <property name="has_separator">False</property>
<child internal-child="vbox"> <child internal-child="vbox">
@ -638,6 +660,10 @@
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -661,6 +687,10 @@
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -685,6 +715,10 @@
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">4</property> <property name="left_attach">4</property>
@ -1155,6 +1189,8 @@
<property name="skip_pager_hint">False</property> <property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property> <property name="has_separator">False</property>
<child internal-child="vbox"> <child internal-child="vbox">
@ -1237,6 +1273,10 @@
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -1258,6 +1298,10 @@
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="padding">6</property> <property name="padding">6</property>
@ -1288,6 +1332,10 @@
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -1312,6 +1360,10 @@
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>