ProgressMeter changes
svn: r5009
This commit is contained in:
parent
ca4856adee
commit
1cc16595a9
@ -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 <shura@gramps-project.org>
|
||||
* src/Bookmarks.py: Convert from CList to ListModel and TreeView;
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
|
||||
Utils.set_titles(self.topWin,top.get_widget('title'),
|
||||
_('Determining possible merges'))
|
||||
self.progress = Utils.ProgressMeter(_('Find duplicates'),
|
||||
_('Looking for duplicate people'))
|
||||
|
||||
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
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -62,9 +62,16 @@ def runTool(database,active_person,callback,parent=None):
|
||||
# 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:
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user