From c65b1d8259455055662c2af0ce1ad53935bd3380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Thu, 5 May 2011 08:37:54 +0000 Subject: [PATCH] 4698: Additional Source Filters svn: r17412 --- po/POTFILES.in | 15 ++++- po/POTFILES.skip | 1 + src/Filters/Rules/Repository/Makefile.am | 1 + .../Repository/_MatchesNameSubstringOf.py | 54 ++++++++++++++++ src/Filters/Rules/Repository/__init__.py | 2 + src/Filters/Rules/Source/Makefile.am | 5 +- .../Source/_HasRepositoryCallNumberRef.py | 56 ++++++++++++++++ .../Rules/Source/_MatchesRepositoryFilter.py | 64 +++++++++++++++++++ .../Rules/Source/_MatchesTitelSubstringOf.py | 54 ++++++++++++++++ src/Filters/Rules/Source/__init__.py | 8 ++- src/gui/filtereditor.py | 2 + 11 files changed, 258 insertions(+), 4 deletions(-) create mode 100644 src/Filters/Rules/Repository/_MatchesNameSubstringOf.py create mode 100644 src/Filters/Rules/Source/_HasRepositoryCallNumberRef.py create mode 100644 src/Filters/Rules/Source/_MatchesRepositoryFilter.py create mode 100644 src/Filters/Rules/Source/_MatchesTitelSubstringOf.py diff --git a/po/POTFILES.in b/po/POTFILES.in index ffa324c66..7bd5c1278 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -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 diff --git a/po/POTFILES.skip b/po/POTFILES.skip index beb079360..ff5ab4180 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -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 diff --git a/src/Filters/Rules/Repository/Makefile.am b/src/Filters/Rules/Repository/Makefile.am index 8d54903be..62d0ea383 100644 --- a/src/Filters/Rules/Repository/Makefile.am +++ b/src/Filters/Rules/Repository/Makefile.am @@ -11,6 +11,7 @@ pkgdata_PYTHON = \ _HasReferenceCountOf.py\ _HasRepo.py\ _MatchesFilter.py\ + _MatchesNameSubstringOf.py\ _RegExpIdOf.py\ _RepoPrivate.py\ __init__.py diff --git a/src/Filters/Rules/Repository/_MatchesNameSubstringOf.py b/src/Filters/Rules/Repository/_MatchesNameSubstringOf.py new file mode 100644 index 000000000..67fe080fc --- /dev/null +++ b/src/Filters/Rules/Repository/_MatchesNameSubstringOf.py @@ -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 """ + + labels = [ _('Substring:')] + name = _('Repository name containing ') + 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 diff --git a/src/Filters/Rules/Repository/__init__.py b/src/Filters/Rules/Repository/__init__.py index c7b42f5ce..8d354e8ee 100644 --- a/src/Filters/Rules/Repository/__init__.py +++ b/src/Filters/Rules/Repository/__init__.py @@ -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 ] diff --git a/src/Filters/Rules/Source/Makefile.am b/src/Filters/Rules/Source/Makefile.am index 1851291bd..5c36fcdfb 100644 --- a/src/Filters/Rules/Source/Makefile.am +++ b/src/Filters/Rules/Source/Makefile.am @@ -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 diff --git a/src/Filters/Rules/Source/_HasRepositoryCallNumberRef.py b/src/Filters/Rules/Source/_HasRepositoryCallNumberRef.py new file mode 100644 index 000000000..c3d7f3fa2 --- /dev/null +++ b/src/Filters/Rules/Source/_HasRepositoryCallNumberRef.py @@ -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 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 diff --git a/src/Filters/Rules/Source/_MatchesRepositoryFilter.py b/src/Filters/Rules/Source/_MatchesRepositoryFilter.py new file mode 100644 index 000000000..2f1113395 --- /dev/null +++ b/src/Filters/Rules/Source/_MatchesRepositoryFilter.py @@ -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 ') + 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 diff --git a/src/Filters/Rules/Source/_MatchesTitelSubstringOf.py b/src/Filters/Rules/Source/_MatchesTitelSubstringOf.py new file mode 100644 index 000000000..b9f833368 --- /dev/null +++ b/src/Filters/Rules/Source/_MatchesTitelSubstringOf.py @@ -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 """ + + labels = [ _('Substring:')] + name = _('Sources title containing ') + 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 diff --git a/src/Filters/Rules/Source/__init__.py b/src/Filters/Rules/Source/__init__.py index f1ad76b06..7cfdfa600 100644 --- a/src/Filters/Rules/Source/__init__.py +++ b/src/Filters/Rules/Source/__init__.py @@ -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 ] diff --git a/src/gui/filtereditor.py b/src/gui/filtereditor.py index 758fa2f34..6886cdf7d 100644 --- a/src/gui/filtereditor.py +++ b/src/gui/filtereditor.py @@ -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:'):