2465: More rules according to User Interface Object tabs - (benny)
svn: r11249
This commit is contained in:
parent
eb17261235
commit
190784e4b5
@ -2,6 +2,8 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# 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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -469,9 +471,13 @@ class EditRule(ManagedWindow.ManagedWindow):
|
|||||||
l.show()
|
l.show()
|
||||||
if v == _('Place:'):
|
if v == _('Place:'):
|
||||||
t = MyPlaces([])
|
t = MyPlaces([])
|
||||||
elif v == _('Reference count:'):
|
elif v in [_('Reference count:'),
|
||||||
|
_('Number of instances:')
|
||||||
|
]:
|
||||||
t = MyInteger(0, 999)
|
t = MyInteger(0, 999)
|
||||||
elif v == _('Reference count must be:'):
|
elif v in [_('Reference count must be:'),
|
||||||
|
_('Number must be')
|
||||||
|
]:
|
||||||
t = MyLesserEqualGreater()
|
t = MyLesserEqualGreater()
|
||||||
elif v == _('Number of generations:'):
|
elif v == _('Number of generations:'):
|
||||||
t = MyInteger(1, 32)
|
t = MyInteger(1, 32)
|
||||||
|
@ -40,5 +40,5 @@ from Filters.Rules._HasGalleryBase import HasGalleryBase
|
|||||||
class HavePhotos(HasGalleryBase):
|
class HavePhotos(HasGalleryBase):
|
||||||
"""Rule that checks for person who has media object reference"""
|
"""Rule that checks for person who has media object reference"""
|
||||||
|
|
||||||
name = _('People with media')
|
name = _('People with <count> media')
|
||||||
description = _("Matches people with media object in the gallery")
|
description = _("Matches people with a certain number of items in the gallery")
|
||||||
|
@ -40,9 +40,27 @@ from Filters.Rules import Rule
|
|||||||
class HasGalleryBase(Rule):
|
class HasGalleryBase(Rule):
|
||||||
"""Objects who have Media Object"""
|
"""Objects who have Media Object"""
|
||||||
|
|
||||||
name = _('Object with Media reference')
|
labels = [ _('Number of instances:'), _('Number must be')]
|
||||||
description = _("Matches objects with reference in the gallery")
|
name = _('Object with <count> Media reference')
|
||||||
|
description = _("Matches objects with certain number of items in the gallery")
|
||||||
category = _('General filters')
|
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):
|
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
|
||||||
|
@ -41,9 +41,28 @@ from Filters.Rules._Rule import Rule
|
|||||||
class HasNoteBase(Rule):
|
class HasNoteBase(Rule):
|
||||||
"""Objects having notes"""
|
"""Objects having notes"""
|
||||||
|
|
||||||
name = _('Object with note')
|
labels = [ _('Number of instances:'), _('Number must be')]
|
||||||
description = _("Matches objects that have a note")
|
name = _('Object with notes')
|
||||||
|
description = _("Matches objects that have a certain number of notes")
|
||||||
category = _('General filters')
|
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):
|
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
|
||||||
|
@ -41,9 +41,27 @@ from Filters.Rules._Rule import Rule
|
|||||||
class HasSourceBase(Rule):
|
class HasSourceBase(Rule):
|
||||||
"""Objects having notes"""
|
"""Objects having notes"""
|
||||||
|
|
||||||
name = _('Objects with source')
|
labels = [ _('Number of instances:'), _('Number must be')]
|
||||||
description = _("Matches objects that have a source")
|
name = _('Objects with <count> sources')
|
||||||
|
description = _("Matches objects that have a certain number of sources")
|
||||||
category = _('General filters')
|
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):
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user