Faster Multiple Person Delete

This commit is contained in:
prculley 2020-01-14 09:03:18 -06:00 committed by Paul Culley
parent 1ce63261c3
commit 31bf3edf17
2 changed files with 30 additions and 1 deletions

View File

@ -440,7 +440,7 @@ class MissingMediaDialog:
class MultiSelectDialog:
def __init__(self, msg1_func, msg2_func, items, lookup,
cancel_func=None, no_func=None, yes_func=None,
parent=None):
multi_yes_func=None, parent=None):
"""
"""
self.xml = Glade(toplevel='multiselectdialog')
@ -489,6 +489,10 @@ class MultiSelectDialog:
response = self.top.run()
if check_button.get_active():
# run the multiple yes if 'do remainder' is checked
if multi_yes_func and response == 3:
multi_yes_func(items)
break
default_action = response
else:
response = default_action

View File

@ -462,6 +462,7 @@ class BasePersonView(ListView):
handles,
self._lookup_person,
yes_func=self.delete_person_response,
multi_yes_func=self.delete_multi_person_response,
parent=self.uistate.window)
def _message1_format(self, person):
@ -502,6 +503,30 @@ class BasePersonView(ListView):
self.uistate.set_busy_cursor(False)
def delete_multi_person_response(self, handles=None):
"""
Deletes multiple persons from the database.
"""
# set the busy cursor, so the user knows that we are working
self.uistate.set_busy_cursor(True)
self.uistate.progress.show()
self.uistate.push_message(self.dbstate, _("Processing..."))
hndl_cnt = len(handles) / 100
self.dbstate.db.disable_signals()
# create the transaction
with DbTxn('', self.dbstate.db) as trans:
for (indx, handle) in enumerate(handles):
person = self.dbstate.db.get_person_from_handle(handle)
self.dbstate.db.delete_person_from_database(person, trans)
self.uistate.pulse_progressbar(indx / hndl_cnt)
trans.set_description(_("Multiple Selection Delete"))
self.dbstate.db.enable_signals()
self.dbstate.db.request_rebuild()
self.uistate.progress.hide()
self.uistate.set_busy_cursor(False)
def remove_object_from_handle(self, handle):
"""
The remove_selected_objects method is not called in this view.