* src/GrampsBSDDB.py: remove transaction.batch in favor of signal suppression

* src/GrampsDbBase.py: remove transaction.batch in favor of signal suppression
* src/GrampsInMemDB.py: remove transaction.batch in favor of signal suppression
* src/ReadGedcom.py: fix relation typo, enable/disable signals around import
* src/ReadXML.py: enable/disable signals around import
* src/gramps_main.py: disable signals before undo and exit


svn: r4295
This commit is contained in:
Don Allingham 2005-04-04 23:52:46 +00:00
parent 8239697464
commit 0dbc5c0341
7 changed files with 50 additions and 56 deletions

View File

@ -1,5 +1,11 @@
2005-04-04 Don Allingham <don@gramps-project.org> 2005-04-04 Don Allingham <don@gramps-project.org>
* src/MedaiView.py: pass handle instead of GRAMPS ID during drag-n-drop * src/MedaiView.py: pass handle instead of GRAMPS ID during drag-n-drop
* src/GrampsBSDDB.py: remove transaction.batch in favor of signal suppression
* src/GrampsDbBase.py: remove transaction.batch in favor of signal suppression
* src/GrampsInMemDB.py: remove transaction.batch in favor of signal suppression
* src/ReadGedcom.py: fix relation typo, enable/disable signals around import
* src/ReadXML.py: enable/disable signals around import
* src/gramps_main.py: disable signals before undo and exit
2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk> 2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/GrampsDBCallback.py: Don't check callbacks if the dict is empty. * src/GrampsDBCallback.py: Don't check callbacks if the dict is empty.

View File

@ -279,8 +279,7 @@ class GrampsBSDDB(GrampsDbBase):
self.genderStats.uncount_person (person) self.genderStats.uncount_person (person)
if transaction != None: if transaction != None:
transaction.add(PERSON_KEY,handle,person.serialize()) transaction.add(PERSON_KEY,handle,person.serialize())
if not transaction.batch: self.emit('person-delete',([str(handle)],))
self.emit('person-delete',([str(handle)],))
self.person_map.delete(str(handle)) self.person_map.delete(str(handle))
def remove_source(self,handle,transaction): def remove_source(self,handle,transaction):
@ -288,8 +287,7 @@ class GrampsBSDDB(GrampsDbBase):
if transaction != None: if transaction != None:
old_data = self.source_map.get(str(handle)) old_data = self.source_map.get(str(handle))
transaction.add(SOURCE_KEY,handle,old_data) transaction.add(SOURCE_KEY,handle,old_data)
if not transaction.batch: self.emit('source-delete',([handle],))
self.emit('source-delete',([handle],))
self.source_map.delete(str(handle)) self.source_map.delete(str(handle))
def remove_family(self,handle,transaction): def remove_family(self,handle,transaction):
@ -297,8 +295,7 @@ class GrampsBSDDB(GrampsDbBase):
if transaction != None: if transaction != None:
old_data = self.family_map.get(str(handle)) old_data = self.family_map.get(str(handle))
transaction.add(FAMILY_KEY,handle,old_data) transaction.add(FAMILY_KEY,handle,old_data)
if not transaction.batch: self.emit('family-delete',([str(handle)],))
self.emit('family-delete',([str(handle)],))
self.family_map.delete(str(handle)) self.family_map.delete(str(handle))
def remove_event(self,handle,transaction): def remove_event(self,handle,transaction):
@ -313,8 +310,7 @@ class GrampsBSDDB(GrampsDbBase):
if transaction != None: if transaction != None:
old_data = self.place_map.get(handle) old_data = self.place_map.get(handle)
transaction.add(PLACE_KEY,handle,old_data) transaction.add(PLACE_KEY,handle,old_data)
if not transaction.batch: self.emit('place-delete',([handle],))
self.emit('place-delete',([handle],))
self.place_map.delete(str(handle)) self.place_map.delete(str(handle))
def remove_object(self,handle,transaction): def remove_object(self,handle,transaction):
@ -322,8 +318,7 @@ class GrampsBSDDB(GrampsDbBase):
if transaction != None: if transaction != None:
old_data = self.media_map.get(handle) old_data = self.media_map.get(handle)
transaction.add(PLACE_KEY,handle,old_data) transaction.add(PLACE_KEY,handle,old_data)
if not transaction.batch: self.emit('media-delete',([handle],))
self.emit('media-delete',([handle],))
self.media_map.delete(str(handle)) self.media_map.delete(str(handle))
def get_person_from_gramps_id(self,val): def get_person_from_gramps_id(self,val):

View File

