* src/EditPerson.py: TreeView enhancements
* src/PeopleModel.py: TreeView enhancements * src/PeopleView.py: TreeView enhancements * src/gramps_main.py: TreeView enhancements svn: r2984
This commit is contained in:
parent
ee99826261
commit
fbb05c44eb
@ -79,10 +79,11 @@ class EditPerson:
|
||||
"""Creates an edit window. Associates a person with the window."""
|
||||
|
||||
self.person = person
|
||||
self.original_id = person.get_id()
|
||||
self.orig_id = person.get_id()
|
||||
self.orig_surname = person.get_primary_name().get_surname()
|
||||
self.parent = parent
|
||||
if self.parent.child_windows.has_key(self.original_id):
|
||||
self.parent.child_windows[self.original_id].present(None)
|
||||
if self.parent.child_windows.has_key(self.orig_id):
|
||||
self.parent.child_windows[self.orig_id].present(None)
|
||||
return
|
||||
self.db = db
|
||||
self.callback = callback
|
||||
@ -95,7 +96,7 @@ class EditPerson:
|
||||
self.update_death = 0
|
||||
self.pdmap = {}
|
||||
self.add_places = []
|
||||
self.should_guess_gender = (self.original_id == '' and
|
||||
self.should_guess_gender = (self.orig_id == '' and
|
||||
person.get_gender () ==
|
||||
RelLib.Person.unknown)
|
||||
|
||||
@ -423,7 +424,7 @@ class EditPerson:
|
||||
self.window.destroy()
|
||||
|
||||
def add_itself_to_winsmenu(self):
|
||||
self.parent.child_windows[self.original_id] = self
|
||||
self.parent.child_windows[self.orig_id] = self
|
||||
win_menu_label = GrampsCfg.nameof(self.person)
|
||||
if not win_menu_label.strip():
|
||||
win_menu_label = _("New Person")
|
||||
@ -438,7 +439,7 @@ class EditPerson:
|
||||
self.winsmenu.append(self.menu_item)
|
||||
|
||||
def remove_itself_from_winsmenu(self):
|
||||
del self.parent.child_windows[self.original_id]
|
||||
del self.parent.child_windows[self.orig_id]
|
||||
self.menu_item.destroy()
|
||||
self.winsmenu.destroy()
|
||||
self.win_menu_item.destroy()
|
||||
@ -1043,7 +1044,7 @@ class EditPerson:
|
||||
|
||||
def did_data_change(self):
|
||||
"""Check to see if any of the data has changed from the
|
||||
original record"""
|
||||
orig record"""
|
||||
|
||||
surname = unicode(self.surname_field.get_text())
|
||||
self.birth.set_date(unicode(self.bdate.get_text()))
|
||||
@ -1576,10 +1577,12 @@ class EditPerson:
|
||||
self.person.set_source_reference_list(self.srcreflist)
|
||||
|
||||
self.update_lists()
|
||||
if self.callback:
|
||||
self.callback(self)
|
||||
|
||||
self.db.commit_person(self.person)
|
||||
|
||||
if self.callback:
|
||||
change = (self.orig_surname != surname) or (self.orig_id != idval)
|
||||
self.callback(self,change)
|
||||
|
||||
self.close(1)
|
||||
|
||||
def get_place(self,field,makenew=0):
|
||||
|
@ -31,6 +31,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
self.connect('row-deleted',self.on_row_deleted)
|
||||
|
||||
def rebuild_data(self):
|
||||
print "rebuild"
|
||||
self.top_iter2path = {}
|
||||
self.top_path2iter = {}
|
||||
self.iter2path = {}
|
||||
@ -68,7 +69,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def on_row_deleted(self,obj,path):
|
||||
self.rebuild_data()
|
||||
|
||||
|
||||
def find_path(self,iter):
|
||||
if self.top_iter2path.has_key(iter):
|
||||
return self.top_iter2path[iter]
|
||||
|
@ -136,20 +136,12 @@ class PeopleView:
|
||||
def remove_from_person_list(self,person,old_id=None):
|
||||
"""Remove the selected person from the list. A person object is expected,
|
||||
not an ID"""
|
||||
person_id = person.get_id()
|
||||
if old_id:
|
||||
del_id = old_id
|
||||
print old_id, person.get_id()
|
||||
if old_id == None or person.get_id() == old_id:
|
||||
path = self.person_model.find_path(person.get_id())
|
||||
self.person_model.row_deleted(path)
|
||||
else:
|
||||
del_id = person_id
|
||||
|
||||
if self.id2col.has_key(del_id):
|
||||
(model,iter) = self.id2col[del_id]
|
||||
if iter:
|
||||
model.remove(iter)
|
||||
del self.id2col[del_id]
|
||||
|
||||
if person == self.parent.active_person:
|
||||
self.parent.active_person = None
|
||||
self.person_model.rebuild_data()
|
||||
|
||||
def remove_from_history(self,person,old_id=None):
|
||||
"""Removes a person from the history list"""
|
||||
@ -182,45 +174,7 @@ class PeopleView:
|
||||
self.goto_active_person()
|
||||
|
||||
def add_to_person_list(self,person,change):
|
||||
key = person.get_id()
|
||||
val = self.parent.db.get_person_display(key)
|
||||
pg = unicode(val[5])
|
||||
pg = pg[0]
|
||||
model = None
|
||||
if self.DataFilter.compare(person):
|
||||
|
||||
if pg and pg != '@':
|
||||
if not self.alpha_page.has_key(pg):
|
||||
self.create_new_panel(pg)
|
||||
model = self.alpha_page[pg]
|
||||
else:
|
||||
model = self.default_list
|
||||
|
||||
if val[3]:
|
||||
bdate = self.parent.db.find_event_from_id(val[3]).get_date()
|
||||
else:
|
||||
bdate = ""
|
||||
|
||||
if val[4]:
|
||||
ddate = self.parent.db.find_event_from_id(val[4]).get_date()
|
||||
else:
|
||||
ddate = ""
|
||||
|
||||
iter = model.add([val[0],val[1],val[2],bdate,ddate,val[5],
|
||||
val[6],val[7],val[8]],1)
|
||||
|
||||
self.id2col[key] = (model,iter)
|
||||
|
||||
if change:
|
||||
self.parent.change_active_person(person)
|
||||
|
||||
try:
|
||||
self.goto_active_person()
|
||||
except:
|
||||
print "goto failed"
|
||||
|
||||
if model:
|
||||
model.enable_sort()
|
||||
self.rebuild_data()
|
||||
|
||||
def goto_active_person(self,first=0):
|
||||
if not self.parent.active_person:
|
||||
@ -289,6 +243,3 @@ class PeopleView:
|
||||
|
||||
def redisplay_person_list(self,person):
|
||||
self.person_model.rebuild_data()
|
||||
|
||||
def update_person_list(self,person,old_id):
|
||||
self.person_model.rebuild_data()
|
||||
|
@ -99,10 +99,6 @@ class Gramps:
|
||||
|
||||
def __init__(self,args):
|
||||
|
||||
self.pl_titles = [ (_('Name'),5,250), (_('ID'),1,50),(_('Gender'),2,70),
|
||||
(_('Birth date'),6,150),(_('Death date'),7,150), ('',5,0),
|
||||
('',6,0), ('',7,0) ]
|
||||
|
||||
self.program = gnome.program_init('gramps',const.version)
|
||||
self.program.set_property('app-libdir','%s/lib' % const.prefixdir)
|
||||
self.program.set_property('app-datadir','%s/share/gramps' % const.prefixdir)
|
||||
@ -730,7 +726,7 @@ class Gramps:
|
||||
page = self.views.get_current_page()
|
||||
if page == PERSON_VIEW:
|
||||
|
||||
mlist = self.people_view.person_tree.get_selected_objects()
|
||||
mlist = self.people_view.get_selected_objects()
|
||||
|
||||
if len(mlist) != 2:
|
||||
msg = _("Cannot merge people.")
|
||||
@ -1190,7 +1186,7 @@ class Gramps:
|
||||
|
||||
def load_selected_people(self,obj):
|
||||
"""Display the selected people in the EditPerson display"""
|
||||
mlist = self.people_view.person_tree.get_selected_objects()
|
||||
mlist = self.people_view.get_selected_objects()
|
||||
if mlist and self.active_person.get_id() == mlist[0]:
|
||||
self.load_person(self.active_person)
|
||||
|
||||
@ -1211,7 +1207,7 @@ class Gramps:
|
||||
def delete_person_clicked(self,obj):
|
||||
cpage = self.views.get_current_page()
|
||||
if cpage == PERSON_VIEW:
|
||||
mlist = self.people_view.person_tree.get_selected_objects()
|
||||
mlist = self.people_view.get_selected_objects()
|
||||
else:
|
||||
mlist = [ self.active_person.get_id() ]
|
||||
|
||||
@ -1265,7 +1261,7 @@ class Gramps:
|
||||
self.people_view.remove_from_history(self.active_person)
|
||||
self.db.remove_person_id(self.active_person.get_id())
|
||||
self.people_view.remove_from_person_list(self.active_person)
|
||||
self.people_view.person_model.sort_column_changed()
|
||||
#self.people_view.person_model.sort_column_changed()
|
||||
|
||||
if self.hindex >= 0:
|
||||
self.active_person = self.db.get_person(self.history[self.hindex])
|
||||
@ -1494,17 +1490,21 @@ class Gramps:
|
||||
for p in plist:
|
||||
self.place_view.new_place_after_edit(p)
|
||||
|
||||
def update_after_edit(self,epo):
|
||||
def update_after_edit(self,epo,change=1):
|
||||
if epo:
|
||||
self.db.build_person_display(epo.person.get_id(),epo.original_id)
|
||||
self.people_view.remove_from_person_list(epo.person,epo.original_id)
|
||||
self.people_view.redisplay_person_list(epo.person)
|
||||
if change:
|
||||
print "change"
|
||||
self.people_view.redisplay_person_list(epo.person)
|
||||
else:
|
||||
print "no change"
|
||||
iter = self.people_view.person_model.get_iter((0,))
|
||||
id = epo.person.get_id()
|
||||
path = self.people_view.person_model.find_path(id)
|
||||
self.people_view.person_model.row_changed(path,iter)
|
||||
self.update_display(0)
|
||||
|
||||
def update_after_merge(self,person,old_id):
|
||||
if person:
|
||||
self.people_view.remove_from_person_list(person.get_id(),old_id)
|
||||
self.db.build_person_display(person.get_id(),old_id)
|
||||
self.people_view.redisplay_person_list(person)
|
||||
self.update_display(0)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user