mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix tag_list_editor.py to use ids when deleting tags
This commit is contained in:
parent
477d947899
commit
40d054d465
@ -48,7 +48,7 @@ class TagListEditor(QDialog, Ui_TagListEditor):
|
||||
'The tag %s is already used.'%(item.text())).exec_()
|
||||
item.setText(self.item_before_editing.text())
|
||||
return
|
||||
id,ign = self.item_before_editing.data(Qt.UserRole).toInt()
|
||||
(id,_) = self.item_before_editing.data(Qt.UserRole).toInt()
|
||||
self.to_rename[item.text()] = id
|
||||
|
||||
def rename_tag(self):
|
||||
@ -82,13 +82,14 @@ class TagListEditor(QDialog, Ui_TagListEditor):
|
||||
deletes += confirms
|
||||
|
||||
for item in deletes:
|
||||
self.to_delete.append(item)
|
||||
(id,_) = item.data(Qt.UserRole).toInt()
|
||||
self.to_delete.append(id)
|
||||
self.available_tags.takeItem(self.available_tags.row(item))
|
||||
|
||||
def accept(self):
|
||||
for text in self.to_rename:
|
||||
self.db.rename_tag(self.to_rename[text], unicode(text))
|
||||
self.db.rename_tag(id=self.to_rename[text], new_name=unicode(text))
|
||||
for item in self.to_delete:
|
||||
self.db.delete_tag(unicode(item.text()))
|
||||
self.db.delete_tag_using_id(item)
|
||||
QDialog.accept(self)
|
||||
|
||||
|
@ -987,16 +987,13 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
|
||||
# Convenience method for tags_list_editor
|
||||
def get_tags_with_ids(self):
|
||||
result = self.conn.get('SELECT * FROM tags')
|
||||
result = self.conn.get('SELECT id,name FROM tags')
|
||||
if not result:
|
||||
return {}
|
||||
r = []
|
||||
for k,v in result:
|
||||
r.append((k,v))
|
||||
return r
|
||||
return []
|
||||
return result
|
||||
|
||||
def rename_tag(self, id, new):
|
||||
self.conn.execute('UPDATE tags SET name=? WHERE id=?', (new, id))
|
||||
def rename_tag(self, id, new_name):
|
||||
self.conn.execute('UPDATE tags SET name=? WHERE id=?', (new_name, id))
|
||||
self.conn.commit()
|
||||
|
||||
def get_tags(self, id):
|
||||
@ -1083,6 +1080,11 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
self.conn.execute('DELETE FROM tags WHERE id=?', (id,))
|
||||
self.conn.commit()
|
||||
|
||||
def delete_tag_using_id(self, id):
|
||||
if id:
|
||||
self.conn.execute('DELETE FROM books_tags_link WHERE tag=?', (id,))
|
||||
self.conn.execute('DELETE FROM tags WHERE id=?', (id,))
|
||||
self.conn.commit()
|
||||
|
||||
def set_series(self, id, series, notify=True):
|
||||
self.conn.execute('DELETE FROM books_series_link WHERE book=?',(id,))
|
||||
|
Loading…
x
Reference in New Issue
Block a user