@ -277,11 +277,10 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
transaction.add(PERSON_KEY,handle,old_data) transaction.add(PERSON_KEY,handle,old_data)
self.person_map[handle] = person.serialize() self.person_map[handle] = person.serialize()
if transaction and not transaction.batch: if transaction and old_data:
if old_data: self.emit('person-update',([handle],))
self.emit('person-update',([handle],)) else:
else: self.emit('person-add',([handle],))
self.emit('person-add',([handle],))
def commit_media_object(self,obj,transaction,change_time=None): def commit_media_object(self,obj,transaction,change_time=None):
""" """
@ -299,11 +298,10 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
old_data = self.media_map.get(handle) old_data = self.media_map.get(handle)
transaction.add(MEDIA_KEY,handle,old_data) transaction.add(MEDIA_KEY,handle,old_data)
self.media_map[handle] = obj.serialize() self.media_map[handle] = obj.serialize()
if transaction and not transaction.batch: if transaction and old_data:
if old_data: self.emit('media-update',([handle],))
self.emit('media-update',([handle],)) else:
else: self.emit('media-add',([handle],))
self.emit('media-add',([handle],))
def commit_source(self,source,transaction,change_time=None): def commit_source(self,source,transaction,change_time=None):
""" """
@ -321,11 +319,10 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
old_data = self.source_map.get(handle) old_data = self.source_map.get(handle)
transaction.add(SOURCE_KEY,handle,old_data) transaction.add(SOURCE_KEY,handle,old_data)
self.source_map[handle] = source.serialize() self.source_map[handle] = source.serialize()
if transaction and not transaction.batch: if transaction and old_data:
if old_data: self.emit('source-update',([handle],))
self.emit('source-update',([handle],)) else:
else: self.emit('source-add',([handle],))
self.emit('source-add',([handle],))
def commit_place(self,place,transaction,change_time=None): def commit_place(self,place,transaction,change_time=None):
""" """
@ -343,11 +340,10 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
old_data = self.place_map.get(handle) old_data = self.place_map.get(handle)
transaction.add(PLACE_KEY,handle,old_data) transaction.add(PLACE_KEY,handle,old_data)
self.place_map[handle] = place.serialize() self.place_map[handle] = place.serialize()
if transaction and not transaction.batch: if transaction and old_data:
if old_data: self.emit('place-update',([handle],))
self.emit('place-update',([handle],)) else:
else: self.emit('place-add',([handle],))
self.emit('place-add',([handle],))
def commit_event(self,event,transaction,change_time=None): def commit_event(self,event,transaction,change_time=None):
""" """
@ -383,11 +379,10 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
transaction.add(FAMILY_KEY,handle,old_data) transaction.add(FAMILY_KEY,handle,old_data)
self.family_map[handle] = family.serialize() self.family_map[handle] = family.serialize()
if transaction and not transaction.batch: if transaction and old_data:
if old_data: self.emit('family-update',([handle],))
self.emit('family-update',([handle],)) else:
else: self.emit('family-add',([handle],))
self.emit('family-add',([handle],))
def find_next_person_gramps_id(self): def find_next_person_gramps_id(self):
""" """
@ -537,8 +532,7 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
if transaction != None: if transaction != None:
transaction.add(PERSON_KEY, val, None) transaction.add(PERSON_KEY, val, None)
self.person_map[str(val)] = person.serialize() self.person_map[str(val)] = person.serialize()
if transaction and not transaction.batch: self.emit('person-add', ([str(val)],))
self.emit('person-add', ([str(val)],))
self.genderStats.count_person (person, self) self.genderStats.count_person (person, self)
return person return person
@ -967,9 +961,6 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
if self.undo_callback: if self.undo_callback:
self.undo_callback(_("_Undo %s") % transaction.get_description()) self.undo_callback(_("_Undo %s") % transaction.get_description())
if transaction and transaction.batch:
self.request_rebuild()
def undo(self): def undo(self):
""" """
Accesses the last committed transaction, and reverts the data to Accesses the last committed transaction, and reverts the data to

View File

