* 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
07cbc8ec0a
commit
c4a640394d
@ -79,10 +79,11 @@ class EditPerson:
|
|||||||
"""Creates an edit window. Associates a person with the window."""
|
"""Creates an edit window. Associates a person with the window."""
|
||||||
|
|
||||||
self.person = person
|
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
|
self.parent = parent
|
||||||
if self.parent.child_windows.has_key(self.original_id):
|
if self.parent.child_windows.has_key(self.orig_id):
|
||||||
self.parent.child_windows[self.original_id].present(None)
|
self.parent.child_windows[self.orig_id].present(None)
|
||||||
return
|
return
|
||||||
self.db = db
|
self.db = db
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
@ -95,7 +96,7 @@ class EditPerson:
|
|||||||
self.update_death = 0
|
self.update_death = 0
|
||||||
self.pdmap = {}
|
self.pdmap = {}
|
||||||
self.add_places = []
|
self.add_places = []
|
||||||
self.should_guess_gender = (self.original_id == '' and
|
self.should_guess_gender = (self.orig_id == '' and
|
||||||
person.get_gender () ==
|
person.get_gender () ==
|
||||||
RelLib.Person.unknown)
|
RelLib.Person.unknown)
|
||||||
|
|
||||||
@ -423,7 +424,7 @@ class EditPerson:
|
|||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
||||||
def add_itself_to_winsmenu(self):
|
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)
|
win_menu_label = GrampsCfg.nameof(self.person)
|
||||||
if not win_menu_label.strip():
|
if not win_menu_label.strip():
|
||||||
win_menu_label = _("New Person")
|
win_menu_label = _("New Person")
|
||||||
@ -438,7 +439,7 @@ class EditPerson:
|
|||||||
self.winsmenu.append(self.menu_item)
|
self.winsmenu.append(self.menu_item)
|
||||||
|
|
||||||
def remove_itself_from_winsmenu(self):
|
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.menu_item.destroy()
|
||||||
self.winsmenu.destroy()
|
self.winsmenu.destroy()
|
||||||
self.win_menu_item.destroy()
|
self.win_menu_item.destroy()
|
||||||
@ -1043,7 +1044,7 @@ class EditPerson:
|
|||||||
|
|
||||||
def did_data_change(self):
|
def did_data_change(self):
|
||||||
"""Check to see if any of the data has changed from the
|
"""Check to see if any of the data has changed from the
|
||||||
original record"""
|
orig record"""
|
||||||
|
|
||||||
surname = unicode(self.surname_field.get_text())
|
surname = unicode(self.surname_field.get_text())
|
||||||
self.birth.set_date(unicode(self.bdate.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.person.set_source_reference_list(self.srcreflist)
|
||||||
|
|
||||||
self.update_lists()
|
self.update_lists()
|
||||||
if self.callback:
|
|
||||||
self.callback(self)
|
|
||||||
|
|
||||||
self.db.commit_person(self.person)
|
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)
|
self.close(1)
|
||||||
|
|
||||||
def get_place(self,field,makenew=0):
|
def get_place(self,field,makenew=0):
|
||||||
|
@ -31,6 +31,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
self.connect('row-deleted',self.on_row_deleted)
|
self.connect('row-deleted',self.on_row_deleted)
|
||||||
|
|
||||||
def rebuild_data(self):
|
def rebuild_data(self):
|
||||||
|
print "rebuild"
|
||||||
self.top_iter2path = {}
|
self.top_iter2path = {}
|
||||||
self.top_path2iter = {}
|
self.top_path2iter = {}
|
||||||
self.iter2path = {}
|
self.iter2path = {}
|
||||||
@ -68,7 +69,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
|||||||
|
|
||||||
def on_row_deleted(self,obj,path):
|
def on_row_deleted(self,obj,path):
|
||||||
self.rebuild_data()
|
self.rebuild_data()
|
||||||
|
|
||||||
def find_path(self,iter):
|
def find_path(self,iter):
|
||||||
if self.top_iter2path.has_key(iter):
|
if self.top_iter2path.has_key(iter):
|
||||||
return self.top_iter2path[iter]
|
return self.top_iter2path[iter]
|
||||||
|
@ -136,20 +136,12 @@ class PeopleView:
|
|||||||
def remove_from_person_list(self,person,old_id=None):
|
def remove_from_person_list(self,person,old_id=None):
|
||||||
"""Remove the selected person from the list. A person object is expected,
|
"""Remove the selected person from the list. A person object is expected,
|
||||||
not an ID"""
|
not an ID"""
|
||||||
person_id = person.get_id()
|
print old_id, person.get_id()
|
||||||
if old_id:
|
if old_id == None or person.get_id() == old_id:
|
||||||
del_id = old_id
|
path = self.person_model.find_path(person.get_id())
|
||||||
|
self.person_model.row_deleted(path)
|
||||||
else:
|
else:
|
||||||
del_id = person_id
|
self.person_model.rebuild_data()
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
def remove_from_history(self,person,old_id=None):
|
def remove_from_history(self,person,old_id=None):
|
||||||
"""Removes a person from the history list"""
|
"""Removes a person from the history list"""
|
||||||
@ -182,45 +174,7 @@ class PeopleView:
|
|||||||
self.goto_active_person()
|
self.goto_active_person()
|
||||||
|
|
||||||
def add_to_person_list(self,person,change):
|
def add_to_person_list(self,person,change):
|
||||||
key = person.get_id()
|
self.rebuild_data()
|
||||||
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()
|
|
||||||
|
|
||||||
def goto_active_person(self,first=0):
|
def goto_active_person(self,first=0):
|
||||||
if not self.parent.active_person:
|
if not self.parent.active_person:
|
||||||
@ -289,6 +243,3 @@ class PeopleView:
|
|||||||
|
|
||||||
def redisplay_person_list(self,person):
|
def redisplay_person_list(self,person):
|
||||||
self.person_model.rebuild_data()
|
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):
|
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 = gnome.program_init('gramps',const.version)
|
||||||
self.program.set_property('app-libdir','%s/lib' % const.prefixdir)
|
self.program.set_property('app-libdir','%s/lib' % const.prefixdir)
|
||||||
self.program.set_property('app-datadir','%s/share/gramps' % 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()
|
page = self.views.get_current_page()
|
||||||
if page == PERSON_VIEW:
|
if page == PERSON_VIEW:
|
||||||
|
|
||||||
mlist = self.people_view.person_tree.get_selected_objects()
|
mlist = self.people_view.get_selected_objects()
|
||||||
|
|
||||||
if len(mlist) != 2:
|
if len(mlist) != 2:
|
||||||
msg = _("Cannot merge people.")
|
msg = _("Cannot merge people.")
|
||||||
@ -1190,7 +1186,7 @@ class Gramps:
|
|||||||
|
|
||||||
def load_selected_people(self,obj):
|
def load_selected_people(self,obj):
|
||||||
"""Display the selected people in the EditPerson display"""
|
"""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]:
|
if mlist and self.active_person.get_id() == mlist[0]:
|
||||||
self.load_person(self.active_person)
|
self.load_person(self.active_person)
|
||||||
|
|
||||||
@ -1211,7 +1207,7 @@ class Gramps:
|
|||||||
def delete_person_clicked(self,obj):
|
def delete_person_clicked(self,obj):
|
||||||
cpage = self.views.get_current_page()
|
cpage = self.views.get_current_page()
|
||||||
if cpage == PERSON_VIEW:
|
if cpage == PERSON_VIEW:
|
||||||
mlist = self.people_view.person_tree.get_selected_objects()
|
mlist = self.people_view.get_selected_objects()
|
||||||
else:
|
else:
|
||||||
mlist = [ self.active_person.get_id() ]
|
mlist = [ self.active_person.get_id() ]
|
||||||
|
|
||||||
@ -1265,7 +1261,7 @@ class Gramps:
|
|||||||
self.people_view.remove_from_history(self.active_person)
|
self.people_view.remove_from_history(self.active_person)
|
||||||
self.db.remove_person_id(self.active_person.get_id())
|
self.db.remove_person_id(self.active_person.get_id())
|
||||||
self.people_view.remove_from_person_list(self.active_person)
|
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:
|
if self.hindex >= 0:
|
||||||
self.active_person = self.db.get_person(self.history[self.hindex])
|
self.active_person = self.db.get_person(self.history[self.hindex])
|
||||||
@ -1494,17 +1490,21 @@ class Gramps:
|
|||||||
for p in plist:
|
for p in plist:
|
||||||
self.place_view.new_place_after_edit(p)
|
self.place_view.new_place_after_edit(p)
|
||||||
|
|
||||||
def update_after_edit(self,epo):
|
def update_after_edit(self,epo,change=1):
|
||||||
if epo:
|
if epo:
|
||||||
self.db.build_person_display(epo.person.get_id(),epo.original_id)
|
if change:
|
||||||
self.people_view.remove_from_person_list(epo.person,epo.original_id)
|
print "change"
|
||||||
self.people_view.redisplay_person_list(epo.person)
|
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)
|
self.update_display(0)
|
||||||
|
|
||||||
def update_after_merge(self,person,old_id):
|
def update_after_merge(self,person,old_id):
|
||||||
if person:
|
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.people_view.redisplay_person_list(person)
|
||||||
self.update_display(0)
|
self.update_display(0)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user