* src/GrampsDbBase.py: correctly handle signals when undoing a

delete operation
* src/PeopleView.py: remove unused signal
* src/gramps_main.py: handle history mechanism with new signal scheme,
avoiding the double active-changed when selecting an element


svn: r4326
This commit is contained in:
Don Allingham 2005-04-09 00:31:39 +00:00
parent a83de42a94
commit f70a65446a
4 changed files with 43 additions and 70 deletions

View File

@ -1,3 +1,10 @@
2005-04-08 Don Allingham <don@gramps-project.org>
* src/GrampsDbBase.py: correctly handle signals when undoing a
delete operation
* src/PeopleView.py: remove unused signal
* src/gramps_main.py: handle history mechanism with new signal scheme,
avoiding the double active-changed when selecting an element
2005-04-08 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/Utils.py (probably_alive): Added two more checks for birth and death year

View File

@ -738,30 +738,6 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
"""
assert False, "Needs to be overridden in the derived class"
def get_people_view_maps(self):
"""
Allows the saving people display data into the database metadata.
This allows faster display of the treeview.
"""
if self.metadata:
return (self.metadata.get('tp_path'),
self.metadata.get('p_iter'),
self.metadata.get('p_path'),
self.metadata.get('sname'))
else:
return (None,None,None,None)
def set_people_view_maps(self,maps):
"""
Allows the retreiving people display data into the database metadata.
This allows faster display of the treeview.
"""
if self.metadata and not self.readonly:
self.metadata['tp_path'] = maps[0]
self.metadata['p_iter'] = maps[1]
self.metadata['p_path'] = maps[2]
self.metadata['sname'] = maps[3]
def get_number_of_people(self):
"""
Returns the number of people currently in the databse.
@ -975,46 +951,22 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
subitems.reverse()
for record_id in subitems:
(key, handle, data) = transaction.get_record(record_id)
handle = str(handle)
if key == PERSON_KEY:
if data == None:
self.emit('person-delete',([str(handle)],))
del self.person_map[str(handle)]
else:
self.person_map[str(handle)] = data
self.emit('person-update',([str(handle)],))
self.undo_data(data,handle,self.person_map,'person')
elif key == FAMILY_KEY:
if data == None:
self.emit('family-delete',([str(handle)],))
del self.family_map[str(handle)]
else:
self.family_map[str(handle)] = data
self.emit('family-update',([str(handle)],))
self.undo_data(data,handle,self.family_map,'family')
elif key == SOURCE_KEY:
if data == None:
self.emit('source-delete',([str(handle)],))
del self.source_map[str(handle)]
else:
self.source_map[str(handle)] = data
self.emit('source-update',([str(handle)],))
self.undo_data(data,handle,self.source_map,'source')
elif key == EVENT_KEY:
if data == None:
del self.event_map[str(handle)]
del self.event_map[handle]
else:
self.event_map[str(handle)] = data
self.event_map[handle] = data
elif key == PLACE_KEY:
if data == None:
self.emit('place-delete',([str(handle)],))
del self.place_map[str(handle)]
else:
self.place_map[str(handle)] = data
self.emit('place-update',([str(handle)],))
self.undo_data(data,handle,self.place_map,'place')
elif key == MEDIA_KEY:
if data == None:
self.emit('media-delete',([str(handle)],))
del self.media_map[str(handle)]
else:
self.emit('media-update',([str(handle)],))
self.media_map[str(handle)] = data
self.undo_data(data,handle,self.media_map,'media')
if self.undo_callback:
if self.undoindex == -1:
@ -1023,6 +975,18 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
transaction = self.translist[self.undoindex]
self.undo_callback(_("_Undo %s") % transaction.get_description())
return True
def undo_data(self,data,handle,db_map,signal_root):
if data == None:
self.emit(signal_root + '-delete',([handle],))
del db_map[handle]
else:
if db_map.has_key(handle):
signal = signal_root + '-update'
else:
signal = signal_root + '-add'
db_map[handle] = data
self.emit(signal,([handle],))
def set_undo_callback(self,callback):
"""

View File

@ -238,9 +238,6 @@ class PeopleView:
self.apply_filter()
self.goto_active_person()
def add_to_person_list(self,person,change=0):
pass
def goto_active_person(self):
if not self.parent.active_person:
return

View File

@ -116,7 +116,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
def __init__(self,args):
GrampsDBCallback.GrampsDBCallback.__init__(self)
try:
self.program = gnome.program_init('gramps',const.version,
gnome.libgnome_module_info_get(),
@ -133,7 +133,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
self.bookmarks = None
self.c_details = 6
self.cl = 0
self.lock_history = False
self.history = []
self.mhistory = []
@ -510,7 +510,6 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
def exit_and_undo(self,*args):
self.db.disable_signals()
self.db.abort_changes()
self.db.set_people_view_maps((None,None,None,None))
gtk.main_quit()
def set_person_column_order(self,list):
@ -723,12 +722,14 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
ScratchPad.ScratchPadWindow(self.db, self)
def back_clicked(self,obj,step=1):
self.lock_history = True
if self.hindex > 0:
try:
self.hindex -= step
self.active_person = self.db.get_person_from_handle(self.history[self.hindex])
handle = unicode(self.history[self.hindex])
self.active_person = self.db.get_person_from_handle(handle)
self.modify_statusbar()
self.update_display(0)
self.emit('active-changed',(handle,))
self.mhistory.append(self.history[self.hindex])
self.redraw_histmenu()
self.set_buttons(1)
@ -748,14 +749,17 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
self.fwdbtn.set_sensitive(1)
self.forward.set_sensitive(1)
self.goto_active_person()
self.lock_history = False
def fwd_clicked(self,obj,step=1):
self.lock_history = True
if self.hindex+1 < len(self.history):
try:
self.hindex += step
self.active_person = self.db.get_person_from_handle(self.history[self.hindex])
handle = unicode(self.history[self.hindex])
self.active_person = self.db.get_person_from_handle(handle)
self.modify_statusbar()
self.update_display(0)
self.emit('active-changed',(handle,))
self.mhistory.append(self.history[self.hindex])
self.redraw_histmenu()
self.set_buttons(1)
@ -775,6 +779,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
self.backbtn.set_sensitive(1)
self.back.set_sensitive(1)
self.goto_active_person()
self.lock_history = False
def edit_button_clicked(self,obj):
cpage = self.views.get_current_page()
@ -1453,13 +1458,13 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
self.set_buttons(0)
self.active_person = None
self.modify_statusbar()
self.emit('active-changed',('',))
self.emit('active-changed',(u"",))
elif (self.active_person == None or
person.get_handle() != self.active_person.get_handle()):
self.active_person = self.db.get_person_from_handle(person.get_handle())
self.modify_statusbar()
self.set_buttons(1)
if person:
if person and not self.lock_history:
if self.hindex+1 < len(self.history):
self.history = self.history[0:self.hindex+1]
@ -1481,11 +1486,11 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
else:
self.backbtn.set_sensitive(0)
self.back.set_sensitive(0)
self.emit('active-changed',(person.get_handle(),))
self.emit('active-changed',(unicode(person.get_handle()),))
else:
self.active_person = self.db.get_person_from_handle(person.get_handle())
self.set_buttons(1)
self.emit('active-changed',(person.get_handle(),))
self.emit('active-changed',(unicode(person.get_handle()),))
def modify_statusbar(self):