From 745585d93c2c26cb6837fdafa34c2739ebe6427a Mon Sep 17 00:00:00 2001 From: Martin Hawlisch Date: Wed, 25 May 2005 21:09:51 +0000 Subject: [PATCH] * src/EditSource.py (DelSrcQuery.query_response), src/EditPlace.py (DeletePlaceQuery.query_response), src/ImageSelect.py (DeleteMediaQuery.query_response): Block signals while removing the references of the to be deleted object to get much more speed. * src/plugins/TestcaseGenerator.py: Add place, media and source references. * src/SourceView.py (button_press): Handle case of no selection. svn: r4681 --- gramps2/ChangeLog | 10 ++++++++ gramps2/src/EditPlace.py | 4 +++- gramps2/src/EditSource.py | 2 ++ gramps2/src/ImageSelect.py | 2 ++ gramps2/src/SourceView.py | 12 ++++++---- gramps2/src/plugins/TestcaseGenerator.py | 30 +++++++++++++++++++++++- 6 files changed, 53 insertions(+), 7 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index a00c94cf2..6f3993d39 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,13 @@ +2005-05-26 Martin Hawlisch + * src/EditSource.py (DelSrcQuery.query_response), + src/EditPlace.py (DeletePlaceQuery.query_response), + src/ImageSelect.py (DeleteMediaQuery.query_response): Block + signals while removing the references of the to be deleted + object to get much more speed. + * src/plugins/TestcaseGenerator.py: Add place, media and source + references. + * src/SourceView.py (button_press): Handle case of no selection. + 2005-05-25 Alex Roitman * src/WriteGedcom.py (write_person): Typo. diff --git a/gramps2/src/EditPlace.py b/gramps2/src/EditPlace.py index f41ba2dae..2db318b93 100644 --- a/gramps2/src/EditPlace.py +++ b/gramps2/src/EditPlace.py @@ -577,9 +577,9 @@ class DeletePlaceQuery: def query_response(self): trans = self.db.transaction_begin() + self.db.disable_signals() place_handle = self.place.get_handle() - self.db.remove_place(place_handle,trans) for handle in self.db.get_person_handles(sort_handles=False): person = self.db.get_person_from_handle(handle) @@ -599,5 +599,7 @@ class DeletePlaceQuery: event.remove_handle_references('Place',place_handle) self.db.commit_event(event,trans) + self.db.enable_signals() + self.db.remove_place(place_handle,trans) self.db.transaction_commit(trans, _("Delete Place (%s)") % self.place.get_title()) diff --git a/gramps2/src/EditSource.py b/gramps2/src/EditSource.py index 99c3061d5..37d962bcc 100644 --- a/gramps2/src/EditSource.py +++ b/gramps2/src/EditSource.py @@ -420,6 +420,7 @@ class DelSrcQuery: def query_response(self): trans = self.db.transaction_begin() + self.db.disable_signals() (person_list,family_list,event_list, place_list,source_list,media_list) = self.the_lists @@ -456,6 +457,7 @@ class DelSrcQuery: media.remove_source_references(src_handle_list) self.db.commit_media_object(media,trans) + self.db.enable_signals() self.db.remove_source(self.source.get_handle(),trans) self.db.transaction_commit( trans,_("Delete Source (%s)") % self.source.get_title()) diff --git a/gramps2/src/ImageSelect.py b/gramps2/src/ImageSelect.py index b93fdb72f..013ce00ad 100644 --- a/gramps2/src/ImageSelect.py +++ b/gramps2/src/ImageSelect.py @@ -1243,6 +1243,7 @@ class DeleteMediaQuery: def query_response(self): trans = self.db.transaction_begin() + self.db.disable_signals() (person_list,family_list,event_list, place_list,source_list) = self.the_lists @@ -1282,6 +1283,7 @@ class DeleteMediaQuery: source.set_media_list(new_list) self.db.commit_source(source,trans) + self.db.enable_signals() self.db.remove_object(self.media_handle,trans) self.db.transaction_commit(trans,_("Remove Media Object")) diff --git a/gramps2/src/SourceView.py b/gramps2/src/SourceView.py index 03c32af65..9622757d1 100644 --- a/gramps2/src/SourceView.py +++ b/gramps2/src/SourceView.py @@ -154,11 +154,13 @@ class SourceView: if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: mlist = [] self.selection.selected_foreach(self.blist,mlist) - handle = mlist[0] - source = self.parent.db.get_source_from_handle(handle) - EditSource.EditSource(source,self.parent.db,self.parent, - self.topWindow) - return True + if mlist: + handle = mlist[0] + source = self.parent.db.get_source_from_handle(handle) + EditSource.EditSource(source,self.parent.db,self.parent, + self.topWindow) + return True + return False elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: self.build_context_menu(event) return True diff --git a/gramps2/src/plugins/TestcaseGenerator.py b/gramps2/src/plugins/TestcaseGenerator.py index 7d81f2ac4..6421e7568 100644 --- a/gramps2/src/plugins/TestcaseGenerator.py +++ b/gramps2/src/plugins/TestcaseGenerator.py @@ -144,7 +144,6 @@ class TestcaseGenerator: if not self.multiple_transactions: self.trans.set_batch(True) self.db.disable_signals() - if self.multiple_transactions: @@ -248,6 +247,23 @@ class TestcaseGenerator: print "DONE." + if generate_bugs or generate_dates or generate_families: + self.default_source = RelLib.Source() + self.default_source.set_title("TestcaseGenerator") + self.db.add_source(self.default_source, self.trans) + self.default_sourceref = RelLib.SourceRef() + self.default_sourceref.set_base_handle(self.default_source.get_handle()) + self.default_place = RelLib.Place() + self.default_place.set_title("TestcaseGenerator place") + self.db.add_place(self.default_place, self.trans) + self.default_media = RelLib.MediaObject() + self.default_media.set_description("TestcaseGenerator media") + self.default_media.set_path("/tmp/TestcaseGenerator.png") + self.default_media.set_mime_type("image/png") + self.db.add_object(self.default_media, self.trans) + self.default_mediaref = RelLib.MediaRef() + self.default_mediaref.set_reference_handle(self.default_media.get_handle()) + if generate_bugs: self.generate_broken_relations() @@ -607,6 +623,8 @@ class TestcaseGenerator: np = RelLib.Person() + self.add_defaults(np) + # Note if note: np.set_note(note) @@ -662,6 +680,7 @@ class TestcaseGenerator: self.parents_todo.append(person2_h) fam = RelLib.Family() + self.add_defaults(fam) fam.set_father_handle(person1_h) fam.set_mother_handle(person2_h) fam.set_relationship(RelLib.Family.MARRIED) @@ -721,6 +740,15 @@ class TestcaseGenerator: self.db.commit_person(child,self.trans) self.commit_transaction() # COMMIT TRANSACTION STEP + def add_defaults(self,object,ref_text = ""): + object.add_source_reference(self.default_sourceref) + object.add_media_reference(self.default_mediaref) + e = RelLib.Event() + e.set_name("TestcaseGenerator") + e.set_place_handle(self.default_place.get_handle()) + self.db.add_event(e, self.trans) + object.add_event_handle(e.get_handle()) + def commit_transaction(self): if self.multiple_transactions: self.db.transaction_commit(self.trans,_("Testcase generator step %d") % self.transaction_count)