* src/DisplayModels.py: use a dictionary to handle reverse
indices instead of list.index function. Drastically reduces time are larger lists. * src/GrampsDbBase.py: use cursors to build sorted key lists * src/PeopleModel.py: fetch sort names out of database first instead of continuously fetching from database during sort * src/PeopleView.py: remove unnecessary apply_filter * src/PlaceView.py: remove commented-out code * src/ReadXML.py: add gtk event handling to allow screen to update * src/gramps.glade: use gramps.png for loading message window * src/gramps_main.py: remove delete_abandoned_photos calls * src/PeopleModel.py: Fixed rebuild_display * src/ReadXML.py: Fixed calendar handling svn: r3819
This commit is contained in:
@@ -33,13 +33,6 @@ _findint = re.compile('^[^\d]*(\d+)[^\d]*')
|
||||
|
||||
def runTool(db,active_person,callback,parent):
|
||||
"""Changed person, family, object, source, and place ids"""
|
||||
# FIXME: Remove when plugin is properly implemented
|
||||
from QuestionDialog import OkDialog
|
||||
OkDialog(_("Plugin unavailable"),
|
||||
_("This plugin is not implemented yet. Please check the next version."),
|
||||
parent.topWindow)
|
||||
return
|
||||
|
||||
try:
|
||||
ReorderIds(db,callback)
|
||||
except:
|
||||
@@ -52,33 +45,31 @@ class ReorderIds:
|
||||
|
||||
self.db = db
|
||||
|
||||
self.reorder(db.get_person_handle_map(),db.iprefix,db.build_person_display)
|
||||
self.reorder_person()
|
||||
self.reorder(db.get_family_handle_map(),db.fprefix,None)
|
||||
self.reorder(db.get_object_map(),db.oprefix,None)
|
||||
self.reorder(db.get_source_map(),db.sprefix,db.build_source_display)
|
||||
self.reorder(db.get_place_handle_map(),db.pprefix,db.build_place_display)
|
||||
Utils.history_broken()
|
||||
callback(1)
|
||||
|
||||
def reorder(self,data_map,prefix,update):
|
||||
"""Try to extract the old integer out of the id, and reuse it
|
||||
if possible. Otherwise, blindly renumber those that can't."""
|
||||
|
||||
def reorder_person():
|
||||
dups = []
|
||||
newids = {}
|
||||
key_list = []
|
||||
|
||||
# search all ids in the map
|
||||
|
||||
for x in data_map.keys():
|
||||
key_list.append(x)
|
||||
cursor = self.db.get_person_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
(handle,sdata) = data
|
||||
|
||||
gramps_id = sdata[1]
|
||||
|
||||
for handle in key_list:
|
||||
|
||||
# attempt to extract integer, if we can't, treat it as a
|
||||
# duplicate
|
||||
|
||||
match = _findint.match(handle)
|
||||
match = _findint.match(gramps_id)
|
||||
if match:
|
||||
# get the integer, build the new handle. Make sure it
|
||||
# hasn't already been chosen. If it has, put this
|
||||
@@ -86,42 +77,45 @@ class ReorderIds:
|
||||
|
||||
try:
|
||||
index = match.groups()[0]
|
||||
newhandle = prefix % int(index)
|
||||
if newhandle == handle:
|
||||
newids[newhandle] = handle
|
||||
newgramps_id = prefix % int(index)
|
||||
if newgramps_id == gramps_id:
|
||||
newids[newgramps_id] = gramps_id
|
||||
continue
|
||||
elif data_map.has_key(newhandle):
|
||||
elif data_map.has_key(newgramps_id):
|
||||
dups.append(handle)
|
||||
else:
|
||||
data = data_map[handle]
|
||||
data_map[newhandle] = data
|
||||
newids[newhandle] = handle
|
||||
data.set_handle(newhandle)
|
||||
del data_map[handle]
|
||||
data = data_map[gramps_id]
|
||||
data_map[newgramps_id] = data
|
||||
newids[newgramps_id] = gramps_id
|
||||
data.set_gramps_id(newgramps_id)
|
||||
del data_map[gramps_id]
|
||||
if update:
|
||||
update(newhandle,handle)
|
||||
update(newgramps_id,gramps_id)
|
||||
except:
|
||||
dups.append(handle)
|
||||
else:
|
||||
dups.append(handle)
|
||||
|
||||
data = cursor.next()
|
||||
|
||||
|
||||
# go through the duplicates, looking for the first availble
|
||||
# handle that matches the new scheme.
|
||||
|
||||
index = 0
|
||||
for handle in dups:
|
||||
for gramps_id in dups:
|
||||
while 1:
|
||||
newhandle = prefix % index
|
||||
if not newids.has_key(newhandle):
|
||||
newgramps_id = prefix % index
|
||||
if not newids.has_key(newgramps_id):
|
||||
break
|
||||
index = index + 1
|
||||
newids[newhandle] = newhandle
|
||||
data = data_map[handle]
|
||||
data.set_handle(newhandle)
|
||||
data_map[newhandle] = data
|
||||
newids[newgramps_id] = newgramps_id
|
||||
data = data_map[gramps_id]
|
||||
data.set_gramps_id(newgramps_id)
|
||||
data_map[newgramps_id] = data
|
||||
if update:
|
||||
update(newhandle,handle)
|
||||
del data_map[handle]
|
||||
update(newgramps_id,gramps_id)
|
||||
del data_map[gramps_id]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user