mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-24 08:04:27 +01:00
Fix #7524 (Remove all option for tags when editing metadata hanging up system)
This commit is contained in:
parent
377da4abad
commit
ca466d77ee
2 changed files with 19 additions and 5 deletions
|
|
@ -98,7 +98,7 @@ def do_one_safe(self):
|
|||
return self.accept()
|
||||
|
||||
def do_one(self, id):
|
||||
remove, add, au, aus, do_aus, rating, pub, do_series, \
|
||||
remove_all, remove, add, au, aus, do_aus, rating, pub, do_series, \
|
||||
do_autonumber, do_remove_format, remove_format, do_swap_ta, \
|
||||
do_remove_conv, do_auto_author, series, do_series_restart, \
|
||||
series_start_value, do_title_case, clear_series = self.args
|
||||
|
|
@ -168,6 +168,8 @@ def do_one(self, id):
|
|||
# both of these are fast enough to just do them all
|
||||
for w in self.cc_widgets:
|
||||
w.commit(self.ids)
|
||||
if remove_all:
|
||||
self.db.remove_all_tags(self.ids)
|
||||
self.db.bulk_modify_tags(self.ids, add=add, remove=remove,
|
||||
notify=False)
|
||||
self.current_index = len(self.ids)
|
||||
|
|
@ -640,9 +642,9 @@ def accept(self):
|
|||
for w in getattr(self, 'custom_column_widgets', []):
|
||||
w.gui_val
|
||||
|
||||
if self.remove_all_tags.isChecked():
|
||||
remove = self.db.all_tags()
|
||||
else:
|
||||
remove_all = self.remove_all_tags.isChecked()
|
||||
remove = []
|
||||
if not remove_all:
|
||||
remove = unicode(self.remove_tags.text()).strip().split(',')
|
||||
add = unicode(self.tags.text()).strip().split(',')
|
||||
au = unicode(self.authors.text())
|
||||
|
|
@ -663,7 +665,7 @@ def accept(self):
|
|||
do_auto_author = self.auto_author_sort.isChecked()
|
||||
do_title_case = self.change_title_to_title_case.isChecked()
|
||||
|
||||
args = (remove, add, au, aus, do_aus, rating, pub, do_series,
|
||||
args = (remove_all, remove, add, au, aus, do_aus, rating, pub, do_series,
|
||||
do_autonumber, do_remove_format, remove_format, do_swap_ta,
|
||||
do_remove_conv, do_auto_author, series, do_series_restart,
|
||||
series_start_value, do_title_case, clear_series)
|
||||
|
|
|
|||
|
|
@ -1759,6 +1759,18 @@ def cleanup_tags(cls, tags):
|
|||
ans.append(tag)
|
||||
return ans
|
||||
|
||||
def remove_all_tags(self, ids, notify=False, commit=True):
|
||||
self.conn.executemany(
|
||||
'DELETE FROM books_tags_link WHERE book=?', [(x,) for x in ids])
|
||||
self.dirtied(ids, commit=False)
|
||||
if commit:
|
||||
self.conn.commit()
|
||||
|
||||
for x in ids:
|
||||
self.data.set(x, self.FIELD_MAP['tags'], '', row_is_id=True)
|
||||
if notify:
|
||||
self.notify('metadata', ids)
|
||||
|
||||
def bulk_modify_tags(self, ids, add=[], remove=[], notify=False):
|
||||
add = self.cleanup_tags(add)
|
||||
remove = self.cleanup_tags(remove)
|
||||
|
|
|
|||
Loading…
Reference in a new issue