mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Fix renaming bug where multiple items were renamed to the same thing
This commit is contained in:
parent
716b8a0905
commit
91cd75909e
@ -839,10 +839,11 @@ class EditMetadataAction(object): # {{{
|
||||
d = TagListEditor(self, tag_to_match=None, data=result, compare=compare)
|
||||
d.exec_()
|
||||
if d.result() == d.Accepted:
|
||||
to_rename = d.to_rename # dict of new text to old id
|
||||
to_rename = d.to_rename # dict of new text to old ids
|
||||
to_delete = d.to_delete # list of ids
|
||||
for text in to_rename:
|
||||
model.rename_collection(old_id=to_rename[text], new_name=unicode(text))
|
||||
for old_id in to_rename[text]:
|
||||
model.rename_collection(old_id, new_name=unicode(text))
|
||||
for item in to_delete:
|
||||
model.delete_collection_using_id(item)
|
||||
self.upload_collections(model.db, view=view, oncard=oncard)
|
||||
|
@ -73,7 +73,10 @@ class TagListEditor(QDialog, Ui_TagListEditor):
|
||||
return
|
||||
if item.text() != self.item_before_editing.text():
|
||||
(id,ign) = self.item_before_editing.data(Qt.UserRole).toInt()
|
||||
self.to_rename[item.text()] = id
|
||||
if item.text() not in self.to_rename:
|
||||
self.to_rename[item.text()] = [id]
|
||||
else:
|
||||
self.to_rename[item.text()].append(id)
|
||||
|
||||
def rename_tag(self):
|
||||
item = self.available_tags.currentItem()
|
||||
|
@ -720,7 +720,9 @@ class TagBrowserMixin(object): # {{{
|
||||
delete_func = partial(db.delete_custom_item_using_id, label=cc_label)
|
||||
if rename_func:
|
||||
for text in to_rename:
|
||||
rename_func(old_id=to_rename[text], new_name=unicode(text))
|
||||
for old_id in to_rename[text]:
|
||||
print 'rename', old_id, text
|
||||
rename_func(old_id, new_name=unicode(text))
|
||||
for item in to_delete:
|
||||
delete_func(item)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user