* src/Filters/Rules/*: Add new Rule HasMarkerOf

* src/FilterEditor/_EditRule.py: Support MarkerType
* src/Filters/SideBar/_FamilySidebarFilter.py: Add MarkerType
* src/Filters/SideBar/_PersonSidebarFilter.py: Add MarkerType



svn: r7735
This commit is contained in:
Martin Hawlisch 2006-11-30 15:52:26 +00:00
parent e21c00a504
commit 7ef890fe32
8 changed files with 212 additions and 26 deletions

View File

@ -1,3 +1,9 @@
2006-11-30 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/Filters/Rules/*: Add new Rule HasMarkerOf
* src/FilterEditor/_EditRule.py: Support MarkerType
* src/Filters/SideBar/_FamilySidebarFilter.py: Add MarkerType
* src/Filters/SideBar/_PersonSidebarFilter.py: Add MarkerType
2006-11-29 Alex Roitman <shura@gramps-project.org> 2006-11-29 Alex Roitman <shura@gramps-project.org>
* src/GrampsWidgets.py (PlaceEntry.set_button): Dynamically set * src/GrampsWidgets.py (PlaceEntry.set_button): Dynamically set
tooltips. tooltips.

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: _HasEvent.py 7607 2006-11-10 21:27:08Z loshawlos $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasMarkerBase import HasMarkerBase
#-------------------------------------------------------------------------
#
# HasEvent
#
#-------------------------------------------------------------------------
class HasMarkerOf(HasMarkerBase):
"""Rule that checks for a family with a particular marker"""
name = _('Families with <marker>')
description = _("Matches Families with a marker of a particular value")

View File

@ -39,6 +39,7 @@ from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _FamilyPrivate import FamilyPrivate from _FamilyPrivate import FamilyPrivate
from _HasAttribute import HasAttribute from _HasAttribute import HasAttribute
from _HasEvent import HasEvent from _HasEvent import HasEvent
from _HasMarkerOf import HasMarkerOf
from _MatchesFilter import MatchesFilter from _MatchesFilter import MatchesFilter
from _FatherHasNameOf import FatherHasNameOf from _FatherHasNameOf import FatherHasNameOf
from _FatherHasIdOf import FatherHasIdOf from _FatherHasIdOf import FatherHasIdOf
@ -57,6 +58,7 @@ editor_rule_list = [
FamilyPrivate, FamilyPrivate,
HasEvent, HasEvent,
HasAttribute, HasAttribute,
HasMarkerOf,
MatchesFilter, MatchesFilter,
FatherHasNameOf, FatherHasNameOf,
FatherHasIdOf, FatherHasIdOf,

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: _HasEvent.py 7607 2006-11-10 21:27:08Z loshawlos $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasMarkerBase import HasMarkerBase
#-------------------------------------------------------------------------
#
# HasEvent
#
#-------------------------------------------------------------------------
class HasMarkerOf(HasMarkerBase):
"""Rule that checks for a person with a particular marker"""
name = _('People with <marker>')
description = _("Matches people with a marker of a particular value")

View File

@ -48,6 +48,7 @@ from _HasSourceOf import HasSourceOf
from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf
from _HasTextMatchingSubstringOf import HasTextMatchingSubstringOf from _HasTextMatchingSubstringOf import HasTextMatchingSubstringOf
from _HasUnknownGender import HasUnknownGender from _HasUnknownGender import HasUnknownGender
from _HasMarkerOf import HasMarkerOf
from _HaveAltFamilies import HaveAltFamilies from _HaveAltFamilies import HaveAltFamilies
from _HaveChildren import HaveChildren from _HaveChildren import HaveChildren
from _HavePhotos import HavePhotos from _HavePhotos import HavePhotos
@ -119,6 +120,7 @@ editor_rule_list = [
HasAttribute, HasAttribute,
HasFamilyAttribute, HasFamilyAttribute,
HasSourceOf, HasSourceOf,
HasMarkerOf,
HaveAltFamilies, HaveAltFamilies,
HavePhotos, HavePhotos,
HaveChildren, HaveChildren,

View File

@ -0,0 +1,55 @@
#
# 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: _HasEvent.py 6635 2006-05-13 03:53:06Z dallingham $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from RelLib import MarkerType
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#
# HasEvent
#
#-------------------------------------------------------------------------
class HasMarkerBase(Rule):
"""Rule that checks for a person with a particular value"""
labels = [ _('Marker type:')]
name = _('Has marker of')
description = _("Matches markers of a partikular type")
category = _('General filters')
def apply(self,db,obj):
specified_type = MarkerType()
specified_type.set_from_xml_str(self.list[0])
return obj.get_marker() == specified_type

View File

@ -82,14 +82,22 @@ class FamilySidebarFilter(SidebarFilter):
self.family_stub.set_relationship, self.family_stub.set_relationship,
self.family_stub.get_relationship) self.family_stub.get_relationship)
self.filter_marker = RelLib.Family()
self.filter_marker.set_marker((RelLib.MarkerType.CUSTOM,''))
self.mtype = gtk.ComboBoxEntry()
self.marker_menu = GrampsWidgets.MonitoredDataType(
self.mtype,
self.filter_marker.set_marker,
self.filter_marker.get_marker)
self.filter_note = gtk.Entry() self.filter_note = gtk.Entry()
self.filter_regex = gtk.CheckButton(_('Use regular expressions')) self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
self.generic = gtk.ComboBox() self.generic = gtk.ComboBox()
cell = gtk.CellRendererText() cell = gtk.CellRendererText()
self.generic.pack_start(cell, True) self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0) self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Family') self.on_filters_changed('Family')
self.add_text_entry(_('ID'), self.filter_id) self.add_text_entry(_('ID'), self.filter_id)
@ -98,6 +106,7 @@ class FamilySidebarFilter(SidebarFilter):
self.add_text_entry(_('Child'), self.filter_child) self.add_text_entry(_('Child'), self.filter_child)
self.add_entry(_('Relationship'), self.rtype) self.add_entry(_('Relationship'), self.rtype)
self.add_entry(_('Family Event'), self.etype) self.add_entry(_('Family Event'), self.etype)
self.add_entry(_('Marker'), self.mtype)
self.add_text_entry(_('Family Note'), self.filter_note) self.add_text_entry(_('Family Note'), self.filter_note)
self.add_entry(_('Custom filter'), self.generic) self.add_entry(_('Custom filter'), self.generic)
self.add_entry(None, self.filter_regex) self.add_entry(None, self.filter_regex)
@ -110,6 +119,7 @@ class FamilySidebarFilter(SidebarFilter):
self.filter_note.set_text('') self.filter_note.set_text('')
self.etype.child.set_text('') self.etype.child.set_text('')
self.rtype.child.set_text('') self.rtype.child.set_text('')
self.mtype.child.set_text('')
self.generic.set_active(0) self.generic.set_active(0)
def clicked(self, obj): def clicked(self, obj):
@ -123,10 +133,11 @@ class FamilySidebarFilter(SidebarFilter):
note = unicode(self.filter_note.get_text()).strip() note = unicode(self.filter_note.get_text()).strip()
etype = self.filter_event.get_type().xml_str() etype = self.filter_event.get_type().xml_str()
rtype = self.family_stub.get_relationship().xml_str() rtype = self.family_stub.get_relationship().xml_str()
mtype = self.filter_marker.get_marker().xml_str()
regex = self.filter_regex.get_active() regex = self.filter_regex.get_active()
gen = self.generic.get_active() > 0 gen = self.generic.get_active() > 0
empty = not (gid or father or mother or child or note empty = not (gid or father or mother or child or note or mtype
or regex or etype or rtype or gen) or regex or etype or rtype or gen)
if empty: if empty:
generic_filter = None generic_filter = None
@ -159,6 +170,10 @@ class FamilySidebarFilter(SidebarFilter):
rule = HasRelType([rtype]) rule = HasRelType([rtype])
generic_filter.add_rule(rule) generic_filter.add_rule(rule)
if mtype:
rule = HasMarkerOf([mtype])
generic_filter.add_rule(rule)
if note: if note:
if regex: if regex:
rule = HasNoteRegexp([note]) rule = HasNoteRegexp([note])
@ -166,12 +181,12 @@ class FamilySidebarFilter(SidebarFilter):
rule = HasNoteMatchingSubstringOf([note]) rule = HasNoteMatchingSubstringOf([note])
generic_filter.add_rule(rule) generic_filter.add_rule(rule)
if self.generic.get_active() != 0: if self.generic.get_active() != 0:
model = self.generic.get_model() model = self.generic.get_model()
iter = self.generic.get_active_iter() iter = self.generic.get_active_iter()
obj = model.get_value(iter, 0) obj = model.get_value(iter, 0)
rule = MatchesFilter([obj]) rule = MatchesFilter([obj])
generic_filter.add_rule(rule) generic_filter.add_rule(rule)
return generic_filter return generic_filter

View File

@ -65,12 +65,19 @@ class PersonSidebarFilter(SidebarFilter):
self.filter_event = RelLib.Event() self.filter_event = RelLib.Event()
self.filter_event.set_type((RelLib.EventType.CUSTOM,'')) self.filter_event.set_type((RelLib.EventType.CUSTOM,''))
self.etype = gtk.ComboBoxEntry() self.etype = gtk.ComboBoxEntry()
self.event_menu = GrampsWidgets.MonitoredDataType( self.event_menu = GrampsWidgets.MonitoredDataType(
self.etype, self.etype,
self.filter_event.set_type, self.filter_event.set_type,
self.filter_event.get_type) self.filter_event.get_type)
self.filter_marker = RelLib.Person()
self.filter_marker.set_marker((RelLib.MarkerType.CUSTOM,''))
self.mtype = gtk.ComboBoxEntry()
self.marker_menu = GrampsWidgets.MonitoredDataType(
self.mtype,
self.filter_marker.set_marker,
self.filter_marker.get_marker)
self.filter_note = gtk.Entry() self.filter_note = gtk.Entry()
self.filter_gender = gtk.combo_box_new_text() self.filter_gender = gtk.combo_box_new_text()
for i in [ _('any'), _('male'), _('female'), _('unknown') ]: for i in [ _('any'), _('male'), _('female'), _('unknown') ]:
@ -79,10 +86,10 @@ class PersonSidebarFilter(SidebarFilter):
self.filter_regex = gtk.CheckButton(_('Use regular expressions')) self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
self.generic = gtk.ComboBox() self.generic = gtk.ComboBox()
cell = gtk.CellRendererText() cell = gtk.CellRendererText()
self.generic.pack_start(cell, True) self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0) self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Person') self.on_filters_changed('Person')
self.add_text_entry(_('Name'), self.filter_name) self.add_text_entry(_('Name'), self.filter_name)
@ -91,6 +98,7 @@ class PersonSidebarFilter(SidebarFilter):
self.add_text_entry(_('Birth date'), self.filter_birth) self.add_text_entry(_('Birth date'), self.filter_birth)
self.add_text_entry(_('Death date'), self.filter_death) self.add_text_entry(_('Death date'), self.filter_death)
self.add_entry(_('Event'), self.etype) self.add_entry(_('Event'), self.etype)
self.add_entry(_('Marker'), self.mtype)
self.add_text_entry(_('Note'), self.filter_note) self.add_text_entry(_('Note'), self.filter_note)
self.add_entry(_('Custom filter'), self.generic) self.add_entry(_('Custom filter'), self.generic)
self.add_entry(None, self.filter_regex) self.add_entry(None, self.filter_regex)
@ -103,6 +111,7 @@ class PersonSidebarFilter(SidebarFilter):
self.filter_note.set_text('') self.filter_note.set_text('')
self.filter_gender.set_active(0) self.filter_gender.set_active(0)
self.etype.child.set_text('') self.etype.child.set_text('')
self.mtype.child.set_text('')
self.generic.set_active(0) self.generic.set_active(0)
def clicked(self, obj): def clicked(self, obj):
@ -114,12 +123,13 @@ class PersonSidebarFilter(SidebarFilter):
birth = unicode(self.filter_birth.get_text()).strip() birth = unicode(self.filter_birth.get_text()).strip()
death = unicode(self.filter_death.get_text()).strip() death = unicode(self.filter_death.get_text()).strip()
etype = self.filter_event.get_type().xml_str() etype = self.filter_event.get_type().xml_str()
mtype = self.filter_marker.get_marker().xml_str()
note = unicode(self.filter_note.get_text()).strip() note = unicode(self.filter_note.get_text()).strip()
gender = self.filter_gender.get_active() gender = self.filter_gender.get_active()
regex = self.filter_regex.get_active() regex = self.filter_regex.get_active()
gen = self.generic.get_active() > 0 gen = self.generic.get_active() > 0
empty = not (name or gid or birth or death or etype empty = not (name or gid or birth or death or etype or mtype
or note or gender or regex or gen) or note or gender or regex or gen)
if empty: if empty:
generic_filter = None generic_filter = None
@ -146,6 +156,10 @@ class PersonSidebarFilter(SidebarFilter):
else: else:
generic_filter.add_rule(HasUnknownGender([])) generic_filter.add_rule(HasUnknownGender([]))
if mtype:
rule = HasMarkerOf([mtype])
generic_filter.add_rule(rule)
if etype: if etype:
rule = HasEvent([etype, '', '', '']) rule = HasEvent([etype, '', '', ''])
generic_filter.add_rule(rule) generic_filter.add_rule(rule)
@ -163,12 +177,12 @@ class PersonSidebarFilter(SidebarFilter):
rule = HasNoteMatchingSubstringOf([note]) rule = HasNoteMatchingSubstringOf([note])
generic_filter.add_rule(rule) generic_filter.add_rule(rule)
if self.generic.get_active() != 0: if self.generic.get_active() != 0:
model = self.generic.get_model() model = self.generic.get_model()
iter = self.generic.get_active_iter() iter = self.generic.get_active_iter()
obj = model.get_value(iter, 0) obj = model.get_value(iter, 0)
rule = MatchesFilter([obj]) rule = MatchesFilter([obj])
generic_filter.add_rule(rule) generic_filter.add_rule(rule)
return generic_filter return generic_filter