Two new filters
svn: r8868
This commit is contained in:
parent
342f60a78f
commit
dbbf63cbe4
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2007-08-25 Benny Malengier/Joachim Breitner <bm@cage.ugent.be>
|
||||
* src/Filters/Rules/Place/_MatchesEventFilter.py : new filter feature #1182
|
||||
* src/Filters/Rules/Event/_MatchesPersonFilter.py: new filter feature #1182
|
||||
* po/POTFILES.in : add new filters
|
||||
* src/Filters/Rules/_MatchesFilterBase.py : add helper function
|
||||
* src/Filters/Rules/Place/Makefile.am : add new filter
|
||||
* src/Filters/Rules/Place/__init__.py : add new filter
|
||||
* src/Filters/Rules/Event/Makefile.am : add new filter
|
||||
* src/Filters/Rules/Event/__init__.py : add new filter
|
||||
* src/FilterEditor/_EditRule.py : new custom filter widgets
|
||||
|
||||
2007-08-25 Don Allingham <don@gramps-project.org>
|
||||
* src/Config/_GrampsConfigKeys.py; Add EXPORT_NO_PRIVATE and
|
||||
EXPORT_RESTRICT
|
||||
|
@ -565,6 +565,7 @@ src/Filters/Rules/Event/_HasIdOf.py
|
||||
src/Filters/Rules/Event/_HasMarkerOf.py
|
||||
src/Filters/Rules/Event/_HasType.py
|
||||
src/Filters/Rules/Event/_HasNoteMatchingSubstringOf.py
|
||||
src/Filters/Rules/Event/_MatchesPersonFilter.py
|
||||
src/Filters/Rules/Event/__init__.py
|
||||
|
||||
# Filters.Rules.Place package
|
||||
@ -576,6 +577,7 @@ src/Filters/Rules/Place/_HasNoteRegexp.py
|
||||
src/Filters/Rules/Place/_HasPlace.py
|
||||
src/Filters/Rules/Place/_InLatLonNeighborhood.py
|
||||
src/Filters/Rules/Place/_MatchesFilter.py
|
||||
src/Filters/Rules/Place/_MatchesEventFilter.py
|
||||
src/Filters/Rules/Place/_PlacePrivate.py
|
||||
src/Filters/Rules/Place/_RegExpIdOf.py
|
||||
src/Filters/Rules/Place/__init__.py
|
||||
|
@ -433,6 +433,13 @@ class EditRule(ManagedWindow.ManagedWindow):
|
||||
elif v == _('Filter name:'):
|
||||
t = MyFilters(self.filterdb.get_filters(self.space),
|
||||
self.filter_name)
|
||||
# filters of another namespace
|
||||
elif v == _('Person filter name:'):
|
||||
t = MyFilters(self.filterdb.get_filters('Person'),
|
||||
self.filter_name)
|
||||
elif v == _('Event filter name:'):
|
||||
t = MyFilters(self.filterdb.get_filters('Event'),
|
||||
self.filter_name)
|
||||
elif _name2typeclass.has_key(v):
|
||||
t = MySelect(_name2typeclass[v])
|
||||
elif v == _('Inclusive:'):
|
||||
@ -441,6 +448,8 @@ class EditRule(ManagedWindow.ManagedWindow):
|
||||
t = MyBoolean(_('Use exact case of letters'))
|
||||
elif v == _('Regular-Expression matching:'):
|
||||
t = MyBoolean(_('Use regular expression'))
|
||||
elif v == _('Include Family events:'):
|
||||
t = MyBoolean(_('Also family events where person is wife/husband'))
|
||||
else:
|
||||
t = MyEntry()
|
||||
tlist.append(t)
|
||||
|
@ -12,6 +12,7 @@ pkgdata_PYTHON = \
|
||||
_HasMarkerOf.py\
|
||||
_HasType.py\
|
||||
_HasNoteMatchingSubstringOf.py\
|
||||
_MatchesPersonFilter.py\
|
||||
__init__.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Event
|
||||
|
90
src/Filters/Rules/Event/_MatchesPersonFilter.py
Normal file
90
src/Filters/Rules/Event/_MatchesPersonFilter.py
Normal file
@ -0,0 +1,90 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2002-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id: _MatchesFilter.py 6932 2006-06-21 16:30:35Z dallingham $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Filters
|
||||
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MatchesFilter
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MatchesPersonFilter(MatchesFilterBase):
|
||||
"""
|
||||
Rule that checks against another filter.
|
||||
|
||||
This is a base rule for subclassing by specific objects.
|
||||
Subclasses need to define the namespace class attribute.
|
||||
"""
|
||||
|
||||
labels = [_('Person filter name:'), _('Include Family events:')]
|
||||
name = _('Events of persons matching the <person filter>')
|
||||
description = _("Matches events of persons matched by the specified "
|
||||
"person filter name")
|
||||
category = _('General filters')
|
||||
# we want to have this filter show person filters
|
||||
namespace = 'Person'
|
||||
|
||||
def prepare(self,db):
|
||||
MatchesFilterBase.prepare(self, db)
|
||||
|
||||
try :
|
||||
if int(self.list[1]):
|
||||
self.MPF_famevents = True
|
||||
else:
|
||||
self.MPF_famevents = False
|
||||
except IndexError:
|
||||
self.MPF_famevents = False
|
||||
|
||||
|
||||
def apply(self,db,event):
|
||||
filt = self.find_filter()
|
||||
if filt:
|
||||
for (classname, handle) in db.find_backlink_handles(
|
||||
event.get_handle(), ['Person']):
|
||||
if filt.check(db, handle):
|
||||
return True
|
||||
if self.MPF_famevents :
|
||||
#also include if family event of the person
|
||||
for (classname, handle) in db.find_backlink_handles(
|
||||
event.get_handle(), ['Family']):
|
||||
family = db.get_family_from_handle(handle)
|
||||
if family.father_handle and filt.check(db,
|
||||
family.father_handle) :
|
||||
return True
|
||||
if family.mother_handle and filt.check(db,
|
||||
family.mother_handle) :
|
||||
return True
|
||||
|
||||
return False
|
@ -38,6 +38,7 @@ from _HasNoteRegexp import HasNoteRegexp
|
||||
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
|
||||
from _EventPrivate import EventPrivate
|
||||
from _MatchesFilter import MatchesFilter
|
||||
from _MatchesPersonFilter import MatchesPersonFilter
|
||||
|
||||
editor_rule_list = [
|
||||
AllEvents,
|
||||
@ -50,4 +51,5 @@ editor_rule_list = [
|
||||
HasNoteMatchingSubstringOf,
|
||||
EventPrivate,
|
||||
MatchesFilter,
|
||||
MatchesPersonFilter,
|
||||
]
|
||||
|
@ -11,6 +11,7 @@ pkgdata_PYTHON = \
|
||||
_HasNoteRegexp.py\
|
||||
_HasPlace.py\
|
||||
_MatchesFilter.py\
|
||||
_MatchesEventFilter.py\
|
||||
_PlacePrivate.py\
|
||||
_RegExpIdOf.py\
|
||||
__init__.py
|
||||
|
66
src/Filters/Rules/Place/_MatchesEventFilter.py
Normal file
66
src/Filters/Rules/Place/_MatchesEventFilter.py
Normal file
@ -0,0 +1,66 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2002-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id: _MatchesFilter.py 6932 2006-06-21 16:30:35Z dallingham $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Filters
|
||||
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MatchesFilter
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MatchesEventFilter(MatchesFilterBase):
|
||||
"""
|
||||
Rule that checks against another filter.
|
||||
|
||||
This is a base rule for subclassing by specific objects.
|
||||
Subclasses need to define the namespace class attribute.
|
||||
"""
|
||||
|
||||
labels = [_('Event filter name:')]
|
||||
name = _('Places of events matching the <event filter>')
|
||||
description = _("Matches places where events happened that match the "
|
||||
"specified event filter name")
|
||||
category = _('General filters')
|
||||
# we want to have this filter show event filters
|
||||
namespace = 'Event'
|
||||
|
||||
|
||||
def apply(self,db,event):
|
||||
filt = self.find_filter()
|
||||
if filt:
|
||||
for (classname, handle) in db.find_backlink_handles(event.get_handle(), ['Event']):
|
||||
if filt.check(db, handle):
|
||||
return True
|
||||
return False
|
@ -36,6 +36,7 @@ from _MatchesFilter import MatchesFilter
|
||||
from _HasPlace import HasPlace
|
||||
from _HasNoLatOrLon import HasNoLatOrLon
|
||||
from _InLatLonNeighborhood import InLatLonNeighborhood
|
||||
from _MatchesEventFilter import MatchesEventFilter
|
||||
|
||||
editor_rule_list = [
|
||||
AllPlaces,
|
||||
@ -48,4 +49,5 @@ editor_rule_list = [
|
||||
HasPlace,
|
||||
HasNoLatOrLon,
|
||||
InLatLonNeighborhood,
|
||||
MatchesEventFilter,
|
||||
]
|
||||
|
@ -87,3 +87,17 @@ class MatchesFilterBase(Rule):
|
||||
if filt.get_name() == self.list[0]:
|
||||
return filt.check(db,obj.handle)
|
||||
return False
|
||||
|
||||
def find_filter(self):
|
||||
''' helper function that can be usefull, returning the filter
|
||||
selected or None
|
||||
'''
|
||||
if Filters.SystemFilters:
|
||||
for filt in Filters.SystemFilters.get_filters(self.namespace):
|
||||
if filt.get_name() == self.list[0]:
|
||||
return filt
|
||||
if Filters.CustomFilters:
|
||||
for filt in Filters.CustomFilters.get_filters(self.namespace):
|
||||
if filt.get_name() == self.list[0]:
|
||||
return filt
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user