2006-08-07  Alex Roitman  <shura@gramps-project.org>
	* src/DataViews/_RepositoryView.py: Add filter sidebar.
	* src/FilterEditor/_ShowResults.py: Support repo filters.
	* src/FilterEditor/_EditRule.py: Support repo filters.
	* src/FilterEditor/_FilterEditor.py: Support repo filters.
	* src/Filters/_GenericFilter.py: Support repo filters.
	* src/Filters/SideBar/Makefile.am (pkgdata_PYTHON): Ship new file.
	* src/Filters/SideBar/__init__.py: Expose new module.
	* src/Filters/SideBar/_RepoSidebarFilter.py: Add module.
	* src/Filters/Rules/Repository/Makefile.am (pkgdata_PYTHON): Ship
	new files.
	* src/Filters/Rules/Repository/__init__.py: Expose new modules.
	* src/Filters/Rules/Repository/_HasRepo.py: Add module.
	* src/Filters/Rules/Repository/_RepoPrivate.py: Add module.
	* src/Filters/Rules/Repository/_RegExpIdOf.py: Add module.
	* src/Filters/Rules/Repository/_MatchesFilter.py: Add module.
	* src/Filters/Rules/Repository/_HasNoteRegexp.py: Add module.
	* src/Filters/Rules/Repository/_HasNoteMatchingSubstringOf.py: Add
	module.
	* src/Filters/Rules/Repository/_HasIdOf.py: Add module.
	* src/Filters/Rules/Repository/_AllRepos.py: Add module.

In po:
2006-08-07  Alex Roitman  <shura@gramps-project.org>
	* POTFILES.in: Add new files.



svn: r7144
This commit is contained in:
Alex Roitman 2006-08-07 20:16:00 +00:00
parent 693a413471
commit b1522eab91
21 changed files with 679 additions and 2 deletions

View File

@ -1,3 +1,25 @@
2006-08-07 Alex Roitman <shura@gramps-project.org>
* src/DataViews/_RepositoryView.py: Add filter sidebar.
* src/FilterEditor/_ShowResults.py: Support repo filters.
* src/FilterEditor/_EditRule.py: Support repo filters.
* src/FilterEditor/_FilterEditor.py: Support repo filters.
* src/Filters/_GenericFilter.py: Support repo filters.
* src/Filters/SideBar/Makefile.am (pkgdata_PYTHON): Ship new file.
* src/Filters/SideBar/__init__.py: Expose new module.
* src/Filters/SideBar/_RepoSidebarFilter.py: Add module.
* src/Filters/Rules/Repository/Makefile.am (pkgdata_PYTHON): Ship
new files.
* src/Filters/Rules/Repository/__init__.py: Expose new modules.
* src/Filters/Rules/Repository/_HasRepo.py: Add module.
* src/Filters/Rules/Repository/_RepoPrivate.py: Add module.
* src/Filters/Rules/Repository/_RegExpIdOf.py: Add module.
* src/Filters/Rules/Repository/_MatchesFilter.py: Add module.
* src/Filters/Rules/Repository/_HasNoteRegexp.py: Add module.
* src/Filters/Rules/Repository/_HasNoteMatchingSubstringOf.py: Add
module.
* src/Filters/Rules/Repository/_HasIdOf.py: Add module.
* src/Filters/Rules/Repository/_AllRepos.py: Add module.
2006-08-06 Brian Matherly <brian@gramps-project.org>
* src/plugins/DetAncestralReport.py: print children when no mother exists

View File

@ -1,3 +1,6 @@
2006-08-07 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Add new files.
2006-08-06 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Add new files.

View File

@ -545,6 +545,14 @@ src/Filters/Rules/Source/__init__.py
src/Filters/Rules/Media/__init__.py
# Filters.Rules.Repository package
src/Filters/Rules/Repository/_AllRepos.py
src/Filters/Rules/Repository/_HasIdOf.py
src/Filters/Rules/Repository/_HasNoteMatchingSubstringOf.py
src/Filters/Rules/Repository/_HasNoteRegexp.py
src/Filters/Rules/Repository/_HasRepo.py
src/Filters/Rules/Repository/_MatchesFilter.py
src/Filters/Rules/Repository/_RegExpIdOf.py
src/Filters/Rules/Repository/_RepoPrivate.py
src/Filters/Rules/Repository/__init__.py
# Filters.SideBar package
@ -554,6 +562,7 @@ src/Filters/SideBar/_PersonSidebarFilter.py
src/Filters/SideBar/_SidebarFilter.py
src/Filters/SideBar/_SourceSidebarFilter.py
src/Filters/SideBar/_PlaceSidebarFilter.py
src/Filters/SideBar/_RepoSidebarFilter.py
# FilterEditor package
src/FilterEditor/_FilterEditor.py

