From aedc453452e414c0df1edc42a2fa9af29562b4c1 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sun, 26 Jan 2014 14:08:51 +0000 Subject: [PATCH] 6519: Add primary role option to event filter --- gramps/gen/filters/_filterparser.py | 3 +++ gramps/gen/filters/rules/_haseventbase.py | 3 ++- gramps/gen/filters/rules/person/_hasevent.py | 5 +++-- gramps/gui/editors/filtereditor.py | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gramps/gen/filters/_filterparser.py b/gramps/gen/filters/_filterparser.py index 8c59ff719..bebb670b6 100644 --- a/gramps/gen/filters/_filterparser.py +++ b/gramps/gen/filters/_filterparser.py @@ -167,6 +167,9 @@ class FilterParser(handler.ContentHandler): and len(self.a) == 3): self.use_regex = self.a[2] == '1' self.a = self.a[:2] + # HasEvent rule has extra primary role field in v3.4.7 + if self.r == rules.person.HasEvent and len(self.a) == 5: + self.a.append('1') #------------------------------------------------------------------------- # diff --git a/gramps/gen/filters/rules/_haseventbase.py b/gramps/gen/filters/rules/_haseventbase.py index b93cfadd8..a592fb587 100644 --- a/gramps/gen/filters/rules/_haseventbase.py +++ b/gramps/gen/filters/rules/_haseventbase.py @@ -51,7 +51,8 @@ class HasEventBase(Rule): 'Date:', 'Place:', 'Description:', - 'Main Participants' ] + 'Main Participants:', + 'Primary Role:' ] name = 'Events matching parameters' description = "Matches events with particular parameters" category = _('Event filters') diff --git a/gramps/gen/filters/rules/person/_hasevent.py b/gramps/gen/filters/rules/person/_hasevent.py index 703a71b0a..fcc1e3658 100644 --- a/gramps/gen/filters/rules/person/_hasevent.py +++ b/gramps/gen/filters/rules/person/_hasevent.py @@ -51,7 +51,8 @@ class HasEvent(HasEventBase): _('Date:'), _('Place:'), _('Description:'), - _('Main Participants') ] + _('Main Participants:'), + _('Primary Role:') ] name = _('People with the personal ') description = _("Matches people with a personal event of a particular " "value") @@ -60,7 +61,7 @@ class HasEvent(HasEventBase): for event_ref in person.get_event_ref_list(): if not event_ref: continue - if event_ref.role != EventRoleType.PRIMARY: + if int(self.list[5]) and event_ref.role != EventRoleType.PRIMARY: # Only match primaries, no witnesses continue event = dbase.get_event_from_handle(event_ref.ref) diff --git a/gramps/gui/editors/filtereditor.py b/gramps/gui/editors/filtereditor.py index 45892dbed..c5c6c11a2 100644 --- a/gramps/gui/editors/filtereditor.py +++ b/gramps/gui/editors/filtereditor.py @@ -572,6 +572,8 @@ class EditRule(ManagedWindow): elif v == _('Include Family events:'): t = MyBoolean(_('Also family events where person is ' 'wife/husband')) + elif v == _('Primary Role:'): + t = MyBoolean(_('Only include primary participants')) elif v == _('Tag:'): taglist = [''] taglist = taglist + [tag.get_name() for tag in dbstate.db.iter_tags()]