* src/FamilyView.py: remove debug statement
* src/PeopleModel.py: abandon the attempt to use TreeFilter * src/PeopleView.py: abandon the attempt to use TreeFilter svn: r3792
This commit is contained in:
parent
5eb387daaf
commit
b51838f634
@ -1,3 +1,8 @@
|
|||||||
|
2004-12-09 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
|
* src/FamilyView.py: remove debug statement
|
||||||
|
* src/PeopleModel.py: abandon the attempt to use TreeFilter
|
||||||
|
* src/PeopleView.py: abandon the attempt to use TreeFilter
|
||||||
|
|
||||||
2004-12-07 Don Allingham <dallingham@users.sourceforge.net>
|
2004-12-07 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
* src/DbPrompter.py: destroy filechooser if open cancelled.
|
* src/DbPrompter.py: destroy filechooser if open cancelled.
|
||||||
* src/Report.py: Use markup in dialog
|
* src/Report.py: Use markup in dialog
|
||||||
|
@ -960,7 +960,6 @@ class FamilyView:
|
|||||||
|
|
||||||
flist = {}
|
flist = {}
|
||||||
|
|
||||||
print splist
|
|
||||||
for f in splist:
|
for f in splist:
|
||||||
fm = self.parent.db.get_family_from_handle(f)
|
fm = self.parent.db.get_family_from_handle(f)
|
||||||
if not fm:
|
if not fm:
|
||||||
|
@ -66,40 +66,31 @@ _CHANGE_COL= 21
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class PeopleModel(gtk.GenericTreeModel):
|
class PeopleModel(gtk.GenericTreeModel):
|
||||||
|
|
||||||
def __init__(self,db):
|
def __init__(self,db,data_filter):
|
||||||
gtk.GenericTreeModel.__init__(self)
|
gtk.GenericTreeModel.__init__(self)
|
||||||
|
|
||||||
self.db = db
|
self.db = db
|
||||||
self.visible = {}
|
self.visible = {}
|
||||||
self.top_visible = {}
|
self.top_visible = {}
|
||||||
|
self.rebuild_data(data_filter)
|
||||||
|
|
||||||
maps = self.db.get_people_view_maps()
|
def rebuild_data(self,data_filter):
|
||||||
if maps[0] != None and len(maps[0]) != 0:
|
self.data_filter = data_filter
|
||||||
self.top_path2iter = maps[0]
|
temp_top_path2iter = []
|
||||||
self.iter2path = maps[1]
|
temp_iter2path = {}
|
||||||
self.path2iter = maps[2]
|
temp_path2iter = {}
|
||||||
self.sname_sub = maps[3]
|
|
||||||
else:
|
|
||||||
self.rebuild_data()
|
|
||||||
|
|
||||||
def rebuild_data(self):
|
|
||||||
self.top_path2iter = []
|
|
||||||
self.iter2path = {}
|
|
||||||
self.path2iter = {}
|
|
||||||
self.sname_sub = {}
|
self.sname_sub = {}
|
||||||
self.visible = {}
|
|
||||||
self.top_visible = {}
|
|
||||||
|
|
||||||
if not self.db.is_open():
|
if not self.db.is_open():
|
||||||
return
|
return
|
||||||
|
|
||||||
cursor = self.db.get_person_cursor()
|
if data_filter:
|
||||||
|
keys = self.data_filter.apply(self.db,self.db.get_person_handles(sort_handles=False))
|
||||||
|
else:
|
||||||
|
keys = self.db.get_person_handles(sort_handles=False)
|
||||||
|
|
||||||
data = cursor.first()
|
for person_handle in keys:
|
||||||
while data:
|
person = self.db.get_person_from_handle(person_handle)
|
||||||
person = Person()
|
|
||||||
person_handle = data[0]
|
|
||||||
person.unserialize(data[1])
|
|
||||||
grp_as = person.get_primary_name().get_group_as()
|
grp_as = person.get_primary_name().get_group_as()
|
||||||
sn = person.get_primary_name().get_surname()
|
sn = person.get_primary_name().get_surname()
|
||||||
if grp_as:
|
if grp_as:
|
||||||
@ -112,20 +103,22 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
else:
|
else:
|
||||||
self.sname_sub[surname] = [person_handle]
|
self.sname_sub[surname] = [person_handle]
|
||||||
|
|
||||||
data = cursor.next()
|
temp_top_path2iter = self.sname_sub.keys()
|
||||||
cursor.close()
|
temp_top_path2iter.sort(locale.strcoll)
|
||||||
|
for name in temp_top_path2iter:
|
||||||
self.top_path2iter = self.sname_sub.keys()
|
|
||||||
self.top_path2iter.sort(locale.strcoll)
|
|
||||||
for name in self.top_path2iter:
|
|
||||||
val = 0
|
val = 0
|
||||||
entries = self.sname_sub[name]
|
entries = self.sname_sub[name]
|
||||||
entries.sort(self.byname)
|
entries.sort(self.byname)
|
||||||
for person_handle in entries:
|
for person_handle in entries:
|
||||||
tpl = (name,val)
|
tpl = (name,val)
|
||||||
self.iter2path[person_handle] = tpl
|
temp_iter2path[person_handle] = tpl
|
||||||
self.path2iter[tpl] = person_handle
|
temp_path2iter[tpl] = person_handle
|
||||||
val += 1
|
val += 1
|
||||||
|
|
||||||
|
self.top_path2iter = temp_top_path2iter
|
||||||
|
self.iter2path = temp_iter2path
|
||||||
|
self.path2iter = temp_path2iter
|
||||||
|
|
||||||
self.db.set_people_view_maps(self.get_maps())
|
self.db.set_people_view_maps(self.get_maps())
|
||||||
|
|
||||||
def get_maps(self):
|
def get_maps(self):
|
||||||
@ -188,16 +181,10 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
return u'error'
|
return u'error'
|
||||||
|
|
||||||
def reset_visible(self):
|
def reset_visible(self):
|
||||||
self.visible = {}
|
pass
|
||||||
self.top_visible = {}
|
|
||||||
|
|
||||||
def set_visible(self,node,val):
|
def set_visible(self,node,val):
|
||||||
try:
|
pass
|
||||||
col = self.iter2path[node]
|
|
||||||
self.top_visible[col[0]] = val
|
|
||||||
self.visible[node] = val
|
|
||||||
except:
|
|
||||||
self.visible[node] = val
|
|
||||||
|
|
||||||
def on_iter_next(self, node):
|
def on_iter_next(self, node):
|
||||||
'''returns the next node at this level of the tree'''
|
'''returns the next node at this level of the tree'''
|
||||||
@ -234,11 +221,14 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def on_iter_nth_child(self,node,n):
|
def on_iter_nth_child(self,node,n):
|
||||||
if node == None:
|
|
||||||
return self.top_path2iter[n]
|
|
||||||
try:
|
try:
|
||||||
return self.path2iter[(node,n)]
|
if node == None:
|
||||||
except:
|
return self.top_path2iter[n]
|
||||||
|
try:
|
||||||
|
return self.path2iter[(node,n)]
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
except IndexError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def on_iter_parent(self, node):
|
def on_iter_parent(self, node):
|
||||||
@ -315,9 +305,6 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
def column_bold(self,data,node):
|
def column_bold(self,data,node):
|
||||||
return pango.WEIGHT_NORMAL
|
return pango.WEIGHT_NORMAL
|
||||||
|
|
||||||
def column_view(self,data,node):
|
|
||||||
return self.visible.has_key(node)
|
|
||||||
|
|
||||||
def column_header(self,node):
|
def column_header(self,node):
|
||||||
return node
|
return node
|
||||||
|
|
||||||
@ -325,7 +312,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
return pango.WEIGHT_NORMAL #BOLD
|
return pango.WEIGHT_NORMAL #BOLD
|
||||||
|
|
||||||
def column_header_view(self,node):
|
def column_header_view(self,node):
|
||||||
return self.top_visible.has_key(node)
|
return True
|
||||||
|
|
||||||
_GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
|
_GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
|
||||||
|
|
||||||
@ -346,7 +333,6 @@ COLUMN_DEFS = [
|
|||||||
|
|
||||||
# these columns are hidden, and must always be last in the list
|
# these columns are hidden, and must always be last in the list
|
||||||
(PeopleModel.column_sort_name, None, gobject.TYPE_STRING),
|
(PeopleModel.column_sort_name, None, gobject.TYPE_STRING),
|
||||||
(PeopleModel.column_view, PeopleModel.column_header_view,gobject.TYPE_BOOLEAN),
|
|
||||||
(PeopleModel.column_bold, PeopleModel.column_header_bold,gobject.TYPE_INT),
|
(PeopleModel.column_bold, PeopleModel.column_header_bold,gobject.TYPE_INT),
|
||||||
(PeopleModel.column_int_id, None, gobject.TYPE_STRING),
|
(PeopleModel.column_int_id, None, gobject.TYPE_STRING),
|
||||||
]
|
]
|
||||||
@ -354,7 +340,6 @@ COLUMN_DEFS = [
|
|||||||
# dynamic calculation of column indices, for use by various Views
|
# dynamic calculation of column indices, for use by various Views
|
||||||
COLUMN_INT_ID = len(COLUMN_DEFS) - 1
|
COLUMN_INT_ID = len(COLUMN_DEFS) - 1
|
||||||
COLUMN_BOLD = COLUMN_INT_ID - 1
|
COLUMN_BOLD = COLUMN_INT_ID - 1
|
||||||
COLUMN_VIEW = COLUMN_BOLD - 1
|
|
||||||
|
|
||||||
# indices into main column definition table
|
# indices into main column definition table
|
||||||
COLUMN_DEF_LIST = 0
|
COLUMN_DEF_LIST = 0
|
||||||
|
@ -115,10 +115,8 @@ class PeopleView:
|
|||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
def build_tree(self):
|
def build_tree(self):
|
||||||
self.person_model = PeopleModel.PeopleModel(self.parent.db)
|
self.person_model = PeopleModel.PeopleModel(self.parent.db,self.DataFilter)
|
||||||
#self.sort_model = self.person_model
|
self.sort_model = self.person_model
|
||||||
self.sort_model = self.person_model.filter_new()
|
|
||||||
self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW)
|
|
||||||
self.person_tree.set_model(self.sort_model)
|
self.person_tree.set_model(self.sort_model)
|
||||||
|
|
||||||
def blist(self, store, path, node, id_list):
|
def blist(self, store, path, node, id_list):
|
||||||
@ -147,10 +145,10 @@ class PeopleView:
|
|||||||
|
|
||||||
def change_db(self,db):
|
def change_db(self,db):
|
||||||
self.build_columns()
|
self.build_columns()
|
||||||
self.person_model = PeopleModel.PeopleModel(db)
|
self.person_model = PeopleModel.PeopleModel(db,self.DataFilter)
|
||||||
#self.sort_model = self.person_model
|
self.sort_model = self.person_model
|
||||||
self.sort_model = self.person_model.filter_new()
|
#self.sort_model = self.person_model.filter_new()
|
||||||
self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW)
|
#self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW)
|
||||||
self.apply_filter()
|
self.apply_filter()
|
||||||
self.person_tree.set_model(self.sort_model)
|
self.person_tree.set_model(self.sort_model)
|
||||||
|
|
||||||
@ -193,32 +191,26 @@ class PeopleView:
|
|||||||
if not self.parent.active_person:
|
if not self.parent.active_person:
|
||||||
return
|
return
|
||||||
p = self.parent.active_person
|
p = self.parent.active_person
|
||||||
path = self.person_model.on_get_path(p.get_handle())
|
try:
|
||||||
group_name = p.get_primary_name().get_group_name()
|
path = self.person_model.on_get_path(p.get_handle())
|
||||||
top_name = self.parent.db.get_name_group_mapping(group_name)
|
group_name = p.get_primary_name().get_group_name()
|
||||||
top_path = self.person_model.on_get_path(top_name)
|
top_name = self.parent.db.get_name_group_mapping(group_name)
|
||||||
self.person_tree.expand_row(top_path,0)
|
top_path = self.person_model.on_get_path(top_name)
|
||||||
self.person_selection.select_path(path)
|
self.person_tree.expand_row(top_path,0)
|
||||||
self.person_tree.scroll_to_cell(path,None,1,0.5,0)
|
self.person_selection.select_path(path)
|
||||||
|
self.person_tree.scroll_to_cell(path,None,1,0.5,0)
|
||||||
|
except KeyError:
|
||||||
|
self.person_selection.unselect_all()
|
||||||
|
print "Person not currently available due to filter"
|
||||||
|
self.parent.active_person = p
|
||||||
|
|
||||||
def alpha_event(self,*obj):
|
def alpha_event(self,*obj):
|
||||||
self.parent.load_person(self.parent.active_person)
|
self.parent.load_person(self.parent.active_person)
|
||||||
|
|
||||||
def apply_filter(self,current_model=None):
|
def apply_filter(self,current_model=None):
|
||||||
self.person_model.rebuild_data()
|
|
||||||
self.parent.status_text(_('Updating display...'))
|
self.parent.status_text(_('Updating display...'))
|
||||||
keys = self.DataFilter.apply(
|
self.build_tree()
|
||||||
self.parent.db,
|
|
||||||
self.parent.db.get_person_handles(sort_handles=False))
|
|
||||||
self.person_model.reset_visible()
|
|
||||||
for person_handle in keys:
|
|
||||||
self.person_model.set_visible(person_handle,True)
|
|
||||||
|
|
||||||
print "Applying filter"
|
|
||||||
self.sort_model.refilter()
|
|
||||||
print "Done"
|
|
||||||
self.parent.modify_statusbar()
|
self.parent.modify_statusbar()
|
||||||
print "exit"
|
|
||||||
|
|
||||||
def on_plist_button_press(self,obj,event):
|
def on_plist_button_press(self,obj,event):
|
||||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||||
@ -265,7 +257,7 @@ class PeopleView:
|
|||||||
menu.popup(None,None,None,event.button,event.time)
|
menu.popup(None,None,None,event.button,event.time)
|
||||||
|
|
||||||
def redisplay_person_list(self,person):
|
def redisplay_person_list(self,person):
|
||||||
self.person_model.rebuild_data()
|
self.person_model.rebuild_data(self.DataFilter)
|
||||||
self.add_person(person)
|
self.add_person(person)
|
||||||
|
|
||||||
def add_person(self,person):
|
def add_person(self,person):
|
||||||
@ -294,7 +286,7 @@ class PeopleView:
|
|||||||
|
|
||||||
def update_person_list(self,person):
|
def update_person_list(self,person):
|
||||||
self.delete_person(person)
|
self.delete_person(person)
|
||||||
self.person_model.rebuild_data()
|
self.person_model.rebuild_data(self.DataFilter)
|
||||||
self.add_person(person)
|
self.add_person(person)
|
||||||
self.parent.change_active_person(person)
|
self.parent.change_active_person(person)
|
||||||
self.goto_active_person()
|
self.goto_active_person()
|
||||||
|
Loading…
Reference in New Issue
Block a user