* 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


svn: r4903
This commit is contained in:
Martin Hawlisch 2005-07-05 21:15:05 +00:00
parent 139ae5c305
commit 47922e7be9
4 changed files with 42 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2005-07-05 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* 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 <shura@gramps-project.org>
* src/system_filters.xml: Remove testing contents.
* src/EditPerson.py (__init__): Refresh person object from handle,

View File

@ -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):

View File

@ -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 <subtring>"""
labels = [ _('Substring:')]
name = _('People having notes containing <subtring>')
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
]
#-------------------------------------------------------------------------

View File

@ -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)