Speed up place accesses

svn: r754
This commit is contained in:
Don Allingham 2002-02-05 22:41:06 +00:00
parent f37364732c
commit fa508db0f2
5 changed files with 74 additions and 31 deletions

View File

@ -82,6 +82,8 @@ class EditPerson:
self.update_birth = 0
self.update_death = 0
self.pmap = {}
self.add_places = []
for p in db.getPlaces():
self.pmap[p.get_title()] = p
@ -106,7 +108,6 @@ class EditPerson:
"on_apply_person_clicked" : self.on_apply_person_clicked,
"on_attr_button_press" : self.attr_double_click,
"on_attr_list_select_row" : self.on_attr_list_select_row,
"on_combo_insert_text" : utils.combo_insert_text,
"on_edit_birth_clicked" : self.on_edit_birth_clicked,
"on_edit_death_clicked" : self.on_edit_death_clicked,
"on_delete_address_clicked" : self.on_delete_addr_clicked,
@ -641,7 +642,7 @@ class EditPerson:
import EventEdit
pname = self.person.getPrimaryName().getName()
EventEdit.EventEditor(self,pname,const.personalEvents,
const.save_fevent,None,None,0)
const.save_fevent,None,None,0,self.callback)
def on_edit_birth_clicked(self,obj):
"""Brings up the EventEditor for the birth record, event
@ -657,7 +658,8 @@ class EditPerson:
if p != None:
event.setPlace(p)
EventEdit.EventEditor(self,pname,const.personalEvents,
const.save_fevent,event,def_placename,1)
const.save_fevent,event,def_placename,1,
self.callback)
def on_edit_death_clicked(self,obj):
"""Brings up the EventEditor for the death record, event
@ -673,7 +675,8 @@ class EditPerson:
if p != None:
event.setPlace(p)
EventEdit.EventEditor(self,pname,const.personalEvents,\
const.save_fevent,event,def_placename,1)
const.save_fevent,event,def_placename,1,
self.callback)
def on_aka_delete_clicked(self,obj):
"""Deletes the selected name from the name list"""
@ -932,7 +935,9 @@ class EditPerson:
return
pname = self.person.getPrimaryName().getName()
event = obj.get_row_data(obj.selection[0])
EventEdit.EventEditor(self,pname,const.personalEvents,const.save_fevent,event,None,0)
EventEdit.EventEditor(self,pname,const.personalEvents,
const.save_fevent,event,None,0,
self.callback)
def on_event_select_row(self,obj,row,b,c):
event = obj.get_row_data(row)
@ -1206,7 +1211,7 @@ class EditPerson:
self.update_lists()
if self.callback:
self.callback(self)
self.callback(self,self.add_places)
utils.destroy_passed_object(obj)
def get_place(self,field,makenew=0):
@ -1219,6 +1224,7 @@ class EditPerson:
place.set_title(text)
self.pmap[text] = place
self.db.addPlace(place)
self.add_places.append(place)
utils.modified()
return place
else:

View File

@ -51,10 +51,12 @@ _ = gettext
#-------------------------------------------------------------------------
class EventEditor:
def __init__(self,parent,name,list,trans,event,def_placename,read_only):
def __init__(self,parent,name,list,trans,event,def_placename,read_only,cb):
self.parent = parent
self.event = event
self.trans = trans
self.callback = cb
self.plist = []
self.pmap = {}
for p in self.parent.db.getPlaces():
@ -157,6 +159,7 @@ class EventEditor:
place.set_title(text)
self.pmap[text] = place
self.parent.db.addPlace(place)
self.plist.append(place)
utils.modified()
return place
else:
@ -184,6 +187,7 @@ class EventEditor:
self.update_event(ename,self.date,eplace_obj,edesc,enote,epriv,ecause)
self.parent.redraw_event_list()
self.callback(None,self.plist)
utils.destroy_passed_object(obj)
def update_event(self,name,date,place,desc,note,priv,cause):

View File

