From 68af4f7a1bd9537d26a5b67f981889c39d8bdc2c Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Tue, 22 Feb 2011 16:53:12 +0000 Subject: [PATCH] Use case-insensitive matching for user category items --- src/calibre/gui2/dialogs/tag_categories.py | 7 ++++--- src/calibre/library/database2.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/calibre/gui2/dialogs/tag_categories.py b/src/calibre/gui2/dialogs/tag_categories.py index 307baffb5b..b8a7e67c72 100644 --- a/src/calibre/gui2/dialogs/tag_categories.py +++ b/src/calibre/gui2/dialogs/tag_categories.py @@ -73,16 +73,17 @@ class TagCategories(QDialog, Ui_TagCategories): if idx == 0: continue for n in category_values[idx](): - t = Item(name=n, label=label, index=len(self.all_items),icon=category_icons[idx], exists=True) + t = Item(name=n, label=label, index=len(self.all_items), + icon=category_icons[idx], exists=True) self.all_items.append(t) - self.all_items_dict[label+':'+n] = t + self.all_items_dict[icu_lower(label+':'+n)] = t self.categories = dict.copy(db.prefs.get('user_categories', {})) if self.categories is None: self.categories = {} for cat in self.categories: for item,l in enumerate(self.categories[cat]): - key = ':'.join([l[1], l[0]]) + key = icu_lower(':'.join([l[1], l[0]])) t = self.all_items_dict.get(key, None) if l[1] in self.category_labels: if t is None: diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 09c755ab5e..5a0935c2c8 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1421,7 +1421,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): # temporarily duplicating the categories lists. taglist = {} for c in categories.keys(): - taglist[c] = dict(map(lambda t:(t.name, t), categories[c])) + taglist[c] = dict(map(lambda t:(icu_lower(t.name), t), categories[c])) muc = self.prefs.get('grouped_search_make_user_categories', []) gst = self.prefs.get('grouped_search_terms', {}) @@ -1437,8 +1437,9 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): for user_cat in sorted(user_categories.keys(), key=sort_key): items = [] for (name,label,ign) in user_categories[user_cat]: - if label in taglist and name in taglist[label]: - items.append(taglist[label][name]) + n = icu_lower(name) + if label in taglist and n in taglist[label]: + items.append(taglist[label][n]) # else: do nothing, to not include nodes w zero counts cat_name = '@' + user_cat # add the '@' to avoid name collision # Not a problem if we accumulate entries in the icon map