View File

@ -37,10 +37,13 @@ import DisplayModels
import Utils
import Bookmarks
import Errors
import const
import Config
from Editors import EditRepository, DelRepositoryQuery
from DdTargets import DdTargets
from QuestionDialog import QuestionDialog
from Filters.SideBar import RepoSidebarFilter
#-------------------------------------------------------------------------
#
@ -89,7 +92,10 @@ class RepositoryView(PageView.ListView):
column_names, len(column_names),
DisplayModels.RepositoryModel, signal_map,
dbstate.db.get_repo_bookmarks(),
Bookmarks.RepoBookmarks)
Bookmarks.RepoBookmarks,filter_class=RepoSidebarFilter)
Config.client.notify_add("/apps/gramps/interface/filter",
self.filter_toggle)
def get_bookmarks(self):
return self.dbstate.db.get_repo_bookmarks()
@ -101,6 +107,27 @@ class RepositoryView(PageView.ListView):
PageView.ListView.define_actions(self)
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self.column_editor)
self.add_action('FilterEdit', None, _('Repository Filter Editor'),
callback=self.filter_editor,)
def filter_toggle(self, client, cnxn_id, etnry, data):
if Config.get(Config.FILTER):
self.search_bar.hide()
self.filter_pane.show()
active = True
else:
self.search_bar.show()
self.filter_pane.hide()
active = False
def filter_editor(self,obj):
from FilterEditor import FilterEditor
try:
FilterEditor('Repository',const.custom_filters,
self.dbstate,self.uistate)
except Errors.WindowActiveError:
pass
def column_editor(self,obj):
import ColumnOrder
@ -138,6 +165,7 @@ class RepositoryView(PageView.ListView):
<menuitem action="Remove"/>
</placeholder>
<menuitem action="ColumnEdit"/>
<menuitem action="FilterEdit"/>
</menu>
</menubar>
<toolbar name="ToolBar">

View File

@ -377,6 +377,8 @@ class EditRule(ManagedWindow.ManagedWindow):
class_list = Rules.Source.editor_rule_list
elif self.space == 'Place':
class_list = Rules.Place.editor_rule_list
elif self.space == 'Repository':
class_list = Rules.Repository.editor_rule_list
for class_obj in class_list:
arglist = class_obj.labels

View File

@ -178,3 +178,5 @@ class FilterEditor(ManagedWindow.ManagedWindow):
return self.db.get_source_handles()
elif self.space == 'Place':
return self.db.get_place_handles()
elif self.space == 'Repository':
return self.db.get_repository_handles()

View File

@ -123,6 +123,10 @@ class ShowResults(ManagedWindow.ManagedWindow):
place = self.db.get_place_from_handle(handle)
name = place.get_title()
gid = place.get_gramps_id()
elif self.space == 'Repository':
repo = self.db.get_repository_from_handle(handle)
name = repo.get_name()
gid = repo.get_gramps_id()
return (name,gid)
def sort_val_from_handle(self, handle):
@ -142,4 +146,7 @@ class ShowResults(ManagedWindow.ManagedWindow):
elif self.space == 'Place':
name = self.db.get_place_from_handle(handle).get_title()
sortname = locale.strxfrm(name)
elif self.space == 'Repository':
name = self.db.get_repository_from_handle(handle).get_name()
sortname = locale.strxfrm(name)
return (sortname,handle)

View File

@ -3,6 +3,14 @@
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Repository
pkgdata_PYTHON = \
_AllRepos.py\
_HasIdOf.py\
_HasNoteMatchingSubstringOf.py\
_HasNoteRegexp.py\
_HasRepo.py\
_MatchesFilter.py\
_RegExpIdOf.py\
_RepoPrivate.py\
__init__.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Repository

View File

@ -0,0 +1,46 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._Everything import Everything
#-------------------------------------------------------------------------
#
# Everyone
#
#-------------------------------------------------------------------------
class AllRepos(Everything):
"""Matches Everyone"""
name = _('Every repository')
description = _('Matches every repository in the database')

View File

