From 31bf3edf17e0bf7728ad67330394bf132b36ed09 Mon Sep 17 00:00:00 2001 From: prculley Date: Tue, 14 Jan 2020 09:03:18 -0600 Subject: [PATCH] Faster Multiple Person Delete --- gramps/gui/dialog.py | 6 +++++- gramps/plugins/lib/libpersonview.py | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/gramps/gui/dialog.py b/gramps/gui/dialog.py index 53def5a78..ec2596e3f 100644 --- a/gramps/gui/dialog.py +++ b/gramps/gui/dialog.py @@ -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 diff --git a/gramps/plugins/lib/libpersonview.py b/gramps/plugins/lib/libpersonview.py index 84c7bde32..982beecd5 100644 --- a/gramps/plugins/lib/libpersonview.py +++ b/gramps/plugins/lib/libpersonview.py @@ -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.