From 79888ec6ea58c0acd8336921b350d19dd3de95f2 Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 3 Feb 2017 18:00:18 -0600 Subject: [PATCH 1/3] Add progress indication for filters with long 'prepare' times And fix DeepRelationshipPathBetween for more accurate progress And fix IsSiblingOfFilterMatch for HandleError --- .../person/_deeprelationshippathbetween.py | 4 ++-- .../person/_hascommonancestorwithfiltermatch.py | 8 ++++++++ .../rules/person/_isancestoroffiltermatch.py | 8 ++++++++ .../rules/person/_ischildoffiltermatch.py | 8 ++++++++ .../person/_isdescendantfamilyoffiltermatch.py | 8 ++++++++ .../rules/person/_isdescendantoffiltermatch.py | 8 ++++++++ .../rules/person/_isparentoffiltermatch.py | 8 ++++++++ .../rules/person/_issiblingoffiltermatch.py | 17 +++++++++++++---- 8 files changed, 63 insertions(+), 6 deletions(-) diff --git a/gramps/gen/filters/rules/person/_deeprelationshippathbetween.py b/gramps/gen/filters/rules/person/_deeprelationshippathbetween.py index d64ce4aee..5ee885433 100644 --- a/gramps/gen/filters/rules/person/_deeprelationshippathbetween.py +++ b/gramps/gen/filters/rules/person/_deeprelationshippathbetween.py @@ -106,6 +106,8 @@ def find_deep_relations(db, user, person, path, seen, target_people): if handle in seen: return [] seen.append(handle) + if user: + user.step_progress() return_paths = [] person_path = path + [handle] @@ -118,8 +120,6 @@ def find_deep_relations(db, user, person, path, seen, target_people): for family_person in family_people: pers = db.get_person_from_handle(family_person) return_paths += find_deep_relations(db, user, pers, person_path, seen, target_people) - if user: - user.step_progress() return return_paths diff --git a/gramps/gen/filters/rules/person/_hascommonancestorwithfiltermatch.py b/gramps/gen/filters/rules/person/_hascommonancestorwithfiltermatch.py index 76c640303..5b988c8cf 100644 --- a/gramps/gen/filters/rules/person/_hascommonancestorwithfiltermatch.py +++ b/gramps/gen/filters/rules/person/_hascommonancestorwithfiltermatch.py @@ -64,12 +64,20 @@ class HasCommonAncestorWithFilterMatch(HasCommonAncestorWith): self.with_people = [] filt = MatchesFilter(self.list) filt.requestprepare(db, user) + if user: + user.begin_progress(self.category, + _('Retrieving all sub-filter matches'), + db.get_number_of_people()) for handle in db.iter_person_handles(): person = db.get_person_from_handle(handle) + if user: + user.step_progress() if person and filt.apply(db, person): #store all people in the filter so as to compare later self.with_people.append(person.handle) #fill list of ancestor of person if not present yet if handle not in self.ancestor_cache: self.add_ancs(db, person) + if user: + user.end_progress() filt.requestreset() diff --git a/gramps/gen/filters/rules/person/_isancestoroffiltermatch.py b/gramps/gen/filters/rules/person/_isancestoroffiltermatch.py index 01a5c00b9..2f2b9b19e 100644 --- a/gramps/gen/filters/rules/person/_isancestoroffiltermatch.py +++ b/gramps/gen/filters/rules/person/_isancestoroffiltermatch.py @@ -62,9 +62,17 @@ class IsAncestorOfFilterMatch(IsAncestorOf): filt = MatchesFilter(self.list[0:1]) filt.requestprepare(db, user) + if user: + user.begin_progress(self.category, + _('Retrieving all sub-filter matches'), + db.get_number_of_people()) for person in db.iter_people(): + if user: + user.step_progress() if filt.apply(db, person): self.init_ancestor_list(db, person, first) + if user: + user.end_progress() filt.requestreset() def reset(self): diff --git a/gramps/gen/filters/rules/person/_ischildoffiltermatch.py b/gramps/gen/filters/rules/person/_ischildoffiltermatch.py index ca25664d0..fd34c9afb 100644 --- a/gramps/gen/filters/rules/person/_ischildoffiltermatch.py +++ b/gramps/gen/filters/rules/person/_ischildoffiltermatch.py @@ -53,9 +53,17 @@ class IsChildOfFilterMatch(Rule): self.map = set() filt = MatchesFilter(self.list) filt.requestprepare(db, user) + if user: + user.begin_progress(self.category, + _('Retrieving all sub-filter matches'), + db.get_number_of_people()) for person in db.iter_people(): + if user: + user.step_progress() if filt.apply(db, person): self.init_list(person) + if user: + user.end_progress() filt.requestreset() def reset(self): diff --git a/gramps/gen/filters/rules/person/_isdescendantfamilyoffiltermatch.py b/gramps/gen/filters/rules/person/_isdescendantfamilyoffiltermatch.py index 1e42c7756..da5a929c8 100644 --- a/gramps/gen/filters/rules/person/_isdescendantfamilyoffiltermatch.py +++ b/gramps/gen/filters/rules/person/_isdescendantfamilyoffiltermatch.py @@ -55,8 +55,16 @@ class IsDescendantFamilyOfFilterMatch(IsDescendantFamilyOf): filt = MatchesFilter(self.list[0:1]) filt.requestprepare(db, user) + if user: + user.begin_progress(self.category, + _('Retrieving all sub-filter matches'), + db.get_number_of_people()) for person in db.iter_people(): + if user: + user.step_progress() if filt.apply(db, person): self.add_matches(person) + if user: + user.end_progress() filt.requestreset() diff --git a/gramps/gen/filters/rules/person/_isdescendantoffiltermatch.py b/gramps/gen/filters/rules/person/_isdescendantoffiltermatch.py index 1bd660af0..9d63f1f04 100644 --- a/gramps/gen/filters/rules/person/_isdescendantoffiltermatch.py +++ b/gramps/gen/filters/rules/person/_isdescendantoffiltermatch.py @@ -62,9 +62,17 @@ class IsDescendantOfFilterMatch(IsDescendantOf): filt = MatchesFilter(self.list[0:1]) filt.requestprepare(db, user) + if user: + user.begin_progress(self.category, + _('Retrieving all sub-filter matches'), + db.get_number_of_people()) for person in db.iter_people(): + if user: + user.step_progress() if filt.apply(db, person): self.init_list(person, first) + if user: + user.end_progress() filt.requestreset() def reset(self): diff --git a/gramps/gen/filters/rules/person/_isparentoffiltermatch.py b/gramps/gen/filters/rules/person/_isparentoffiltermatch.py index 27126a655..ab611c91a 100644 --- a/gramps/gen/filters/rules/person/_isparentoffiltermatch.py +++ b/gramps/gen/filters/rules/person/_isparentoffiltermatch.py @@ -53,9 +53,17 @@ class IsParentOfFilterMatch(Rule): self.map = set() filt = MatchesFilter(self.list) filt.requestprepare(db, user) + if user: + user.begin_progress(self.category, + _('Retrieving all sub-filter matches'), + db.get_number_of_people()) for person in db.iter_people(): + if user: + user.step_progress() if filt.apply(db, person): self.init_list(person) + if user: + user.end_progress() filt.requestreset() def reset(self): diff --git a/gramps/gen/filters/rules/person/_issiblingoffiltermatch.py b/gramps/gen/filters/rules/person/_issiblingoffiltermatch.py index 05b240223..514c8137b 100644 --- a/gramps/gen/filters/rules/person/_issiblingoffiltermatch.py +++ b/gramps/gen/filters/rules/person/_issiblingoffiltermatch.py @@ -52,9 +52,17 @@ class IsSiblingOfFilterMatch(Rule): self.map = set() filt = MatchesFilter(self.list) filt.requestprepare(db, user) + if user: + user.begin_progress(self.category, + _('Retrieving all sub-filter matches'), + db.get_number_of_people()) for person in db.iter_people(): + if user: + user.step_progress() if filt.apply (db, person): self.init_list (person) + if user: + user.end_progress() filt.requestreset() def reset(self): @@ -67,8 +75,9 @@ class IsSiblingOfFilterMatch(Rule): if not person: return fam_id = person.get_main_parents_family_handle() - fam = self.db.get_family_from_handle(fam_id) - if fam: - self.map.update(child_ref.ref - for child_ref in fam.get_child_ref_list() + if fam_id: + fam = self.db.get_family_from_handle(fam_id) + if fam: + self.map.update( + child_ref.ref for child_ref in fam.get_child_ref_list() if child_ref and child_ref.ref != person.handle) From 705ae9075d4632be899915f02d84cbfc4977b029 Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 3 Feb 2017 18:04:17 -0600 Subject: [PATCH 2/3] Fix TreeBaseModel so that filters have correct transient parent --- gramps/gui/views/treemodels/treebasemodel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gramps/gui/views/treemodels/treebasemodel.py b/gramps/gui/views/treemodels/treebasemodel.py index b6ea8e4a2..f7127c488 100644 --- a/gramps/gui/views/treemodels/treebasemodel.py +++ b/gramps/gui/views/treemodels/treebasemodel.py @@ -587,7 +587,8 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel): self.__total += items assert not skip if dfilter: - for handle in dfilter.apply(self.db, user=User()): + for handle in dfilter.apply(self.db, + user=User(parent=self.uistate.window)): status_ppl.heartbeat() data = data_map(handle) add_func(handle, data) From 076d75eba41350ca6e241fe4c9e2a218b9429c39 Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 3 Feb 2017 18:05:08 -0600 Subject: [PATCH 3/3] Add progress indication to long running reports --- gramps/gen/plug/report/_reportbase.py | 1 + gramps/plugins/graph/gvrelgraph.py | 10 ++++++++++ gramps/plugins/textreport/indivcomplete.py | 9 +++++++++ gramps/plugins/textreport/notelinkreport.py | 8 ++++++++ 4 files changed, 28 insertions(+) diff --git a/gramps/gen/plug/report/_reportbase.py b/gramps/gen/plug/report/_reportbase.py index c6bb68930..760eaabb4 100644 --- a/gramps/gen/plug/report/_reportbase.py +++ b/gramps/gen/plug/report/_reportbase.py @@ -45,6 +45,7 @@ class Report: def __init__(self, database, options_class, user): self.database = database self.options_class = options_class + self._user = user self.doc = options_class.get_document() diff --git a/gramps/plugins/graph/gvrelgraph.py b/gramps/plugins/graph/gvrelgraph.py index 18662572f..9d216ccd1 100644 --- a/gramps/plugins/graph/gvrelgraph.py +++ b/gramps/plugins/graph/gvrelgraph.py @@ -193,8 +193,14 @@ class RelGraphReport(Report): self._db.iter_person_handles()) if len(person_handles) > 1: + if self._user: + self._user.begin_progress(_("Relationship Graph"), + _("Generating report"), + len(person_handles) * 2) self.add_persons_and_families(person_handles) self.add_child_links_to_families(person_handles) + if self._user: + self._user.end_progress() def add_child_links_to_families(self, person_handles): """ @@ -205,6 +211,8 @@ class RelGraphReport(Report): person_dict = dict([handle, 1] for handle in person_handles) for person_handle in person_handles: + if self._user: + self._user.step_progress() person = self._db.get_person_from_handle(person_handle) p_id = person.get_gramps_id() for fam_handle in person.get_parent_family_handle_list(): @@ -261,6 +269,8 @@ class RelGraphReport(Report): # so we don't do it twice families_done = {} for person_handle in person_handles: + if self._user: + self._user.step_progress() # determine per person if we use HTML style label if self.includeimg: self.use_html_output = True diff --git a/gramps/plugins/textreport/indivcomplete.py b/gramps/plugins/textreport/indivcomplete.py index a8f9f2b58..ab1d680ab 100644 --- a/gramps/plugins/textreport/indivcomplete.py +++ b/gramps/plugins/textreport/indivcomplete.py @@ -812,12 +812,21 @@ class IndivCompleteReport(Report): raise ReportError(_('Empty report'), _('You did not specify anybody')) + if self._user: + self._user.begin_progress(_("Complete Individual Report"), + _("Generating report"), + len(ind_list)) for count, person_handle in enumerate(ind_list): + if self._user: + self._user.step_progress() self.person = self._db.get_person_from_handle(person_handle) if self.person is None: continue self.family_notes_list = [] self.write_person(count) + if self._user: + self._user.end_progress() + def write_person(self, count): """ write a person """ diff --git a/gramps/plugins/textreport/notelinkreport.py b/gramps/plugins/textreport/notelinkreport.py index d0f34bc30..49c2f1fe9 100644 --- a/gramps/plugins/textreport/notelinkreport.py +++ b/gramps/plugins/textreport/notelinkreport.py @@ -98,7 +98,13 @@ class NoteLinkReport(Report): self.doc.end_row() + if self._user: + self._user.begin_progress(_("Note Link Check Report"), + _("Generating report"), + self.database.get_number_of_notes()) for note in self.database.iter_notes(): + if self._user: + self._user.step_progress() for (ldomain, ltype, lprop, lvalue) in note.get_links(): if ldomain == "gramps": tagtype = _(ltype) @@ -141,6 +147,8 @@ class NoteLinkReport(Report): self.doc.end_cell() self.doc.end_row() + if self._user: + self._user.end_progress() self.doc.end_table()