@ -0,0 +1,46 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules import HasGrampsId
#-------------------------------------------------------------------------
#
# HasIdOf
#
#-------------------------------------------------------------------------
class HasIdOf(HasGrampsId):
"""Rule that checks for a repo with a specific GRAMPS ID"""
name = _('Repository with <Id>')
description = _("Matches a repository with a specified GRAMPS ID")

View File

@ -0,0 +1,46 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasNoteSubstrBase import HasNoteSubstrBase
#-------------------------------------------------------------------------
# "Events having notes that contain a substring"
#-------------------------------------------------------------------------
class HasNoteMatchingSubstringOf(HasNoteSubstrBase):
"""Repos having notes containing <subtring>"""
name = _('Repositories having notes containing <substring>')
description = _("Matches repositories whose notes contain text "
"matching a substring")

View File

@ -0,0 +1,45 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasNoteRegexBase import HasNoteRegexBase
#-------------------------------------------------------------------------
# "Repos having notes that contain a substring"
#-------------------------------------------------------------------------
class HasNoteRegexp(HasNoteRegexBase):
name = _('Repositoriess having notes '
'containing <regular expression>')
description = _("Matches repositories whose notes contain text "
"matching a regular expression")

View File

@ -0,0 +1,83 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from RelLib import RepositoryType
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#
# HasEvent
#
#-------------------------------------------------------------------------
class HasRepo(Rule):
"""Rule that checks for a repo with a particular value"""
labels = [ _('Name:'),
_('Type:'),
_('Address:'),
_('URL:'),
]
name = _('Repositories matching parameters')
description = _("Matches Repositories with particular parameters")
category = _('General filters')
def apply(self,db,repo):
if not self.match_substring(0,repo.get_name()):
return False
if self.list[1]:
specified_type = RepositoryType()
specified_type.set_from_xml_str(self.list[1])
if repo.type != specified_type:
return False
addr_match = False
for addr in repo.address_list:
addr_text = addr.city + addr.state + addr.country + addr.postal \
+ addr.phone + addr.street
if not self.match_substring(2,addr_text):
continue
addr_match = True
url_match = False
for url in repo.urls:
url_text = url.path + url.desc
if not self.match_substring(3,url_text):
continue
url_match = True
return (addr_match or url_match)

View File

@ -0,0 +1,48 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
#-------------------------------------------------------------------------
#
# MatchesFilter
#
#-------------------------------------------------------------------------
class MatchesFilter(MatchesFilterBase):
"""Rule that checks against another filter"""
name = _('Repositories matching the <filter>')
description = _("Matches repositoriess macthed "
"by the specified filter name")
namespace = 'Repository'

View File

@ -0,0 +1,50 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._RegExpIdBase import RegExpIdBase
#-------------------------------------------------------------------------
#
# HasIdOf
#
#-------------------------------------------------------------------------
class RegExpIdOf(RegExpIdBase):
"""
Rule that checks for a repo whose GRAMPS ID
matches regular expression.
"""
name = _('Repositories with <Id> matching regular expression')
description = _("Matches repositories whose GRAMPS ID matches "
"the regular expression")

View File

@ -0,0 +1,44 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._IsPrivate import IsPrivate
#-------------------------------------------------------------------------
# "Repo marked private"
#-------------------------------------------------------------------------
class RepoPrivate(IsPrivate):
"""Repo marked private"""
name = _('Repositories marked private')
description = _("Matches repositories that are indicated as private")

View File

