* src/FilterEditor/_EditFilter.py: Support invert attribute.
* src/Filters/_GenericFilter.py: Support invert attribute. * src/Filters/_FilterList.py (save): Save invert attribute. * src/Filters/_FilterParser.py (startElement): Parse invert attribute. svn: r7126
This commit is contained in:
parent
19a3a5fea4
commit
af33023e61
@ -1,4 +1,8 @@
|
|||||||
2006-08-04 Alex Roitman <shura@gramps-project.org>
|
2006-08-04 Alex Roitman <shura@gramps-project.org>
|
||||||
|
* src/FilterEditor/_EditFilter.py: Support invert attribute.
|
||||||
|
* src/Filters/_GenericFilter.py: Support invert attribute.
|
||||||
|
* src/Filters/_FilterList.py (save): Save invert attribute.
|
||||||
|
* src/Filters/_FilterParser.py (startElement): Parse invert attribute.
|
||||||
* src/Filters/Rules/Family/__init__.py (editor_rule_list): Import
|
* src/Filters/Rules/Family/__init__.py (editor_rule_list): Import
|
||||||
and use new rule.
|
and use new rule.
|
||||||
* src/Filters/Rules/Family/Makefile.am (pkgdata_PYTHON): Ship new file.
|
* src/Filters/Rules/Family/Makefile.am (pkgdata_PYTHON): Ship new file.
|
||||||
|
@ -86,6 +86,7 @@ class EditFilter(ManagedWindow.ManagedWindow):
|
|||||||
|
|
||||||
self.fname = self.get_widget('filter_name')
|
self.fname = self.get_widget('filter_name')
|
||||||
self.logical = self.get_widget('rule_apply')
|
self.logical = self.get_widget('rule_apply')
|
||||||
|
self.logical_not = self.get_widget('logical_not')
|
||||||
self.comment = self.get_widget('comment')
|
self.comment = self.get_widget('comment')
|
||||||
self.ok_btn = self.get_widget('ok')
|
self.ok_btn = self.get_widget('ok')
|
||||||
self.edit_btn = self.get_widget('edit')
|
self.edit_btn = self.get_widget('edit')
|
||||||
@ -109,6 +110,7 @@ class EditFilter(ManagedWindow.ManagedWindow):
|
|||||||
self.logical.set_active(2)
|
self.logical.set_active(2)
|
||||||
else:
|
else:
|
||||||
self.logical.set_active(0)
|
self.logical.set_active(0)
|
||||||
|
self.logical_not.set_active(self.filter.get_invert())
|
||||||
if self.filter.get_name():
|
if self.filter.get_name():
|
||||||
self.fname.set_text(self.filter.get_name())
|
self.fname.set_text(self.filter.get_name())
|
||||||
self.comment.set_text(self.filter.get_comment())
|
self.comment.set_text(self.filter.get_comment())
|
||||||
@ -159,6 +161,7 @@ class EditFilter(ManagedWindow.ManagedWindow):
|
|||||||
else:
|
else:
|
||||||
op = 'and'
|
op = 'and'
|
||||||
self.filter.set_logical_op(op)
|
self.filter.set_logical_op(op)
|
||||||
|
self.filter.set_invert(self.logical_not.get_active())
|
||||||
self.filterdb.add(self.space,self.filter)
|
self.filterdb.add(self.space,self.filter)
|
||||||
self.update()
|
self.update()
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -92,6 +92,8 @@ class FilterList:
|
|||||||
for the_filter in filter_list:
|
for the_filter in filter_list:
|
||||||
f.write(' <filter name="%s"' %self.fix(the_filter.get_name()))
|
f.write(' <filter name="%s"' %self.fix(the_filter.get_name()))
|
||||||
f.write(' function="%s"' % the_filter.get_logical_op())
|
f.write(' function="%s"' % the_filter.get_logical_op())
|
||||||
|
if the_filter.invert:
|
||||||
|
f.write(' invert="1"')
|
||||||
comment = the_filter.get_comment()
|
comment = the_filter.get_comment()
|
||||||
if comment:
|
if comment:
|
||||||
f.write(' comment="%s"' % self.fix(comment))
|
f.write(' comment="%s"' % self.fix(comment))
|
||||||
|
@ -73,6 +73,8 @@ class FilterParser(handler.ContentHandler):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
op = attrs['function']
|
op = attrs['function']
|
||||||
self.f.set_logical_op(op)
|
self.f.set_logical_op(op)
|
||||||
|
if attrs.has_key('invert'):
|
||||||
|
self.f.set_invert(attrs['invert'])
|
||||||
if attrs.has_key('comment'):
|
if attrs.has_key('comment'):
|
||||||
self.f.set_comment(attrs['comment'])
|
self.f.set_comment(attrs['comment'])
|
||||||
self.gfilter_list.add(self.namespace,self.f)
|
self.gfilter_list.add(self.namespace,self.f)
|
||||||
|
@ -42,12 +42,14 @@ class GenericFilter:
|
|||||||
self.name = source.name
|
self.name = source.name
|
||||||
self.comment = source.comment
|
self.comment = source.comment
|
||||||
self.logical_op = source.logical_op
|
self.logical_op = source.logical_op
|
||||||
|
self.invert = source.invert
|
||||||
else:
|
else:
|
||||||
self.need_param = 0
|
self.need_param = 0
|
||||||
self.flist = []
|
self.flist = []
|
||||||
self.name = ''
|
self.name = ''
|
||||||
self.comment = ''
|
self.comment = ''
|
||||||
self.logical_op = 'and'
|
self.logical_op = 'and'
|
||||||
|
self.invert = False
|
||||||
|
|
||||||
def match(self,handle):
|
def match(self,handle):
|
||||||
return True
|
return True
|
||||||
@ -64,6 +66,12 @@ class GenericFilter:
|
|||||||
def get_logical_op(self):
|
def get_logical_op(self):
|
||||||
return self.logical_op
|
return self.logical_op
|
||||||
|
|
||||||
|
def set_invert(self,val):
|
||||||
|
self.invert = bool(val)
|
||||||
|
|
||||||
|
def get_invert(self):
|
||||||
|
return self.invert
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
@ -102,29 +110,27 @@ class GenericFilter:
|
|||||||
|
|
||||||
if id_list == None:
|
if id_list == None:
|
||||||
cursor = self.get_cursor(db)
|
cursor = self.get_cursor(db)
|
||||||
data = cursor.next()
|
data = cursor.first()
|
||||||
while data:
|
while data:
|
||||||
person = self.make_obj()
|
person = self.make_obj()
|
||||||
person.unserialize(data[1])
|
person.unserialize(data[1])
|
||||||
if task(db,person):
|
if task(db,person) != self.invert:
|
||||||
final_list.append(data[0])
|
final_list.append(data[0])
|
||||||
data = cursor.next()
|
data = cursor.next()
|
||||||
|
cursor.close()
|
||||||
else:
|
else:
|
||||||
for handle in id_list:
|
for handle in id_list:
|
||||||
person = self.find_from_handle(db, handle)
|
person = self.find_from_handle(db, handle)
|
||||||
if task(db,person):
|
if task(db,person) != self.invert:
|
||||||
final_list.append(handle)
|
final_list.append(handle)
|
||||||
return final_list
|
return final_list
|
||||||
|
|
||||||
def check_or(self,db,id_list):
|
|
||||||
return self.check_func(db,id_list,self.or_test)
|
|
||||||
|
|
||||||
def check_and(self,db,id_list):
|
def check_and(self,db,id_list):
|
||||||
final_list = []
|
final_list = []
|
||||||
flist = self.flist
|
flist = self.flist
|
||||||
if id_list == None:
|
if id_list == None:
|
||||||
cursor = self.get_cursor(db)
|
cursor = self.get_cursor(db)
|
||||||
data = cursor.next()
|
data = cursor.first()
|
||||||
while data:
|
while data:
|
||||||
person = self.make_obj()
|
person = self.make_obj()
|
||||||
person.unserialize(data[1])
|
person.unserialize(data[1])
|
||||||
@ -133,9 +139,10 @@ class GenericFilter:
|
|||||||
if not rule.apply(db,person):
|
if not rule.apply(db,person):
|
||||||
val = False
|
val = False
|
||||||
break
|
break
|
||||||
if not val:
|
if val != self.invert:
|
||||||
final_list.append(data[0])
|
final_list.append(data[0])
|
||||||
data = cursor.next()
|
data = cursor.next()
|
||||||
|
cursor.close()
|
||||||
else:
|
else:
|
||||||
for handle in id_list:
|
for handle in id_list:
|
||||||
person = self.find_from_handle(db, handle)
|
person = self.find_from_handle(db, handle)
|
||||||
@ -144,10 +151,13 @@ class GenericFilter:
|
|||||||
if not rule.apply(db,person):
|
if not rule.apply(db,person):
|
||||||
val = False
|
val = False
|
||||||
break
|
break
|
||||||
if val:
|
if val != self.invert:
|
||||||
final_list.append(handle)
|
final_list.append(handle)
|
||||||
return final_list
|
return final_list
|
||||||
|
|
||||||
|
def check_or(self,db,id_list):
|
||||||
|
return self.check_func(db,id_list,self.or_test)
|
||||||
|
|
||||||
def check_one(self,db,id_list):
|
def check_one(self,db,id_list):
|
||||||
return self.check_func(db,id_list,self.one_test)
|
return self.check_func(db,id_list,self.one_test)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user