* src/GenericFilter.py (IsBookmarked,IncompleteNames,
HaveAltFamilies,HavePhotos,HaveChildren,NeverMarried, MultipleMarriages,NoBirthdate): Add filter rules. * src/gramps_main.py (init_filters): Add new filters to the menu. svn: r4156
This commit is contained in:
parent
bba3da4d8d
commit
e3edfe4525
@ -1,3 +1,9 @@
|
||||
2005-03-10 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||
* src/GenericFilter.py (IsBookmarked,IncompleteNames,
|
||||
HaveAltFamilies,HavePhotos,HaveChildren,NeverMarried,
|
||||
MultipleMarriages,NoBirthdate): Add filter rules.
|
||||
* src/gramps_main.py (init_filters): Add new filters to the menu.
|
||||
|
||||
2005-03-09 Don Allingham <don@gramps-project.org>
|
||||
* src/ChooseParents.py: Fix widget sensitivity problem, assign
|
||||
integer value instead of string to relationship type
|
||||
|
@ -313,6 +313,30 @@ class IsDefaultPerson(Rule):
|
||||
return p_id == person.get_handle()
|
||||
return false
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# IsBookmarked
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class IsBookmarked(Rule):
|
||||
"""Rule that checks for the bookmark list in the database"""
|
||||
|
||||
labels = []
|
||||
|
||||
def name(self):
|
||||
return 'Is bookmarked person'
|
||||
|
||||
def description(self):
|
||||
return _("Matches the people on the bookmark list")
|
||||
|
||||
def category(self):
|
||||
return _('General filters')
|
||||
|
||||
def apply(self,db,p_id):
|
||||
if p_id in db.get_bookmarks():
|
||||
return 1
|
||||
return 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasCompleteRecord
|
||||
@ -1410,6 +1434,34 @@ class SearchName(Rule):
|
||||
n = NameDisplay.displayer.display(p)
|
||||
return self.f and n.upper().find(self.f.upper()) != -1
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# IncompleteNames
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class IncompleteNames(Rule):
|
||||
"""People with incomplete names"""
|
||||
|
||||
labels = []
|
||||
|
||||
def name(self):
|
||||
return 'People with incomplete names'
|
||||
|
||||
def description(self):
|
||||
return _("Matches people with firstname or lastname missing")
|
||||
|
||||
def category(self):
|
||||
return _('General filters')
|
||||
|
||||
def apply(self,db,p_id):
|
||||
p = db.get_person_from_handle(p_id)
|
||||
for name in [p.get_primary_name()] + p.get_alternate_names():
|
||||
if name.get_first_name() == "":
|
||||
return 1
|
||||
if name.get_surname() == "":
|
||||
return 1
|
||||
return 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MatchesFilter
|
||||
@ -1466,6 +1518,162 @@ class IsSpouseOfFilterMatch(Rule):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "People who were adopted"
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
class HaveAltFamilies(Rule):
|
||||
"""People who were adopted"""
|
||||
|
||||
labels = []
|
||||
|
||||
def name(self):
|
||||
return 'People who were adopted'
|
||||
|
||||
def description(self):
|
||||
return _("Matches person who were adopted")
|
||||
|
||||
def category(self):
|
||||
return _('Family filters')
|
||||
|
||||
|
||||
def apply(self,db,p_id):
|
||||
p = db.get_person_from_handle(p_id)
|
||||
for (fam,rel1,rel2) in p.get_parent_family_handle_list():
|
||||
if rel1 == RelLib.Person.CHILD_REL_ADOPT or rel2 == RelLib.Person.CHILD_REL_ADOPT:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "People who have images"
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
class HavePhotos(Rule):
|
||||
"""People who have images"""
|
||||
|
||||
labels = []
|
||||
|
||||
def name(self):
|
||||
return 'People who have images'
|
||||
|
||||
def description(self):
|
||||
return _("Matches person who have images in the gallery")
|
||||
|
||||
def category(self):
|
||||
return _('General filters')
|
||||
|
||||
|
||||
def apply(self,db,p_id):
|
||||
p = db.get_person_from_handle(p_id)
|
||||
return len( p.get_media_list()) > 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "People with children"
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
class HaveChildren(Rule):
|
||||
"""People with children"""
|
||||
|
||||
labels = []
|
||||
|
||||
def name(self):
|
||||
return 'People with children'
|
||||
|
||||
def description(self):
|
||||
return _("Matches persons who have children")
|
||||
|
||||
def category(self):
|
||||
return _('Family filters')
|
||||
|
||||
|
||||
def apply(self,db,p_id):
|
||||
p = db.get_person_from_handle(p_id)
|
||||
for (family_handle,rel1,rel2) in p.get_parent_family_handle_list():
|
||||
family = db.get_family_from_handle(family_handle)
|
||||
return len(family.get_child_handle_list()) > 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "People with no marriage records"
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
class NeverMarried(Rule):
|
||||
"""People with no marriage records"""
|
||||
|
||||
labels = []
|
||||
|
||||
def name(self):
|
||||
return 'People with no marriage records'
|
||||
|
||||
def description(self):
|
||||
return _("Matches persons who have have no spouse")
|
||||
|
||||
def category(self):
|
||||
return _('Family filters')
|
||||
|
||||
|
||||
def apply(self,db,p_id):
|
||||
p = db.get_person_from_handle(p_id)
|
||||
return len(p.get_family_handle_list()) == 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "People with multiple marriage records"
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
class MultipleMarriages(Rule):
|
||||
"""People with multiple marriage records"""
|
||||
|
||||
labels = []
|
||||
|
||||
def name(self):
|
||||
return 'People with multiple marriage records'
|
||||
|
||||
def description(self):
|
||||
return _("Matches persons who have more than one spouse")
|
||||
|
||||
def category(self):
|
||||
return _('Family filters')
|
||||
|
||||
|
||||
def apply(self,db,p_id):
|
||||
p = db.get_person_from_handle(p_id)
|
||||
return len(p.get_family_handle_list()) > 1
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "People without a birth date"
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
class NoBirthdate(Rule):
|
||||
"""People without a birth date"""
|
||||
|
||||
labels = []
|
||||
|
||||
def name(self):
|
||||
return 'People without a birth date'
|
||||
|
||||
def description(self):
|
||||
return _("Matches persons without a birthdate")
|
||||
|
||||
def category(self):
|
||||
return _('General filters')
|
||||
|
||||
|
||||
def apply(self,db,p_id):
|
||||
p = db.get_person_from_handle(p_id)
|
||||
birth_handle = p.get_birth_handle()
|
||||
if not birth_handle:
|
||||
return 1
|
||||
birth = db.get_event_from_handle(birth_handle)
|
||||
if not birth.get_date_object():
|
||||
return 1
|
||||
return 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GenericFilter
|
||||
@ -1602,6 +1810,7 @@ class GenericFilter:
|
||||
tasks = {
|
||||
unicode(_("Everyone")) : Everyone,
|
||||
unicode(_("Is default person")) : IsDefaultPerson,
|
||||
unicode(_("Is bookmarked person")) : IsBookmarked,
|
||||
unicode(_("Has the Id")) : HasIdOf,
|
||||
unicode(_("Has a name")) : HasNameOf,
|
||||
unicode(_("Has the relationships")) : HasRelationship,
|
||||
@ -1636,6 +1845,15 @@ tasks = {
|
||||
unicode(_("Is spouse of filter match")) : IsSpouseOfFilterMatch,
|
||||
unicode(_("Is a sibling of filter match")) : IsSiblingOfFilterMatch,
|
||||
unicode(_("Relationship path between two people")) : RelationshipPathBetween,
|
||||
|
||||
unicode(_("People who were adopted")) : HaveAltFamilies,
|
||||
unicode(_("People who have images")) : HavePhotos,
|
||||
unicode(_("People with children")) : HaveChildren,
|
||||
unicode(_("People with incomplete names")) : IncompleteNames,
|
||||
unicode(_("People with no marriage records")) : NeverMarried,
|
||||
unicode(_("People with multiple marriage records")): MultipleMarriages,
|
||||
unicode(_("People without a birth date")) : NoBirthdate,
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -887,6 +887,41 @@ class Gramps:
|
||||
all.add_rule(GenericFilter.SearchName([]))
|
||||
filter_list.append(all)
|
||||
|
||||
all = GenericFilter.GenericFilter()
|
||||
all.set_name(_("People who were adopted"))
|
||||
all.add_rule(GenericFilter.HaveAltFamilies([]))
|
||||
filter_list.append(all)
|
||||
|
||||
all = GenericFilter.GenericFilter()
|
||||
all.set_name(_("People who have images"))
|
||||
all.add_rule(GenericFilter.HavePhotos([]))
|
||||
filter_list.append(all)
|
||||
|
||||
all = GenericFilter.GenericFilter()
|
||||
all.set_name(_("People with incomplete names"))
|
||||
all.add_rule(GenericFilter.IncompleteNames([]))
|
||||
filter_list.append(all)
|
||||
|
||||
all = GenericFilter.GenericFilter()
|
||||
all.set_name(_("People with children"))
|
||||
all.add_rule(GenericFilter.HaveChildren([]))
|
||||
filter_list.append(all)
|
||||
|
||||
all = GenericFilter.GenericFilter()
|
||||
all.set_name(_("People with no marriage records"))
|
||||
all.add_rule(GenericFilter.NeverMarried([]))
|
||||
filter_list.append(all)
|
||||
|
||||
all = GenericFilter.GenericFilter()
|
||||
all.set_name(_("People without a birth date"))
|
||||
all.add_rule(GenericFilter.NoBirthdate([]))
|
||||
filter_list.append(all)
|
||||
|
||||
all = GenericFilter.GenericFilter()
|
||||
all.set_name(_("People with multiple marriage records"))
|
||||
all.add_rule(GenericFilter.MultipleMarriages([]))
|
||||
filter_list.append(all)
|
||||
|
||||
self.filter_model = GenericFilter.FilterStore(filter_list)
|
||||
self.filter_list.set_model(self.filter_model)
|
||||
self.filter_list.set_active(self.filter_model.default_index())
|
||||
|
Loading…
Reference in New Issue
Block a user