4698: Additional Source Filters

svn: r17412
This commit is contained in:
Jérôme Rapinat 2011-05-05 08:37:54 +00:00
parent 622d04afd7
commit c65b1d8259
11 changed files with 258 additions and 4 deletions

View File

@ -319,6 +319,9 @@ src/plugins/lib/libplugins.gpr.py
src/plugins/lib/libtranslate.py
src/plugins/lib/libtreebase.py
src/plugins/lib/holidays.xml.in
src/plugins/lib/maps/constants.py
src/plugins/lib/maps/geography.py
src/plugins/lib/maps/grampsmaps.py
# plugins/mapservices directory
src/plugins/mapservices/eniroswedenmap.py
@ -396,10 +399,14 @@ src/plugins/view/eventview.py
src/plugins/view/familyview.py
src/plugins/view/fanchartview.py
src/plugins/view/fanchartview.gpr.py
src/plugins/view/geoview.py
src/plugins/view/geoview.gpr.py
src/plugins/view/geography.gpr.py
src/plugins/view/geoevents.py
src/plugins/view/geofamily.py
src/plugins/view/geoperson.py
src/plugins/view/geoplaces.py
src/plugins/view/grampletview.py
src/plugins/view/htmlrenderer.py
src/plugins/view/htmlrenderer.gpr.py
src/plugins/view/mediaview.py
src/plugins/view/noteview.py
src/plugins/view/pedigreeview.py
@ -592,8 +599,11 @@ src/Filters/Rules/Source/_HasNoteRegexp.py
src/Filters/Rules/Source/_HasNoteMatchingSubstringOf.py
src/Filters/Rules/Source/_HasReferenceCountOf.py
src/Filters/Rules/Source/_HasRepository.py
src/Filters/Rules/Source/_HasRepositoryCallNumberRef.py
src/Filters/Rules/Source/_HasSource.py
src/Filters/Rules/Source/_MatchesFilter.py
src/Filters/Rules/Source/_MatchesRepositoryFilter.py
src/Filters/Rules/Source/_MatchesTitleSubstringOf.py
src/Filters/Rules/Source/_SourcePrivate.py
src/Filters/Rules/Source/_RegExpIdOf.py
@ -620,6 +630,7 @@ src/Filters/Rules/Repository/_HasNoteRegexp.py
src/Filters/Rules/Repository/_HasReferenceCountOf.py
src/Filters/Rules/Repository/_HasRepo.py
src/Filters/Rules/Repository/_MatchesFilter.py
src/Filters/Rules/Repository/_MatchesNameSubstringOf.py
src/Filters/Rules/Repository/_RegExpIdOf.py
src/Filters/Rules/Repository/_RepoPrivate.py

View File

@ -262,6 +262,7 @@ src/gui/widgets/styledtextbuffer.py
src/gui/widgets/undoablestyledbuffer.py
# gui qt
src/guiQML/grampsqml.py
src/guiQML/viewmanager.py
src/guiQML/views/centralview.py
src/guiQML/views/personview.py

View File

@ -11,6 +11,7 @@ pkgdata_PYTHON = \
_HasReferenceCountOf.py\
_HasRepo.py\
_MatchesFilter.py\
_MatchesNameSubstringOf.py\
_RegExpIdOf.py\
_RepoPrivate.py\
__init__.py

View File

@ -0,0 +1,54 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2011 Helge Herz
#
# 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: $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules import Rule
#-------------------------------------------------------------------------
# "Repositories having a name that contain a substring"
#-------------------------------------------------------------------------
class MatchesNameSubstringOf(Rule):
"""Repository name containing <substring>"""
labels = [ _('Substring:')]
name = _('Repository name containing <substring>')
description = _("Matches repositories with name contains text\n"
"matching a substring")
category = _('General filters')
def apply(self, db, repository):
""" Apply the filter """
name = repository.get_name()
if name.upper().find(self.list[0].upper()) != -1:
return True
return False

View File

