diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index f53dc04d6a..8f1a236134 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -158,27 +158,7 @@ class TableView(QTableView): for i in range(len(self.cw)): self.setColumnWidth(i, self.cw[i]) return True - - def set_visible_columns(self, cols=None): - ''' - @param cols: A list of booleans or None. If an entry is False the corresponding column - is hidden, if True it is shown. - ''' - key = self.__class__.__name__+'visible columns' - if cols: - dynamic[key] = cols - else: - cols = dynamic[key] - if not cols: - cols = [True for i in range(self.model().columnCount(QModelIndex()))] - - for i in range(len(cols)): - hidden = self.isColumnHidden(i) - self.setColumnHidden(i, not cols[i]) - if hidden and cols[i]: - self.resizeColumnToContents(i) - class FileIconProvider(QFileIconProvider): ICONS = { diff --git a/src/calibre/gui2/dialogs/tag_editor.py b/src/calibre/gui2/dialogs/tag_editor.py index 68eca39c3e..b50649f761 100644 --- a/src/calibre/gui2/dialogs/tag_editor.py +++ b/src/calibre/gui2/dialogs/tag_editor.py @@ -21,7 +21,7 @@ class TagEditor(QDialog, Ui_TagEditor): else: tags = [] if tags: - tags = [tag.lower().strip() for tag in tags.split(',') if tag.strip()] + tags = [tag.strip() for tag in tags.split(',') if tag.strip()] tags.sort() for tag in tags: self.applied_tags.addItem(tag) @@ -30,7 +30,7 @@ class TagEditor(QDialog, Ui_TagEditor): self.tags = tags - all_tags = [tag.lower() for tag in self.db.all_tags()] + all_tags = [tag for tag in self.db.all_tags()] all_tags = list(set(all_tags)) all_tags.sort() for tag in all_tags: @@ -98,7 +98,7 @@ class TagEditor(QDialog, Ui_TagEditor): self.available_tags.sortItems() def add_tag(self): - tags = qstring_to_unicode(self.add_tag_input.text()).lower().split(',') + tags = qstring_to_unicode(self.add_tag_input.text()).split(',') for tag in tags: tag = tag.strip() for item in self.available_tags.findItems(tag, Qt.MatchFixedString): diff --git a/src/calibre/gui2/images/window-close.svg b/src/calibre/gui2/images/window-close.svg index 754eb5fd30..90fde01b2f 100644 --- a/src/calibre/gui2/images/window-close.svg +++ b/src/calibre/gui2/images/window-close.svg @@ -161,7 +161,7 @@ sodipodi:rx="36" sodipodi:cy="92" sodipodi:cx="343.99899" - style="fill:url(#linearGradient5167);fill-opacity:1" + style="fill-opacity:1" r="36" rx="8.0010004" cx="343.99899" diff --git a/src/calibre/library/database.py b/src/calibre/library/database.py index eeb6bf2180..1c1129db6b 100644 --- a/src/calibre/library/database.py +++ b/src/calibre/library/database.py @@ -1168,19 +1168,6 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE; self.conn.execute('INSERT INTO comments(book,text) VALUES (?,?)', (id, text)) self.conn.commit() - def is_tag_used(self, tag): - id = self.conn.get('SELECT id FROM tags WHERE name=?', (tag,), all=False) - if not id: - return False - return bool(self.conn.get('SELECT tag FROM books_tags_link WHERE tag=?',(id,), all=False)) - - def delete_tag(self, tag): - id = self.conn.get('SELECT id FROM tags WHERE name=?', (tag,), all=False) - 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 delete_tags(self, tags): for tag in tags: self.delete_tag(tag) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index bb82ea7a8c..0b9a8729ab 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -878,14 +878,22 @@ class LibraryDatabase2(LibraryDatabase): self.conn.execute('DELETE FROM books_tags_link WHERE book=?', (id,)) self.conn.execute('DELETE FROM tags WHERE (SELECT COUNT(id) FROM books_tags_link WHERE tag=tags.id) < 1') for tag in set(tags): - tag = tag.lower().strip() + tag = tag.strip() if not tag: continue if not isinstance(tag, unicode): tag = tag.decode(preferred_encoding, 'replace') - t = self.conn.get('SELECT id FROM tags WHERE name=?', (tag,), all=False) - if t: - tid = t + existing_tags = self.all_tags() + lt = [t.lower() for t in existing_tags] + try: + idx = lt.index(tag.lower()) + except ValueError: + idx = -1 + if idx > -1: + etag = existing_tags[idx] + tid = self.conn.get('SELECT id FROM tags WHERE name=?', (etag,), all=False) + if etag != tag: + self.conn.execute('UPDATE tags SET name=? WHERE id=?', (tag, tid)) else: tid = self.conn.execute('INSERT INTO tags(name) VALUES(?)', (tag,)).lastrowid @@ -915,6 +923,29 @@ class LibraryDatabase2(LibraryDatabase): if notify: self.notify('metadata', [id]) + def is_tag_used(self, tag): + existing_tags = self.all_tags() + lt = [t.lower() for t in existing_tags] + try: + lt.index(tag.lower()) + return True + except ValueError: + return False + + def delete_tag(self, tag): + existing_tags = self.all_tags() + lt = [t.lower() for t in existing_tags] + try: + idx = lt.index(tag.lower()) + except ValueError: + idx = -1 + if idx > -1: + id = self.conn.get('SELECT id FROM tags WHERE name=?', (existing_tags[idx],), all=False) + 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,))