working filters in Person view
svn: r5802
This commit is contained in:
parent
6f61b03a2e
commit
8c439b364e
@ -1,4 +1,8 @@
|
|||||||
2006-01-17 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
2006-01-19 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||||
|
* src/ObjectSelector/_PersonFilterFrame.py, src/ObjectSelector/_PersonFrame.py
|
||||||
|
src/ObjectSelector/_PersonTreeFrame.py: filters in Person view just about work.
|
||||||
|
|
||||||
|
2006-01-19 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||||
* src/ObjectSelector/_FamilyFilterFrame.py, src/ObjectSelector/_ObjectSelectorWindow.py
|
* src/ObjectSelector/_FamilyFilterFrame.py, src/ObjectSelector/_ObjectSelectorWindow.py
|
||||||
src/ObjectSelector/_PersonFilterFrame.py: ground work for filters
|
src/ObjectSelector/_PersonFilterFrame.py: ground work for filters
|
||||||
* src/ObjectSelector/_FilterFrameBase.py: new file
|
* src/ObjectSelector/_FilterFrameBase.py: new file
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
import gtk
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
|
from gettext import gettext as _
|
||||||
|
from logging import getLogger
|
||||||
|
|
||||||
|
log = getLogger(".ObjectSelector")
|
||||||
|
|
||||||
from GrampsWidgets import IntEdit
|
from GrampsWidgets import IntEdit
|
||||||
from _FilterFrameBase import FilterFrameBase
|
from _FilterFrameBase import FilterFrameBase
|
||||||
import GenericFilter
|
import GenericFilter
|
||||||
|
import RelLib
|
||||||
|
|
||||||
class PersonFilterFrame(FilterFrameBase):
|
class PersonFilterFrame(FilterFrameBase):
|
||||||
|
|
||||||
@ -42,10 +47,21 @@ class PersonFilterFrame(FilterFrameBase):
|
|||||||
gender_label = gtk.Label("Gender")
|
gender_label = gtk.Label("Gender")
|
||||||
gender_label.set_alignment(xalign=0,yalign=0.5)
|
gender_label.set_alignment(xalign=0,yalign=0.5)
|
||||||
|
|
||||||
self._gender_combo = gtk.combo_box_new_text()
|
self._gender_list = gtk.ListStore(str,int)
|
||||||
self._gender_combo.append_text("Male")
|
|
||||||
self._gender_combo.append_text("Female")
|
genders=[[_("Male"),RelLib.Person.MALE],
|
||||||
self._gender_combo.append_text("Unknown")
|
[_("Female"),RelLib.Person.FEMALE],
|
||||||
|
[_("Unknown"),RelLib.Person.UNKNOWN]]
|
||||||
|
|
||||||
|
for gender in genders:
|
||||||
|
self._gender_list.append(gender)
|
||||||
|
|
||||||
|
self._gender_combo = gtk.ComboBox(self._gender_list)
|
||||||
|
|
||||||
|
label_cell = gtk.CellRendererText()
|
||||||
|
|
||||||
|
self._gender_combo.pack_start(label_cell, True)
|
||||||
|
self._gender_combo.add_attribute(label_cell, 'text', 0)
|
||||||
self._gender_combo.set_active(2)
|
self._gender_combo.set_active(2)
|
||||||
self._gender_combo.set_sensitive(False)
|
self._gender_combo.set_sensitive(False)
|
||||||
|
|
||||||
@ -118,15 +134,55 @@ class PersonFilterFrame(FilterFrameBase):
|
|||||||
filter_label = gtk.Label("Filter")
|
filter_label = gtk.Label("Filter")
|
||||||
filter_label.set_alignment(xalign=0,yalign=0.5)
|
filter_label.set_alignment(xalign=0,yalign=0.5)
|
||||||
|
|
||||||
self._filter_combo = gtk.combo_box_new_text()
|
default_filters = [
|
||||||
self._filter_combo.append_text("Male")
|
GenericFilter.Everyone,
|
||||||
self._filter_combo.append_text("Female")
|
GenericFilter.IsFemale,
|
||||||
self._filter_combo.append_text("Unknown")
|
GenericFilter.IsMale,
|
||||||
self._filter_combo.set_active(2)
|
GenericFilter.HasUnknownGender,
|
||||||
|
GenericFilter.Disconnected,
|
||||||
|
GenericFilter.SearchName,
|
||||||
|
GenericFilter.HaveAltFamilies,
|
||||||
|
GenericFilter.HavePhotos,
|
||||||
|
GenericFilter.IncompleteNames,
|
||||||
|
GenericFilter.HaveChildren,
|
||||||
|
GenericFilter.NeverMarried,
|
||||||
|
GenericFilter.MultipleMarriages,
|
||||||
|
GenericFilter.NoBirthdate,
|
||||||
|
GenericFilter.PersonWithIncompleteEvent,
|
||||||
|
GenericFilter.FamilyWithIncompleteEvent,
|
||||||
|
GenericFilter.ProbablyAlive,
|
||||||
|
GenericFilter.PeoplePrivate,
|
||||||
|
GenericFilter.IsWitness,
|
||||||
|
GenericFilter.HasTextMatchingSubstringOf,
|
||||||
|
GenericFilter.HasTextMatchingRegexpOf,
|
||||||
|
GenericFilter.HasNote,
|
||||||
|
GenericFilter.HasNoteMatchingSubstringOf,
|
||||||
|
GenericFilter.IsFemale,
|
||||||
|
]
|
||||||
|
|
||||||
|
self._filter_list = gtk.ListStore(object,str)
|
||||||
|
|
||||||
|
for filter in default_filters:
|
||||||
|
if not hasattr(filter,'labels') or len(filter.labels) == 0:
|
||||||
|
# don't currently support filters that need an attribute.
|
||||||
|
self._filter_list.append([filter,filter.name])
|
||||||
|
|
||||||
|
self._filter_combo = gtk.ComboBox(self._filter_list)
|
||||||
|
|
||||||
|
label_cell = gtk.CellRendererText()
|
||||||
|
|
||||||
|
self._filter_combo.pack_start(label_cell, True)
|
||||||
|
self._filter_combo.add_attribute(label_cell, 'text', 1)
|
||||||
|
self._filter_combo.set_active(0)
|
||||||
self._filter_combo.set_sensitive(False)
|
self._filter_combo.set_sensitive(False)
|
||||||
|
|
||||||
|
|
||||||
self._filter_check.connect('toggled',lambda b: self._filter_combo.set_sensitive(self._filter_check.get_active()))
|
self._filter_check.connect('toggled',lambda b: self._filter_combo.set_sensitive(self._filter_check.get_active()))
|
||||||
|
|
||||||
|
self._filter_entry_label = gtk.Label()
|
||||||
|
self._filter_entry_label.set_sensitive(False)
|
||||||
|
|
||||||
|
self._filter_entry_edit = gtk.Entry()
|
||||||
|
self._filter_entry_edit.set_sensitive(False)
|
||||||
|
|
||||||
# table layout
|
# table layout
|
||||||
|
|
||||||
@ -207,6 +263,45 @@ class PersonFilterFrame(FilterFrameBase):
|
|||||||
if self._id_check.get_active():
|
if self._id_check.get_active():
|
||||||
filter.add_rule(GenericFilter.HasIdOf([self._id_edit.get_text()]))
|
filter.add_rule(GenericFilter.HasIdOf([self._id_edit.get_text()]))
|
||||||
|
|
||||||
|
if self._name_check.get_active():
|
||||||
|
filter.add_rule(GenericFilter.SearchName([self._name_edit.get_text()]))
|
||||||
|
|
||||||
|
if self._gender_check.get_active():
|
||||||
|
gender = self._gender_list.get_value(self._gender_combo.get_active_iter(),1)
|
||||||
|
if gender == RelLib.Person.MALE:
|
||||||
|
filter.add_rule(GenericFilter.IsMale([]))
|
||||||
|
elif gender == RelLib.Person.FEMALE:
|
||||||
|
filter.add_rule(GenericFilter.IsFemale([]))
|
||||||
|
elif gender == RelLib.Person.UNKNOWN:
|
||||||
|
filter.add_rule(GenericFilter.HasUnknownGender([]))
|
||||||
|
else:
|
||||||
|
log.warn("Received unknown gender from filter widget")
|
||||||
|
|
||||||
|
if self._birth_check.get_active():
|
||||||
|
date = ""
|
||||||
|
if self._b_before.get_active():
|
||||||
|
date = "before " + self._b_edit.get_text()
|
||||||
|
elif self._b_after.get_active():
|
||||||
|
date = "after " + self._b_edit.get_text()
|
||||||
|
else:
|
||||||
|
log.warn("neither before or after is selected, this should not happen")
|
||||||
|
filter.add_rule(GenericFilter.HasBirth([date,'','']))
|
||||||
|
|
||||||
|
if self._death_check.get_active():
|
||||||
|
date = ""
|
||||||
|
if self._d_before.get_active():
|
||||||
|
date = "before " + self._d_edit.get_text()
|
||||||
|
elif self._d_after.get_active():
|
||||||
|
date = "after " + self._d_edit.get_text()
|
||||||
|
else:
|
||||||
|
log.warn("neither before or after is selected, this should not happen")
|
||||||
|
filter.add_rule(GenericFilter.HasDeath([date,'','']))
|
||||||
|
|
||||||
|
|
||||||
|
if self._filter_check.get_active():
|
||||||
|
filter.add_rule(self._filter_list.get_value(self._filter_combo.get_active_iter(),0)([]))
|
||||||
|
|
||||||
|
|
||||||
self.emit('apply-filter',filter)
|
self.emit('apply-filter',filter)
|
||||||
|
|
||||||
if gtk.pygtk_version < (2,8,0):
|
if gtk.pygtk_version < (2,8,0):
|
||||||
|
@ -57,6 +57,8 @@ class PersonFrame(ObjectFrameBase):
|
|||||||
self._tree_frame.get_selection().connect('changed',self.set_preview,self.__class__.__person_id_field)
|
self._tree_frame.get_selection().connect('changed',self.set_preview,self.__class__.__person_id_field)
|
||||||
self._tree_frame.get_tree().connect('row-activated',self._on_row_activated)
|
self._tree_frame.get_tree().connect('row-activated',self._on_row_activated)
|
||||||
|
|
||||||
|
self._filter_frame.connect('apply-filter',lambda w,m: self._tree_frame.set_model(m))
|
||||||
|
|
||||||
def _on_row_activated(self,widget,path,col):
|
def _on_row_activated(self,widget,path,col):
|
||||||
(model, iter) = widget.get_selection().get_selected()
|
(model, iter) = widget.get_selection().get_selected()
|
||||||
if iter and model.get_value(iter,self.__class__.__person_id_field):
|
if iter and model.get_value(iter,self.__class__.__person_id_field):
|
||||||
|
@ -83,14 +83,14 @@ class PersonTreeFrame(gtk.Frame):
|
|||||||
self._tree.expand_row(path,False)
|
self._tree.expand_row(path,False)
|
||||||
|
|
||||||
def change_db(self,db):
|
def change_db(self,db):
|
||||||
self.set_model(db)
|
self.set_model()
|
||||||
db.connect('person-add', self.person_added)
|
db.connect('person-add', self.person_added)
|
||||||
db.connect('person-update', self.person_updated)
|
db.connect('person-update', self.person_updated)
|
||||||
db.connect('person-delete', self.person_removed)
|
db.connect('person-delete', self.person_removed)
|
||||||
|
|
||||||
def set_model(self,db,data_filter=None):
|
def set_model(self,data_filter=None):
|
||||||
|
|
||||||
self._model = PeopleModel(db,data_filter=data_filter)
|
self._model = PeopleModel(self._dbstate.db,data_filter=data_filter)
|
||||||
|
|
||||||
self._tree.set_model(self._model)
|
self._tree.set_model(self._model)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user