diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 71715b626..b2677a975 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,8 @@ +2005-07-05 Martin Hawlisch + * src/PeopleModel.py (calculate_data): Fix invert of search result + * src/Date.py (is_equal): Only compare text value for TEXTONLY dates. + * src/GenericFilter.py: Add new filters to search for notes + 2005-07-05 Alex Roitman * src/system_filters.xml: Remove testing contents. * src/EditPerson.py (__init__): Refresh person object from handle, diff --git a/gramps2/src/Date.py b/gramps2/src/Date.py index 80ea8fbe1..04ad5e534 100644 --- a/gramps2/src/Date.py +++ b/gramps2/src/Date.py @@ -156,12 +156,12 @@ class Date: instance IN ALL REGARDS. Needed, because the __cmp__ only looks at the sorting value, and ignores the modifiers/comments. """ - + if self.modifier == other.modifier and self.modifier == MOD_TEXTONLY: + return self.text == other.text return (self.calendar == other.calendar and self.modifier == other.modifier and self.quality == other.quality and self.dateval == other.dateval and - self.text == other.text and self.sortval == other.sortval) def __str__(self): diff --git a/gramps2/src/GenericFilter.py b/gramps2/src/GenericFilter.py index 814f10c4b..069ce6f15 100644 --- a/gramps2/src/GenericFilter.py +++ b/gramps2/src/GenericFilter.py @@ -1813,6 +1813,36 @@ class HasSourceOf(Rule): return False return person.has_source_reference( self.source_handle) +#------------------------------------------------------------------------- +# "People having notes" +#------------------------------------------------------------------------- +class HasNote(Rule): + """People having notes""" + + name = _('People having notes') + description = _("Matches people that have a note") + category = _('General filters') + + def apply(self,db,person): + return bool(person.get_note()) + +#------------------------------------------------------------------------- +# "People having notes that contain a substring" +#------------------------------------------------------------------------- +class HasNoteMatchingSubstringOf(Rule): + """People having notes containing """ + + labels = [ _('Substring:')] + name = _('People having notes containing ') + description = _("Matches people whose notes contain text matching a substring") + category = _('General filters') + + def apply(self,db,person): + n = person.get_note() + if n: + return n.find(self.list[0]) != -1 + return False + #------------------------------------------------------------------------- # # GenericFilter @@ -2086,6 +2116,8 @@ editor_rule_list = [ IsSiblingOfFilterMatch, RelationshipPathBetween, HasTextMatchingSubstringOf, + HasNote, + HasNoteMatchingSubstringOf ] #------------------------------------------------------------------------- diff --git a/gramps2/src/PeopleModel.py b/gramps2/src/PeopleModel.py index 4b9a6ac63..ef8582bc3 100644 --- a/gramps2/src/PeopleModel.py +++ b/gramps2/src/PeopleModel.py @@ -107,7 +107,10 @@ class PeopleModel(gtk.GenericTreeModel): if data_filter: keys = data_filter.apply(self.db) if self.invert_result: + handle_list = self.db.get_person_handles(sort_handles=False) + #TODO: Could be optimized by using a cursor keys = [k for k in handle_list if k not in keys] + del handle_list else: keys = self.db.get_person_handles(sort_handles=False)