2465: More rules according to User Interface Object tabs - (benny)

svn: r11249
This commit is contained in:
Jérôme Rapinat 2008-11-05 11:21:36 +00:00
parent eb17261235
commit 190784e4b5
5 changed files with 74 additions and 13 deletions

View File

@ -2,6 +2,8 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2007-2008 Brian G. Matherly
# Copyright (C) 2008 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
@ -469,9 +471,13 @@ class EditRule(ManagedWindow.ManagedWindow):
l.show()
if v == _('Place:'):
t = MyPlaces([])
elif v == _('Reference count:'):
elif v in [_('Reference count:'),
_('Number of instances:')
]:
t = MyInteger(0, 999)
elif v == _('Reference count must be:'):
elif v in [_('Reference count must be:'),
_('Number must be')
]:
t = MyLesserEqualGreater()
elif v == _('Number of generations:'):
t = MyInteger(1, 32)

View File

@ -40,5 +40,5 @@ from Filters.Rules._HasGalleryBase import HasGalleryBase
class HavePhotos(HasGalleryBase):
"""Rule that checks for person who has media object reference"""
name = _('People with media')
description = _("Matches people with media object in the gallery")
name = _('People with <count> media')
description = _("Matches people with a certain number of items in the gallery")

View File

@ -40,9 +40,27 @@ from Filters.Rules import Rule
class HasGalleryBase(Rule):
"""Objects who have Media Object"""
name = _('Object with Media reference')
description = _("Matches objects with reference in the gallery")
labels = [ _('Number of instances:'), _('Number must be')]
name = _('Object with <count> Media reference')
description = _("Matches objects with certain number of items in the gallery")
category = _('General filters')
def prepare(self, db):
# things we want to do just once, not for every handle
if self.list[1] == _('lesser than'):
self.count_type = 0
elif self.list[1] == _('greater than'):
self.count_type = 2
else:
self.count_type = 1 # "equal to"
self.userSelectedCount = int(self.list[0])
def apply(self, db, obj):
return len( obj.get_media_list()) > 0
count = len( obj.get_media_list())
if self.count_type == 0: # "lesser than"
return count < self.userSelectedCount
elif self.count_type == 2: # "greater than"
return count > self.userSelectedCount
# "equal to"
return count == self.userSelectedCount

View File

@ -41,9 +41,28 @@ from Filters.Rules._Rule import Rule
class HasNoteBase(Rule):
"""Objects having notes"""
name = _('Object with note')
description = _("Matches objects that have a note")
labels = [ _('Number of instances:'), _('Number must be')]
name = _('Object with notes')
description = _("Matches objects that have a certain number of notes")
category = _('General filters')
def prepare(self, db):
# things we want to do just once, not for every handle
if self.list[1] == _('lesser than'):
self.count_type = 0
elif self.list[1] == _('greater than'):
self.count_type = 2
else:
self.count_type = 1 # "equal to"
self.userSelectedCount = int(self.list[0])
def apply(self, db, obj):
return len( obj.get_note_list()) > 0
count = len( obj.get_note_list())
if self.count_type == 0: # "lesser than"
return count < self.userSelectedCount
elif self.count_type == 2: # "greater than"
return count > self.userSelectedCount
# "equal to"
return count == self.userSelectedCount

View File

@ -41,9 +41,27 @@ from Filters.Rules._Rule import Rule
class HasSourceBase(Rule):
"""Objects having notes"""
name = _('Objects with source')
description = _("Matches objects that have a source")
labels = [ _('Number of instances:'), _('Number must be')]
name = _('Objects with <count> sources')
description = _("Matches objects that have a certain number of sources")
category = _('General filters')
def prepare(self, db):
# things we want to do just once, not for every handle
if self.list[1] == _('lesser than'):
self.count_type = 0
elif self.list[1] == _('greater than'):
self.count_type = 2
else:
self.count_type = 1 # "equal to"
self.userSelectedCount = int(self.list[0])
def apply(self, db, obj):
return len( obj.get_source_references()) > 0
count = len(obj.get_source_references())
if self.count_type == 0: # "lesser than"
return count < self.userSelectedCount
elif self.count_type == 2: # "greater than"
return count > self.userSelectedCount
# "equal to"
return count == self.userSelectedCount