@ -142,8 +142,7 @@ class GrampsInMemDB(GrampsDbBase):
if transaction != None: if transaction != None:
old_data = self.person_map.get(handle) old_data = self.person_map.get(handle)
transaction.add(PERSON_KEY,handle,old_data) transaction.add(PERSON_KEY,handle,old_data)
if transaction and not transaction.batch: self.emit('person-delete',([handle],))
self.emit('person-delete',([handle],))
del self.id_trans[person.get_gramps_id()] del self.id_trans[person.get_gramps_id()]
del self.person_map[handle] del self.person_map[handle]
@ -154,8 +153,7 @@ class GrampsInMemDB(GrampsDbBase):
if transaction != None: if transaction != None:
old_data = self.source_map.get(str(handle)) old_data = self.source_map.get(str(handle))
transaction.add(SOURCE_KEY,handle,old_data) transaction.add(SOURCE_KEY,handle,old_data)
if transaction and not transaction.batch: self.emit('source-delete',([handle],))
self.emit('source-delete',([handle],))
del self.sid_trans[source.get_gramps_id()] del self.sid_trans[source.get_gramps_id()]
del self.source_map[str(handle)] del self.source_map[str(handle)]
@ -166,8 +164,7 @@ class GrampsInMemDB(GrampsDbBase):
if transaction != None: if transaction != None:
old_data = self.place_map.get(str(handle)) old_data = self.place_map.get(str(handle))
transaction.add(PLACE_KEY,handle,old_data) transaction.add(PLACE_KEY,handle,old_data)
if transaction and not transaction.batch: self.emit('person-delete',([handle],))
self.emit('person-delete',([handle],))
del self.pid_trans[place.get_gramps_id()] del self.pid_trans[place.get_gramps_id()]
del self.place_map[str(handle)] del self.place_map[str(handle)]
@ -188,8 +185,7 @@ class GrampsInMemDB(GrampsDbBase):
if transaction != None: if transaction != None:
old_data = self.family_map.get(str(handle)) old_data = self.family_map.get(str(handle))
transaction.add(FAMILY_KEY,handle,old_data) transaction.add(FAMILY_KEY,handle,old_data)
if transaction and not transaction.batch: self.emit('family-delete',([str(handle),]))
self.emit('family-delete',([str(handle),]))
del self.fid_trans[family.get_gramps_id()] del self.fid_trans[family.get_gramps_id()]
del self.family_map[str(handle)] del self.family_map[str(handle)]

View File

@ -473,6 +473,7 @@ class GedcomParser:
self.trans.set_batch(True) self.trans.set_batch(True)
else: else:
self.trans = None self.trans = None
self.db.disable_signals()
t = time.time() t = time.time()
self.index = 0 self.index = 0
self.fam_count = 0 self.fam_count = 0
@ -497,8 +498,8 @@ class GedcomParser:
if use_trans: if use_trans:
self.db.transaction_commit(self.trans,_("GEDCOM import")) self.db.transaction_commit(self.trans,_("GEDCOM import"))
else: self.db.enable_signals()
self.db.request_rebuild() self.db.request_rebuild()
if self.window: if self.window:
self.infomsg("\n%s" % msg) self.infomsg("\n%s" % msg)
@ -828,7 +829,7 @@ class GedcomParser:
mrel, frel) mrel, frel)
break break
else: else:
if mrel in rel_types and frel in reltypes: if mrel in rel_types and frel in rel_types:
child.set_main_parent_family_handle(self.family.get_handle()) child.set_main_parent_family_handle(self.family.get_handle())
else: else:
if child.get_main_parents_family_handle() == self.family: if child.get_main_parents_family_handle() == self.family:
@ -1548,7 +1549,7 @@ class GedcomParser:
elif matches[1] == "DATA": elif matches[1] == "DATA":
date,text = self.parse_source_data(level+1) date,text = self.parse_source_data(level+1)
d = self.dp.parse(date) d = self.dp.parse(date)
source.set_date(d) source.set_date_object(d)
source.set_text(text) source.set_text(text)
elif matches[1] in ["OBJE","REFN","TEXT"]: elif matches[1] in ["OBJE","REFN","TEXT"]:
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)

View File

@ -533,11 +533,15 @@ class GrampsParser:
return self.oidswap[handle] return self.oidswap[handle]
def parse(self,file,use_trans=True): def parse(self,file,use_trans=True):
if use_trans: if use_trans:
self.trans = self.db.transaction_begin() self.trans = self.db.transaction_begin()
self.trans.set_batch(True) self.trans.set_batch(True)
else: else:
self.trans = None self.trans = None
self.db.disable_signals()
p = ParserCreate() p = ParserCreate()
p.StartElementHandler = self.startElement p.StartElementHandler = self.startElement
p.EndElementHandler = self.endElement p.EndElementHandler = self.endElement
@ -561,8 +565,8 @@ class GrampsParser:
del p del p
if use_trans: if use_trans:
self.db.transaction_commit(self.trans,_("GRAMPS XML import")) self.db.transaction_commit(self.trans,_("GRAMPS XML import"))
else: self.db.enable_signals()
self.db.request_rebuild() self.db.request_rebuild()
def start_lds_ord(self,attrs): def start_lds_ord(self,attrs):
atype = attrs['type'] atype = attrs['type']

View File

@ -505,6 +505,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
self.emit('database-changed',(self.db,)) self.emit('database-changed',(self.db,))
def exit_and_undo(self,*args): def exit_and_undo(self,*args):
self.db.disable_signals()
self.db.abort_changes() self.db.abort_changes()
self.db.set_people_view_maps((None,None,None,None)) self.db.set_people_view_maps((None,None,None,None))
gtk.main_quit() gtk.main_quit()