@ -59,11 +59,12 @@ pycode_tgts = [('fevent', 0, 0),
#-------------------------------------------------------------------------
class Marriage:
def __init__(self,family,db):
def __init__(self,family,db,callback):
"""Initializes the Marriage class, and displays the window"""
self.family = family
self.db = db
self.path = db.getSavePath()
self.cb = callback
self.top = libglade.GladeXML(const.marriageFile,"marriageEditor")
top_window = self.get_widget("marriageEditor")
@ -427,7 +428,8 @@ class Marriage:
def on_add_clicked(self,obj):
import EventEdit
name = utils.family_name(self.family)
EventEdit.EventEditor(self,name,const.marriageEvents,const.save_pevent,None,None,0)
EventEdit.EventEditor(self,name,const.marriageEvents,
const.save_pevent,None,None,0,self.cb)
def on_update_clicked(self,obj):
import EventEdit
@ -436,7 +438,8 @@ class Marriage:
event = obj.get_row_data(obj.selection[0])
name = utils.family_name(self.family)
EventEdit.EventEditor(self,name,const.marriageEvents,const.save_pevent,event,None,0)
EventEdit.EventEditor(self,name,const.marriageEvents,
const.save_pevent,event,None,0,self.cb)
def on_delete_clicked(self,obj):
if utils.delete_selected(obj,self.elist):

View File

@ -80,10 +80,8 @@ class PlaceView:
self.place_list.set_column_visibility(1,Config.id_visible)
index = 0
places = self.db.getPlaceMap().values()
u = string.upper
for src in places:
for src in self.db.getPlaceMap().values():
title = src.get_title()
id = src.getId()
mloc = src.get_main_location()
@ -167,12 +165,35 @@ class PlaceView:
self.place_list.moveto(self.place_list.find_row_from_data(sel))
obj.thaw()
def insert_place(self,place):
title = place.get_title()
id = place.getId()
mloc = place.get_main_location()
city = mloc.get_city()
county = mloc.get_county()
state = mloc.get_state()
parish = mloc.get_parish()
country = mloc.get_country()
u = string.upper
self.place_list.append([title,id,parish,city,county,state,country,
u(title), u(parish), u(city),
u(county),u(state), u(country)])
self.place_list.set_row_data(self.place_list.rows-1,place)
def new_place_after_edit(self,place):
self.place_list.freeze()
self.db.addPlace(place)
self.update_display(0)
self.insert_place(place)
self.place_list.sort()
self.place_list.thaw()
def update_display_after_edit(self,place):
self.update_display(0)
self.place_list.freeze()
index = self.place_list.find_row_from_data(place)
self.place_list.remove(index)
self.insert_place(place)
self.place_list.sort()
self.place_list.thaw()
def on_add_place_clicked(self,obj):
EditPlace.EditPlace(Place(),self.db,self.new_place_after_edit)
@ -203,10 +224,10 @@ class PlaceView:
msg = _("This place is currently being used. Delete anyway?")
gnome.ui.GnomeQuestionDialog(msg,ans.query_response)
else:
obj.remove(index)
map = self.db.getPlaceMap()
del map[place.getId()]
utils.modified()
self.update_display(0)
def on_edit_place_clicked(self,obj):
"""Display the selected places in the EditPlace display"""
@ -218,3 +239,6 @@ class PlaceView:
place = obj.get_row_data(p)
EditPlace.EditPlace(place,self.db,self.update_display_after_edit)

View File

@ -284,7 +284,7 @@ def on_add_sp_clicked(obj):
def on_edit_sp_clicked(obj):
"""Edit the marriage information for the current family"""
if active_person:
Marriage.Marriage(active_family,database)
Marriage.Marriage(active_family,database,new_after_edit)
def on_delete_sp_clicked(obj):
"""Delete the currently selected spouse from the family"""
@ -477,7 +477,7 @@ def update_display(changed):
elif page == 3:
source_view.load_sources()
elif page == 4:
place_view.load_places()
pass
else:
media_view.load_media()
@ -1279,7 +1279,7 @@ def on_notebook1_switch_page(obj,junk,page):
source_view.load_sources()
elif page == 4:
merge_button.set_sensitive(1)
place_view.load_places()
#place_view.load_places()
elif page == 5:
merge_button.set_sensitive(0)
media_view.load_media()
@ -1340,13 +1340,16 @@ def on_spouselist_changed(obj):
#
#
#-------------------------------------------------------------------------
def new_after_edit(epo):
if epo.person.getId() == "":
database.addPerson(epo.person)
else:
database.addPersonNoMap(epo.person,epo.person.getId())
change_active_person(epo.person)
redisplay_person_list(epo.person)
def new_after_edit(epo,plist):
if epo:
if epo.person.getId() == "":
database.addPerson(epo.person)
else:
database.addPersonNoMap(epo.person,epo.person.getId())
change_active_person(epo.person)
redisplay_person_list(epo.person)
for p in plist:
place_view.new_place_after_edit(p)
#-------------------------------------------------------------------------
#
@ -1362,9 +1365,12 @@ def update_after_newchild(family,person):
#
#
#-------------------------------------------------------------------------
def update_after_edit(epo):
remove_from_person_list(epo.person)
redisplay_person_list(epo.person)
def update_after_edit(epo,plist):
if epo:
remove_from_person_list(epo.person)
redisplay_person_list(epo.person)
for p in plist:
place_view.new_place_after_edit(p)
update_display(0)
#-------------------------------------------------------------------------