diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index fb09d93dc..c3fd45d96 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -3,6 +3,11 @@ of items in each table * src/Check.py: Add ProgressMeter calls * src/Utils.py: Define new ProgressMeter class + * src/GrampsBSDDB.py: call callback for rebuilding secondary indices + * src/plugins/Merge.py: use ProgressMeter + * src/plugins/Rebuild.py: use ProgressMeter + * src/plugins/ReorderIds.py: use ProgressMeter + * src/plugins/Verify.py: use ProgressMeter 2005-08-02 Alex Roitman * src/Bookmarks.py: Convert from CList to ListModel and TreeView; diff --git a/gramps2/src/GrampsBSDDB.py b/gramps2/src/GrampsBSDDB.py index 839e86f33..0c5d524f8 100644 --- a/gramps2/src/GrampsBSDDB.py +++ b/gramps2/src/GrampsBSDDB.py @@ -201,7 +201,7 @@ class GrampsBSDDB(GrampsDbBase): self.genderStats = GenderStats(gstats) return 1 - def rebuild_secondary(self): + def rebuild_secondary(self,callback=None): # Repair secondary indices related to person_map @@ -224,6 +224,8 @@ class GrampsBSDDB(GrampsDbBase): self.person_map.associate(self.id_trans, find_idmap, db.DB_CREATE) for key in self.person_map.keys(): + if callback: + callback() self.person_map[key] = self.person_map[key] self.person_map.sync() @@ -239,6 +241,8 @@ class GrampsBSDDB(GrampsDbBase): self.family_map.associate(self.fid_trans, find_idmap, db.DB_CREATE) for key in self.family_map.keys(): + if callback: + callback() self.family_map[key] = self.family_map[key] self.family_map.sync() @@ -253,6 +257,8 @@ class GrampsBSDDB(GrampsDbBase): self.place_map.associate(self.pid_trans, find_idmap, db.DB_CREATE) for key in self.place_map.keys(): + if callback: + callback() self.place_map[key] = self.place_map[key] self.place_map.sync() @@ -267,6 +273,8 @@ class GrampsBSDDB(GrampsDbBase): self.media_map.associate(self.oid_trans, find_idmap, db.DB_CREATE) for key in self.media_map.keys(): + if callback: + callback() self.media_map[key] = self.media_map[key] self.media_map.sync() @@ -281,6 +289,8 @@ class GrampsBSDDB(GrampsDbBase): self.source_map.associate(self.sid_trans, find_idmap, db.DB_CREATE) for key in self.source_map.keys(): + if callback: + callback() self.source_map[key] = self.source_map[key] self.source_map.sync() diff --git a/gramps2/src/GrampsDbBase.py b/gramps2/src/GrampsDbBase.py index 4035bb08b..5fc8b9d8f 100644 --- a/gramps2/src/GrampsDbBase.py +++ b/gramps2/src/GrampsDbBase.py @@ -194,7 +194,7 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): self.place2title = {} self.name_group = {} - def rebuild_secondary(self): + def rebuild_secondary(self,callback=None): pass def version_supported(self): diff --git a/gramps2/src/Utils.py b/gramps2/src/Utils.py index 4681b2e18..387f40afa 100644 --- a/gramps2/src/Utils.py +++ b/gramps2/src/Utils.py @@ -815,7 +815,7 @@ class ProgressMeter: """ Progress meter class for GRAMPS. """ - def __init__(self,title,header): + def __init__(self,title,header=''): """ Specify the title and the current pass header. """ @@ -836,12 +836,18 @@ class ProgressMeter: self.ptop.set_size_request(350,125) self.ptop.vbox.add(self.pbar) self.ptop.show_all() + if header == '': + self.lbl.hide() def set_pass(self,header,total): """ Reset for another pass. Provide a new header and define number of steps to be used. """ + if header == '': + self.lbl.hide() + else: + self.lbl.show() self.pbar_max = total self.pbar_index = 0.0 self.lbl.set_text(header) diff --git a/gramps2/src/plugins/Merge.py b/gramps2/src/plugins/Merge.py index 38946baa7..bc7e99e5d 100644 --- a/gramps2/src/plugins/Merge.py +++ b/gramps2/src/plugins/Merge.py @@ -176,25 +176,21 @@ class Merge: else: self.show() - def progress_update(self,val): - self.progress.set_fraction(val/100.0) - while gtk.events_pending(): - gtk.main_iteration() - def find_potentials(self,thresh): - top = gtk.glade.XML(self.glade_file,"message","gramps") - self.topWin = top.get_widget("message") - self.topWin.set_icon(self.parent.topWindow.get_icon()) - self.progress = top.get_widget("progressbar1") + self.progress = Utils.ProgressMeter(_('Find duplicates'), + _('Looking for duplicate people')) - Utils.set_titles(self.topWin,top.get_widget('title'), - _('Determining possible merges')) - index = 0 - males = {} females = {} + + length = len(self.person_list) + + self.progress.set_pass(_('Pass 1: Building preliminary lists'), + length) + for p1_id in self.person_list: + self.progress.step() p1 = self.db.get_person_from_handle(p1_id) key = self.gen_key(p1.get_primary_name().get_surname()) if p1.get_gender() == RelLib.Person.MALE: @@ -208,14 +204,12 @@ class Merge: else: females[key] = [p1_id] - length = len(self.person_list) + self.progress.set_pass(_('Pass 2: Calculating potential matches'), + length) - num = 0 for p1key in self.person_list: + self.progress.step() p1 = self.db.get_person_from_handle(p1key) - if num % 25 == 0: - self.progress_update((float(num)/float(length))*100) - num = num + 1 key = self.gen_key(p1.get_primary_name().get_surname()) if p1.get_gender() == RelLib.Person.MALE: @@ -246,7 +240,7 @@ class Merge: self.list = self.map.keys() self.list.sort() self.length = len(self.list) - self.topWin.destroy() + self.progress.close() self.dellist = {} def show(self): @@ -602,8 +596,6 @@ class Merge: value = self.name_match(mname1,mname2) if value != -1: chance = chance + value - - print p1.get_gramps_id(), p2.get_gramps_id(), chance return chance #------------------------------------------------------------------------- diff --git a/gramps2/src/plugins/Rebuild.py b/gramps2/src/plugins/Rebuild.py index 404bf2bdc..b5e164339 100644 --- a/gramps2/src/plugins/Rebuild.py +++ b/gramps2/src/plugins/Rebuild.py @@ -61,10 +61,17 @@ def runTool(database,active_person,callback,parent=None): # TODO: split plugin in a check and repair part to support # checking of a read only database return - + + total = database.get_number_of_people() + database.get_number_of_families() + \ + database.get_number_of_places() + database.get_number_of_sources() + \ + database.get_number_of_media_objects() + + progress = Utils.ProgressMeter(_('Rebuilding Secondary Indices')) + progress.set_pass('',total) database.disable_signals() - database.rebuild_secondary() + database.rebuild_secondary(progress.step) database.enable_signals() + progress.close() OkDialog(_("Secondary indices rebuilt"), _('All secondary indices have been rebuilt.')) except: diff --git a/gramps2/src/plugins/ReorderIds.py b/gramps2/src/plugins/ReorderIds.py index 49c7c83f9..4f12e25e0 100644 --- a/gramps2/src/plugins/ReorderIds.py +++ b/gramps2/src/plugins/ReorderIds.py @@ -70,22 +70,31 @@ class ReorderIds: self.db = db + self.progress = Utils.ProgressMeter(_('Reording GRAMPS IDs'),'') + self.trans = db.transaction_begin() + + self.progress.set_pass(_('Reordering People IDs'),db.get_number_of_people()) self.reorder(RelLib.Person, db.get_person_from_gramps_id, db.get_person_from_handle, db.find_next_person_gramps_id, db.get_person_cursor, db.commit_person, db.iprefix) + self.progress.set_pass(_('Reordering Family IDs'),db.get_number_of_families()) self.reorder(RelLib.Family,db.get_family_from_gramps_id, db.get_family_from_handle, db.find_next_family_gramps_id, db.get_family_cursor, db.commit_family, db.fprefix) + self.progress.set_pass(_('Reordering Media Object IDs'),db.get_number_of_media_objects()) self.reorder(RelLib.MediaObject, db.get_object_from_gramps_id, db.get_object_from_handle, db.find_next_object_gramps_id, db.get_media_cursor, db.commit_media_object, db.oprefix) + self.progress.set_pass(_('Reordering Source IDs'),db.get_number_of_sources()) self.reorder(RelLib.Source, db.get_source_from_gramps_id, db.get_source_from_handle, db.find_next_source_gramps_id, db.get_source_cursor, db.commit_source, db.sprefix) + self.progress.set_pass(_('Reordering Place IDs'),db.get_number_of_places()) self.reorder(RelLib.Place, db.get_place_from_gramps_id, db.get_place_from_handle, db.find_next_place_gramps_id, db.get_place_cursor, db.commit_place, db.pprefix) + self.progress.close() db.transaction_commit(self.trans,_("Reorder gramps IDs")) def reorder(self, class_type, find_from_id, find_from_handle, find_next_id, get_cursor, commit, prefix): @@ -98,6 +107,7 @@ class ReorderIds: cursor = get_cursor() data = cursor.first() while data: + self.progress.step() (handle,sdata) = data obj = class_type() @@ -134,7 +144,9 @@ class ReorderIds: # go through the duplicates, looking for the first availble # handle that matches the new scheme. + self.progress.set_pass(_('Finding and assigning unused IDs'),len(dups)) for handle in dups: + self.progress.step() obj = find_from_handle(handle) obj.set_gramps_id(find_next_id()) commit(obj,self.trans) diff --git a/gramps2/src/plugins/Verify.py b/gramps2/src/plugins/Verify.py index d61c149c3..e979e9272 100644 --- a/gramps2/src/plugins/Verify.py +++ b/gramps2/src/plugins/Verify.py @@ -153,7 +153,12 @@ class Verify: error = cStringIO.StringIO() warn = cStringIO.StringIO() + progress = Utils.ProgressMeter(_('Verify the database'),'') + + progress.set_pass(_('Checking data'),self.db.get_number_of_people()) + for person_handle in personList: + progress.step() person = self.db.get_person_from_handle(person_handle) idstr = "%s (%s)" % (person.get_primary_name().get_name(),person.get_gramps_id()) @@ -290,6 +295,7 @@ class Verify: prev_maryear=0 prev_sdyear=0 fnum = 0 + for family_handle in person.get_family_handle_list(): family = self.db.get_family_from_handle(family_handle) fnum = fnum + 1 @@ -473,6 +479,7 @@ class Verify: warn.write(_("Too many children (%(num_children)d) for %(person_name)s.\n") % { 'num_children' : total_children, 'person_name' : idstr }) + progress.close() text = "" err_text = error.getvalue() warn_text = warn.getvalue()