Make Family muli-select remove operate like the People view
This commit is contained in:
parent
eaf0061087
commit
abbe27f53a
@ -394,14 +394,14 @@ class MultiSelectDialog(object):
|
||||
### Now do it
|
||||
if response == 1: # Cancel
|
||||
if self.cancel_func:
|
||||
self.cancel_func()
|
||||
self.cancel_func(item)
|
||||
break
|
||||
elif response == 2: # No
|
||||
if self.no_func:
|
||||
self.no_func()
|
||||
self.no_func(item)
|
||||
elif response == 3: # Yes
|
||||
if self.yes_func:
|
||||
self.yes_func()
|
||||
self.yes_func(item)
|
||||
self.top.destroy()
|
||||
|
||||
def warn(self, obj, obj2):
|
||||
|
@ -292,12 +292,14 @@ class BasePersonView(ListView):
|
||||
msg1 = self._message1_format(person)
|
||||
msg2 = self._message2_format(person)
|
||||
msg2 = "%s %s" % (msg2, data_recover_msg)
|
||||
# This gets person to delete deom self.active_person:
|
||||
QuestionDialog(msg1,
|
||||
msg2,
|
||||
_('_Delete Person'),
|
||||
self.delete_person_response)
|
||||
else:
|
||||
# Ask to delete; option to cancel, delete rest
|
||||
# This gets person to delete from parameter
|
||||
MultiSelectDialog(self._message1_format,
|
||||
self._message2_format,
|
||||
handles,
|
||||
@ -320,7 +322,7 @@ class BasePersonView(ListView):
|
||||
self.active_person = person
|
||||
return person
|
||||
|
||||
def delete_person_response(self):
|
||||
def delete_person_response(self, person=None):
|
||||
"""
|
||||
Deletes the person from the database.
|
||||
"""
|
||||
|
@ -229,18 +229,55 @@ class FamilyView(ListView):
|
||||
pass
|
||||
|
||||
def remove(self, obj):
|
||||
from gramps.gui.dialog import QuestionDialog2
|
||||
"""
|
||||
Method called when deleting a family from a family view.
|
||||
"""
|
||||
from gramps.gui.dialog import QuestionDialog, MultiSelectDialog
|
||||
from gramps.gen.utils.string import data_recover_msg
|
||||
msg = _('Deleting item will remove it from the database.')
|
||||
msg = msg + '\n' + data_recover_msg
|
||||
q = QuestionDialog2(_('Delete %s?') % _('family'), msg,
|
||||
_('_Delete Item'), _('Cancel'))
|
||||
if q.run():
|
||||
self.uistate.set_busy_cursor(True)
|
||||
list(map(self.dbstate.db.remove_family_relationships,
|
||||
self.selected_handles()))
|
||||
self.build_tree()
|
||||
self.uistate.set_busy_cursor(False)
|
||||
handles = self.selected_handles()
|
||||
if len(handles) == 1:
|
||||
family = self.dbstate.db.get_family_from_handle(handles[0])
|
||||
msg1 = self._message1_format(family)
|
||||
msg2 = self._message2_format(family)
|
||||
msg2 = "%s %s" % (msg2, data_recover_msg)
|
||||
QuestionDialog(msg1,
|
||||
msg2,
|
||||
_('_Delete Family'),
|
||||
lambda: self.delete_family_response(family))
|
||||
else:
|
||||
MultiSelectDialog(self._message1_format,
|
||||
self._message2_format,
|
||||
handles,
|
||||
self.dbstate.db.get_family_from_handle,
|
||||
yes_func=self.delete_family_response)
|
||||
|
||||
def _message1_format(self, family):
|
||||
"""
|
||||
Header format for remove dialogs.
|
||||
"""
|
||||
return _('Delete %s?') % (_('family') +
|
||||
(" [%s]" % family.gramps_id))
|
||||
|
||||
def _message2_format(self, family):
|
||||
"""
|
||||
Detailed message format for the remove dialogs.
|
||||
"""
|
||||
return _('Deleting item will remove it from the database.')
|
||||
|
||||
def delete_family_response(self, family):
|
||||
"""
|
||||
Deletes the family from the database. Callback to remove
|
||||
dialogs.
|
||||
"""
|
||||
from gramps.gen.db import DbTxn
|
||||
# set the busy cursor, so the user knows that we are working
|
||||
self.uistate.set_busy_cursor(True)
|
||||
# create the transaction
|
||||
with DbTxn('', self.dbstate.db) as trans:
|
||||
gramps_id = family.gramps_id
|
||||
self.dbstate.db.remove_family_relationships(family.handle, trans)
|
||||
trans.set_description(_("Family [%s]") % gramps_id)
|
||||
self.uistate.set_busy_cursor(False)
|
||||
|
||||
def edit(self, obj):
|
||||
for handle in self.selected_handles():
|
||||
|
Loading…
Reference in New Issue
Block a user