* src/Filters/_GenericFilter.py: Add GenericNoteFilter
* src/Filters/Rules/Makefile.am: Add new Note subfolder * src/Filters/Rules/Note/*: Added new files * src/Filters/SideBar/_NoteSidebarFilter.py: New file * src/Filters/SideBar/Makefile.am: Add NoteSidebarFilter * src/Filters/SideBar/__init__.py: Add NoteSidebarFilter * src/DataViews/_NoteView.py: Enable NoteSidebarFilter * po/POTFILES.in: Add the new files * configure.in: Add new subfolder svn: r8226
This commit is contained in:
parent
0e92d73447
commit
609bfbc9eb
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2007-02-24 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||
* src/Filters/_GenericFilter.py: Add GenericNoteFilter
|
||||
* src/Filters/Rules/Makefile.am: Add new Note subfolder
|
||||
* src/Filters/Rules/Note/*: Added new files
|
||||
* src/Filters/SideBar/_NoteSidebarFilter.py: New file
|
||||
* src/Filters/SideBar/Makefile.am: Add NoteSidebarFilter
|
||||
* src/Filters/SideBar/__init__.py: Add NoteSidebarFilter
|
||||
* src/DataViews/_NoteView.py: Enable NoteSidebarFilter
|
||||
* po/POTFILES.in: Add the new files
|
||||
* configure.in: Add new subfolder
|
||||
|
||||
2007-02-23 Don Allingham <don@gramps-project.org>
|
||||
* src/GrampsDbUtils./_GedcomParse.py: enhanced parsing based off testcases
|
||||
* src/GrampsDbUtils./_GedcomTokens.py: enhanced parsing based off testcases
|
||||
|
@ -220,6 +220,7 @@ src/Filters/Rules/Source/Makefile
|
||||
src/Filters/Rules/Place/Makefile
|
||||
src/Filters/Rules/MediaObject/Makefile
|
||||
src/Filters/Rules/Repository/Makefile
|
||||
src/Filters/Rules/Note/Makefile
|
||||
src/Filters/SideBar/Makefile
|
||||
src/DataViews/Makefile
|
||||
src/BasicUtils/Makefile
|
||||
|
@ -582,6 +582,17 @@ src/Filters/Rules/Repository/_RegExpIdOf.py
|
||||
src/Filters/Rules/Repository/_RepoPrivate.py
|
||||
src/Filters/Rules/Repository/__init__.py
|
||||
|
||||
# Filters.Rules.Note package
|
||||
src/Filters/Rules/Note/_AllNotes.py
|
||||
src/Filters/Rules/Note/_HasIdOf.py
|
||||
src/Filters/Rules/Note/_HasNoteMatchingSubstringOf.py
|
||||
src/Filters/Rules/Note/_HasNoteRegexp.py
|
||||
src/Filters/Rules/Note/_HasNote.py
|
||||
src/Filters/Rules/Note/_MatchesFilter.py
|
||||
src/Filters/Rules/Note/_RegExpIdOf.py
|
||||
src/Filters/Rules/Note/_NotePrivate.py
|
||||
src/Filters/Rules/Note/__init__.py
|
||||
|
||||
# Filters.SideBar package
|
||||
src/Filters/SideBar/_EventSidebarFilter.py
|
||||
src/Filters/SideBar/_FamilySidebarFilter.py
|
||||
@ -591,6 +602,7 @@ src/Filters/SideBar/_SourceSidebarFilter.py
|
||||
src/Filters/SideBar/_PlaceSidebarFilter.py
|
||||
src/Filters/SideBar/_MediaSidebarFilter.py
|
||||
src/Filters/SideBar/_RepoSidebarFilter.py
|
||||
src/Filters/SideBar/_NoteSidebarFilter.py
|
||||
|
||||
# FilterEditor package
|
||||
src/FilterEditor/_FilterEditor.py
|
||||
|
@ -47,7 +47,7 @@ import Bookmarks
|
||||
import Config
|
||||
from DdTargets import DdTargets
|
||||
from QuestionDialog import QuestionDialog, ErrorDialog
|
||||
from Filters.SideBar import PlaceSidebarFilter
|
||||
from Filters.SideBar import NoteSidebarFilter
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -93,6 +93,7 @@ class NoteView(PageView.ListView):
|
||||
len(column_names), DisplayModels.NoteModel, signal_map,
|
||||
dbstate.db.get_place_bookmarks(),
|
||||
Bookmarks.NoteBookmarks,
|
||||
filter_class=NoteSidebarFilter,
|
||||
multiple=False)
|
||||
|
||||
Config.client.notify_add("/apps/gramps/interface/filter",
|
||||
|
@ -1,6 +1,6 @@
|
||||
# This is the src/Filters/Rules level Makefile for Gramps
|
||||
|
||||
SUBDIRS = Person Family Event Place Source MediaObject Repository
|
||||
SUBDIRS = Person Family Event Place Source MediaObject Repository Note
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules
|
||||
|
||||
|
26
src/Filters/Rules/Note/Makefile.am
Normal file
26
src/Filters/Rules/Note/Makefile.am
Normal file
@ -0,0 +1,26 @@
|
||||
# This is the src/Filters/Rules/Note level Makefile for Gramps
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Note
|
||||
|
||||
pkgdata_PYTHON = \
|
||||
_AllNotes.py\
|
||||
_HasIdOf.py\
|
||||
_HasNoteMatchingSubstringOf.py\
|
||||
_HasNoteRegexp.py\
|
||||
_HasNote.py\
|
||||
_MatchesFilter.py\
|
||||
_RegExpIdOf.py\
|
||||
_NotePrivate.py\
|
||||
__init__.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Note
|
||||
pkgpythondir = @pkgpythondir@/Filters/Rules/Note
|
||||
|
||||
# Clean up all the byte-compiled files
|
||||
MOSTLYCLEANFILES = *pyc *pyo
|
||||
|
||||
GRAMPS_PY_MODPATH = "../../../"
|
||||
|
||||
pycheck:
|
||||
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
|
||||
pychecker $(pkgdata_PYTHON));
|
46
src/Filters/Rules/Note/_AllNotes.py
Normal file
46
src/Filters/Rules/Note/_AllNotes.py
Normal 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: _AllRepos.py 7144 2006-08-07 20:16:00Z rshura $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._Everything import Everything
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Everyone
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class AllNotes(Everything):
|
||||
"""Matches every note"""
|
||||
|
||||
name = _('Every note')
|
||||
description = _('Matches every note in the database')
|
46
src/Filters/Rules/Note/_HasIdOf.py
Normal file
46
src/Filters/Rules/Note/_HasIdOf.py
Normal 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: _HasIdOf.py 7144 2006-08-07 20:16:00Z rshura $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules import HasGrampsId
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasIdOf
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class HasIdOf(HasGrampsId):
|
||||
"""Rule that checks for a note with a specific GRAMPS ID"""
|
||||
|
||||
name = _('Note with <Id>')
|
||||
description = _("Matches a note with a specified GRAMPS ID")
|
64
src/Filters/Rules/Note/_HasNote.py
Normal file
64
src/Filters/Rules/Note/_HasNote.py
Normal file
@ -0,0 +1,64 @@
|
||||
#
|
||||
# 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: _HasRepo.py 7737 2006-11-30 20:30:28Z rshura $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from RelLib import NoteType
|
||||
from Filters.Rules._Rule import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasEvent
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class HasNote(Rule):
|
||||
"""Rule that checks for a note with a particular value"""
|
||||
|
||||
|
||||
labels = [ _('Text:'),
|
||||
_('Type:'),
|
||||
]
|
||||
name = _('Notes matching parameters')
|
||||
description = _("Matches Notes with particular parameters")
|
||||
category = _('General filters')
|
||||
|
||||
def apply(self,db,note):
|
||||
if not self.match_substring(0,note.get()):
|
||||
return False
|
||||
|
||||
if self.list[1]:
|
||||
specified_type = NoteType()
|
||||
specified_type.set_from_xml_str(self.list[1])
|
||||
if note.type != specified_type:
|
||||
return False
|
||||
|
||||
return True
|
45
src/Filters/Rules/Note/_HasNoteMatchingSubstringOf.py
Normal file
45
src/Filters/Rules/Note/_HasNoteMatchingSubstringOf.py
Normal 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: _HasNoteMatchingSubstringOf.py 7144 2006-08-07 20:16:00Z rshura $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# 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):
|
||||
"""Notes having notes containing <subtring>"""
|
||||
|
||||
name = _('Notes having notes containing <substring>')
|
||||
description = _("Matches notes whose notes contain text "
|
||||
"matching a substring")
|
45
src/Filters/Rules/Note/_HasNoteRegexp.py
Normal file
45
src/Filters/Rules/Note/_HasNoteRegexp.py
Normal 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: _HasNoteRegexp.py 7144 2006-08-07 20:16:00Z rshura $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# 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 = _('Notes having notes '
|
||||
'containing <regular expression>')
|
||||
description = _("Matches notes whose notes contain text "
|
||||
"matching a regular expression")
|
48
src/Filters/Rules/Note/_MatchesFilter.py
Normal file
48
src/Filters/Rules/Note/_MatchesFilter.py
Normal 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: _MatchesFilter.py 7686 2006-11-24 23:14:25Z romjerome $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# 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 = _('Notes matching the <filter>')
|
||||
description = _("Matches notes matched "
|
||||
"by the specified filter name")
|
||||
namespace = 'Note'
|
44
src/Filters/Rules/Note/_NotePrivate.py
Normal file
44
src/Filters/Rules/Note/_NotePrivate.py
Normal 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: _RepoPrivate.py 7144 2006-08-07 20:16:00Z rshura $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._IsPrivate import IsPrivate
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "Repo marked private"
|
||||
#-------------------------------------------------------------------------
|
||||
class NotePrivate(IsPrivate):
|
||||
"""Note marked private"""
|
||||
|
||||
name = _('Notes marked private')
|
||||
description = _("Matches notes that are indicated as private")
|
50
src/Filters/Rules/Note/_RegExpIdOf.py
Normal file
50
src/Filters/Rules/Note/_RegExpIdOf.py
Normal 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: _RegExpIdOf.py 7144 2006-08-07 20:16:00Z rshura $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# 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 note whose GRAMPS ID
|
||||
matches regular expression.
|
||||
"""
|
||||
|
||||
name = _('Notes with <Id> matching regular expression')
|
||||
description = _("Matches notes whose GRAMPS ID matches "
|
||||
"the regular expression")
|
46
src/Filters/Rules/Note/__init__.py
Normal file
46
src/Filters/Rules/Note/__init__.py
Normal 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: __init__.py 6521 2006-05-03 01:02:54Z rshura $
|
||||
|
||||
"""
|
||||
Package providing filter rules for GRAMPS.
|
||||
"""
|
||||
|
||||
__author__ = "Don Allingham"
|
||||
|
||||
from _AllNotes import AllNotes
|
||||
from _HasIdOf import HasIdOf
|
||||
from _RegExpIdOf import RegExpIdOf
|
||||
#from _HasNoteRegexp import HasNoteRegexp
|
||||
#from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
|
||||
from _NotePrivate import NotePrivate
|
||||
from _MatchesFilter import MatchesFilter
|
||||
from _HasNote import HasNote
|
||||
|
||||
editor_rule_list = [
|
||||
AllNotes,
|
||||
HasIdOf,
|
||||
RegExpIdOf,
|
||||
# HasNoteRegexp,
|
||||
# HasNoteMatchingSubstringOf,
|
||||
NotePrivate,
|
||||
MatchesFilter,
|
||||
]
|
@ -11,7 +11,8 @@ pkgdata_PYTHON = \
|
||||
_SourceSidebarFilter.py\
|
||||
_PlaceSidebarFilter.py\
|
||||
_MediaSidebarFilter.py\
|
||||
_RepoSidebarFilter.py
|
||||
_RepoSidebarFilter.py\
|
||||
_NoteSidebarFilter.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/Filters/SideBar
|
||||
pkgpythondir = @pkgpythondir@/Filters/SideBar
|
||||
|
131
src/Filters/SideBar/_NoteSidebarFilter.py
Normal file
131
src/Filters/SideBar/_NoteSidebarFilter.py
Normal file
@ -0,0 +1,131 @@
|
||||
#
|
||||
# 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: _RepoSidebarFilter.py 7866 2007-01-04 05:09:41Z dallingham $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gtk
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import GrampsWidgets
|
||||
from RelLib import Note, NoteType
|
||||
|
||||
from _SidebarFilter import SidebarFilter
|
||||
from Filters import GenericFilterFactory, build_filter_model, Rules
|
||||
from Filters.Rules.Note import *
|
||||
|
||||
GenericNoteFilter = GenericFilterFactory('Note')
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# PersonSidebarFilter class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class NoteSidebarFilter(SidebarFilter):
|
||||
|
||||
def __init__(self,uistate, clicked):
|
||||
SidebarFilter.__init__(self,uistate)
|
||||
self.clicked_func = clicked
|
||||
|
||||
def create_widget(self):
|
||||
self.filter_id = gtk.Entry()
|
||||
self.filter_text = gtk.Entry()
|
||||
|
||||
self.note = Note()
|
||||
self.note.set_type((NoteType.CUSTOM,''))
|
||||
self.ntype = gtk.ComboBoxEntry()
|
||||
self.event_menu = GrampsWidgets.MonitoredDataType(
|
||||
self.ntype,
|
||||
self.note.set_type,
|
||||
self.note.get_type)
|
||||
|
||||
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
|
||||
|
||||
self.generic = gtk.ComboBox()
|
||||
cell = gtk.CellRendererText()
|
||||
self.generic.pack_start(cell, True)
|
||||
self.generic.add_attribute(cell, 'text', 0)
|
||||
self.on_filters_changed('Note')
|
||||
|
||||
self.add_text_entry(_('ID'), self.filter_id)
|
||||
self.add_text_entry(_('Text'), self.filter_text)
|
||||
self.add_entry(_('Type'), self.ntype)
|
||||
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_text.set_text('')
|
||||
self.ntype.child.set_text('')
|
||||
self.generic.set_active(0)
|
||||
|
||||
def get_filter(self):
|
||||
gid = unicode(self.filter_id.get_text()).strip()
|
||||
text = unicode(self.filter_text.get_text()).strip()
|
||||
ntype = self.note.get_type().xml_str()
|
||||
regex = self.filter_regex.get_active()
|
||||
gen = self.generic.get_active() > 0
|
||||
|
||||
empty = not (gid or text or ntype or regex or gen)
|
||||
if empty:
|
||||
generic_filter = None
|
||||
else:
|
||||
generic_filter = GenericNoteFilter()
|
||||
if gid:
|
||||
if regex:
|
||||
rule = RegExpIdOf([gid])
|
||||
else:
|
||||
rule = HasIdOf([gid])
|
||||
generic_filter.add_rule(rule)
|
||||
|
||||
rule = HasNote([text,ntype])
|
||||
generic_filter.add_rule(rule)
|
||||
|
||||
|
||||
if self.generic.get_active() != 0:
|
||||
model = self.generic.get_model()
|
||||
node = self.generic.get_active_iter()
|
||||
obj = model.get_value(node, 0)
|
||||
rule = MatchesFilter([obj])
|
||||
generic_filter.add_rule(rule)
|
||||
|
||||
return generic_filter
|
||||
|
||||
def on_filters_changed(self,name_space):
|
||||
if name_space == 'Note':
|
||||
all = GenericNoteFilter()
|
||||
all.set_name(_("None"))
|
||||
all.add_rule(Rules.Note.AllNotes([]))
|
||||
self.generic.set_model(build_filter_model('Note', [all]))
|
||||
self.generic.set_active(0)
|
@ -34,3 +34,4 @@ from _SourceSidebarFilter import SourceSidebarFilter
|
||||
from _PlaceSidebarFilter import PlaceSidebarFilter
|
||||
from _MediaSidebarFilter import MediaSidebarFilter
|
||||
from _RepoSidebarFilter import RepoSidebarFilter
|
||||
from _NoteSidebarFilter import NoteSidebarFilter
|
||||
|
@ -288,6 +288,20 @@ class GenericRepoFilter(GenericFilter):
|
||||
def find_from_handle(self, db, handle):
|
||||
return db.get_repository_from_handle(handle)
|
||||
|
||||
class GenericNoteFilter(GenericFilter):
|
||||
|
||||
def __init__(self, source=None):
|
||||
GenericFilter.__init__(self, source)
|
||||
|
||||
def get_cursor(self, db):
|
||||
return db.get_note_cursor()
|
||||
|
||||
def make_obj(self):
|
||||
return RelLib.Note()
|
||||
|
||||
def find_from_handle(self, db, handle):
|
||||
return db.get_note_from_handle(handle)
|
||||
|
||||
|
||||
def GenericFilterFactory(namespace):
|
||||
if namespace == 'Person':
|
||||
@ -304,3 +318,5 @@ def GenericFilterFactory(namespace):
|
||||
return GenericMediaFilter
|
||||
elif namespace == 'Repository':
|
||||
return GenericRepoFilter
|
||||
elif namespace == 'Note':
|
||||
return GenericNoteFilter
|
||||
|
Loading…
Reference in New Issue
Block a user