@ -25,3 +25,22 @@ Package providing filter rules for GRAMPS.
"""
__author__ = "Don Allingham"
from _AllRepos import AllRepos
from _HasIdOf import HasIdOf
from _RegExpIdOf import RegExpIdOf
from _HasNoteRegexp import HasNoteRegexp
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _RepoPrivate import RepoPrivate
from _MatchesFilter import MatchesFilter
from _HasRepo import HasRepo
editor_rule_list = [
AllRepos,
HasIdOf,
RegExpIdOf,
HasNoteRegexp,
HasNoteMatchingSubstringOf,
RepoPrivate,
MatchesFilter,
]

View File

@ -9,7 +9,8 @@ pkgdata_PYTHON = \
_SidebarFilter.py \
_PersonSidebarFilter.py\
_SourceSidebarFilter.py\
_PlaceSidebarFilter.py
_PlaceSidebarFilter.py\
_RepoSidebarFilter.py
pkgpyexecdir = @pkgpyexecdir@/Filters/SideBar
pkgpythondir = @pkgpythondir@/Filters/SideBar

View File

@ -0,0 +1,151 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# gtk
#
#-------------------------------------------------------------------------
import gtk
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import GrampsWidgets
from RelLib import Repository, RepositoryType
from _SidebarFilter import SidebarFilter
from Filters import GenericFilterFactory, build_filter_model, Rules
from Filters.Rules.Repository import *
GenericRepoFilter = GenericFilterFactory('Repository')
#-------------------------------------------------------------------------
#
# PersonSidebarFilter class
#
#-------------------------------------------------------------------------
class RepoSidebarFilter(SidebarFilter):
def __init__(self, clicked):
SidebarFilter.__init__(self)
self.clicked_func = clicked
def create_widget(self):
self.filter_id = gtk.Entry()
self.filter_title = gtk.Entry()
self.filter_address = gtk.Entry()
self.filter_url = gtk.Entry()
self.repo = Repository()
self.repo.set_type((RepositoryType.CUSTOM,''))
self.rtype = gtk.ComboBoxEntry()
self.event_menu = GrampsWidgets.MonitoredDataType(
self.rtype,
self.repo.set_type,
self.repo.get_type)
self.filter_note = gtk.Entry()
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
all = GenericRepoFilter()
all.set_name(_("None"))
all.add_rule(Rules.Repository.AllRepos([]))
self.generic = gtk.ComboBox()
cell = gtk.CellRendererText()
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.generic.set_model(build_filter_model('Repository', [all]))
self.generic.set_active(0)
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Name'), self.filter_title)
self.add_entry(_('Type'), self.rtype)
self.add_text_entry(_('Address'), self.filter_address)
self.add_text_entry(_('URL'), self.filter_url)
self.add_text_entry(_('Note'), self.filter_note)
self.add_entry(_('Custom filter'), self.generic)
self.add_entry(None, self.filter_regex)
def clear(self, obj):
self.filter_id.set_text('')
self.filter_title.set_text('')
self.filter_address.set_text('')
self.filter_url.set_text('')
self.rtype.child.set_text('')
self.filter_note.set_text('')
self.generic.set_active(0)
def clicked(self, obj):
self.clicked_func()
def get_filter(self):
gid = unicode(self.filter_id.get_text()).strip()
title = unicode(self.filter_title.get_text()).strip()
address = unicode(self.filter_address.get_text()).strip()
url = unicode(self.filter_url.get_text()).strip()
rtype = self.repo.get_type().xml_str()
note = unicode(self.filter_note.get_text()).strip()
regex = self.filter_regex.get_active()
gen = self.generic.get_active() > 0
empty = not (gid or title or address or url or rtype
or note or regex or gen)
if empty:
generic_filter = None
else:
generic_filter = GenericRepoFilter()
if gid:
if regex:
rule = RegExpIdOf([gid])
else:
rule = HasIdOf([gid])
generic_filter.add_rule(rule)
rule = HasRepo([title,rtype,address,url])
generic_filter.add_rule(rule)
if note:
if regex:
rule = HasNoteRegexp([note])
else:
rule = HasNoteMatchingSubstringOf([note])
generic_filter.add_rule(rule)
if self.generic.get_active() != 0:
model = self.generic.get_model()
iter = self.generic.get_active_iter()
obj = model.get_value(iter, 0)
rule = MatchesFilter([obj])
generic_filter.add_rule(rule)
return generic_filter

View File

@ -32,3 +32,4 @@ from _FamilySidebarFilter import FamilySidebarFilter
from _EventSidebarFilter import EventSidebarFilter
from _SourceSidebarFilter import SourceSidebarFilter
from _PlaceSidebarFilter import PlaceSidebarFilter
from _RepoSidebarFilter import RepoSidebarFilter

View File

@ -260,6 +260,20 @@ class GenericPlaceFilter(GenericFilter):
def find_from_handle(self, db, handle):
return db.get_place_from_handle(handle)
class GenericRepoFilter(GenericFilter):
def __init__(self, source=None):
GenericFilter.__init__(self, source)
def get_cursor(db, self):
return db.get_repository_cursor()
def make_obj(self):
return RelLib.Repository()
def find_from_handle(self, db, handle):
return db.get_repository_from_handle(handle)
def GenericFilterFactory(namespace):
if namespace == 'Person':
@ -272,3 +286,5 @@ def GenericFilterFactory(namespace):
return GenericSourceFilter
elif namespace == 'Place':
return GenericPlaceFilter
elif namespace == 'Repository':
return GenericRepoFilter