@ -34,6 +34,7 @@ from _RepoPrivate import RepoPrivate
from _MatchesFilter import MatchesFilter
from _HasRepo import HasRepo
from _ChangedSince import ChangedSince
from _MatchesNameSubstringOf import MatchesNameSubstringOf
editor_rule_list = [
AllRepos,
@ -45,4 +46,5 @@ editor_rule_list = [
RepoPrivate,
MatchesFilter,
ChangedSince,
MatchesNameSubstringOf
]

View File

@ -16,7 +16,10 @@ pkgdata_PYTHON = \
_HasNote.py \
_HasNoteRegexp.py\
_HasRepository.py\
__init__.py
__init__.py\
_MatchesTitleSubstringOf.py\
_HasRepositoryCallNumberRef.py\
_MatchesRepositoryFilter.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Source
pkgpythondir = @pkgpythondir@/Filters/Rules/Source

View File

@ -0,0 +1,56 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2011 Helge Herz
#
# 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
#
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules import Rule
#-------------------------------------------------------------------------
# "Sources which reference repositories by a special Call Name"
#-------------------------------------------------------------------------
class HasRepositoryCallNumberRef(Rule):
"""Sources which reference repositories by a special Call Number"""
labels = [ _('Substring:')]
name = _('Sources with repository reference containing <substring> in "Call Number"')
description = _("Matches sources with a repository reference\n"
"containing a substring in \"Call Number\"")
category = _('General filters')
def apply(self, db, obj):
count = len(obj.get_reporef_list())
if count > 0:
for RepoRef in obj.get_reporef_list():
if len(RepoRef.call_number) > 0:
CallNumb = RepoRef.call_number
if CallNumb.upper().find(self.list[0].upper()) != -1:
return True
return False

View File

@ -0,0 +1,64 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2011 Benny Malengier
#
# 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
#
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules import MatchesFilterBase
#-------------------------------------------------------------------------
# "Sources which reference a repository by selection"
#-------------------------------------------------------------------------
class MatchesRepositoryFilter(MatchesFilterBase):
"""Sources which reference the selected repository"""
labels = [ _('Repository filter name:') ]
name = _('Sources with repository reference matching the <repository filter>')
description = _("Matches sources with a repository reference that match a certain\n")
"repository filter")
category = _('General filters')
# we want to have this filter show repository filters
namespace = 'Repository'
def prepare(self, db):
MatchesFilterBase.prepare(self, db)
self.MRF_filt = self.find_filter()
def apply(self, db, object):
if self.MRF_filt is None :
return False
repolist = [x.ref for x in object.get_reporef_list()]
for repohandle in repolist:
#check if repo in repository filter
if self.MRF_filt.check(db, repohandle):
return True
return False

View File

@ -0,0 +1,54 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2011 Helge Herz
#
# 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: $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules import Rule
#-------------------------------------------------------------------------
# "Sources having a title that contain a substring"
#-------------------------------------------------------------------------
class MatchesTitleSubstringOf(Rule):
"""Source title containing <substring>"""
labels = [ _('Substring:')]
name = _('Sources title containing <substring>')
description = _("Matches sources with title contains text\n"
"matching a substring")
category = _('General filters')
def apply(self, db, source):
""" Apply the filter """
title = source.get_title()
if title.upper().find(self.list[0].upper()) != -1:
return True
return False

View File

@ -38,6 +38,9 @@ from _MatchesFilter import MatchesFilter
from _HasSource import HasSource
from _ChangedSince import ChangedSince
from _HasRepository import HasRepository
from _MatchesTitelSubstringOf import MatchesTitleSubstringOf
from _HasRepositoryCallNumberRef import HasRepositoryCallNumberRef
from _MatchesRepositoryFilter import MatchesRepositoryFilter
editor_rule_list = [
AllSources,
@ -51,5 +54,8 @@ editor_rule_list = [
SourcePrivate,
MatchesFilter,
ChangedSince,
HasRepository
HasRepository,
MatchesTitleSubstringOf,
HasRepositoryCallNumberRef,
MatchesRepositoryFilter
]

View File

@ -523,6 +523,8 @@ class EditRule(ManagedWindow.ManagedWindow):
t = MyFilters(self.filterdb.get_filters('Event'))
elif v == _('Source filter name:'):
t = MyFilters(self.filterdb.get_filters('Source'))
elif v == _('Repository filter name:'):
t = MyFilters(self.filterdb.get_filters('Repository'))
elif v in _name2typeclass:
t = MySelect(_name2typeclass[v])
elif v == _('Inclusive:'):