Allow removal of tags in bulk metadata dialog

This commit is contained in:
Kovid Goyal 2008-01-20 07:10:41 +00:00
parent 22e0bd2b91
commit f5c1140042
3 changed files with 30 additions and 2 deletions

View File

@ -65,6 +65,10 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
if tags: if tags:
tags = tags.split(',') tags = tags.split(',')
self.db.set_tags(id, tags, append=True) self.db.set_tags(id, tags, append=True)
remove_tags = qstring_to_unicode(self.remove_tags.text()).strip()
if remove_tags:
remove_tags = [i.strip() for i in remove_tags.split(',')]
self.db.unapply_tags(id, remove_tags)
if self.write_series: if self.write_series:
self.db.set_series(id, qstring_to_unicode(self.series.currentText())) self.db.set_series(id, qstring_to_unicode(self.series.currentText()))
self.changed = True self.changed = True

View File

@ -6,7 +6,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>461</width> <width>461</width>
<height>342</height> <height>387</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
@ -154,6 +154,23 @@
</widget> </widget>
</item> </item>
<item row="5" column="0" > <item row="5" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>&amp;Remove tags:</string>
</property>
<property name="buddy" >
<cstring>remove_tags</cstring>
</property>
</widget>
</item>
<item row="5" column="1" >
<widget class="QLineEdit" name="remove_tags" >
<property name="toolTip" >
<string>Comma separated list of tags to remove from the books. </string>
</property>
</widget>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="label_7" > <widget class="QLabel" name="label_7" >
<property name="text" > <property name="text" >
<string>&amp;Series:</string> <string>&amp;Series:</string>
@ -169,7 +186,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1" > <item row="6" column="1" >
<widget class="QComboBox" name="series" > <widget class="QComboBox" name="series" >
<property name="toolTip" > <property name="toolTip" >
<string>List of known series. You can add new series.</string> <string>List of known series. You can add new series.</string>

View File

@ -1085,6 +1085,13 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
for tag in tags: for tag in tags:
self.delete_tag(tag) self.delete_tag(tag)
def unapply_tags(self, book_id, tags):
for tag in tags:
id = self.conn.execute('SELECT id FROM tags WHERE name=?', (tag,)).fetchone()
if id:
self.conn.execute('DELETE FROM books_tags_link WHERE tag=? AND book=?', (id[0], book_id))
self.conn.commit()
def set_tags(self, id, tags, append=False): def set_tags(self, id, tags, append=False):
''' '''
@param tags: list of strings @param tags: list of strings