From 62179334b1d7cbceaa35bab91e3ca44f33ef6971 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Thu, 9 Feb 2012 14:27:40 +0100 Subject: [PATCH] Add a preference to specify not to partition certain fields in the tag browser. This permits not collapsing fields that are already collapsed because they are hierarchical and contain only a few top-level elements. --- src/calibre/gui2/__init__.py | 1 + src/calibre/gui2/preferences/look_feel.py | 1 + src/calibre/gui2/preferences/look_feel.ui | 39 +++++++++++++++++------ src/calibre/gui2/tag_browser/model.py | 7 ++-- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index b3e128af82..445a0dbc03 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -87,6 +87,7 @@ gprefs.defaults['toolbar_text'] = 'always' gprefs.defaults['font'] = None gprefs.defaults['tags_browser_partition_method'] = 'first letter' gprefs.defaults['tags_browser_collapse_at'] = 100 +gprefs.defaults['tag_browser_dont_collapse'] = [] gprefs.defaults['edit_metadata_single_layout'] = 'default' gprefs.defaults['book_display_fields'] = [ ('title', False), ('authors', True), ('formats', True), diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index 06ec5392c9..2117de009c 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -144,6 +144,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): r('tags_browser_partition_method', gprefs, choices=choices) r('tags_browser_collapse_at', gprefs) r('default_author_link', gprefs) + r('tag_browser_dont_collapse', gprefs, setting=CommaSeparatedList) choices = set([k for k in db.field_metadata.all_field_keys() if (db.field_metadata[k]['is_category'] and diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index 498013a68b..73e0a85a68 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -259,9 +259,9 @@ <p>Enter a template to be used to create a link for -an author in the books information dialog. This template will -be used when no link has been provided for the author using -Manage Authors. You can use the values {author} and +an author in the books information dialog. This template will +be used when no link has been provided for the author using +Manage Authors. You can use the values {author} and {author_sort}, and any template function. @@ -334,14 +334,35 @@ if you never want subcategories If a Tag Browser category has more than this number of items, it is divided -up into sub-categories. If the partition method is set to disable, this value is ignored. +up into subcategories. If the partition method is set to disable, this value is ignored. 10000 - + + + + Categories not to partition: + + + opt_tag_browser_dont_collapse + + + + + + + A comma-separated list of categories that are not to +be partitioned even if the number of items is larger than +the value shown above. This option can be used to +avoid collapsing hierarchical categories that have only +a few top-level elements. + + + + Show &average ratings in the tags browser @@ -351,7 +372,7 @@ up into sub-categories. If the partition method is set to disable, this value is - + Categories with &hierarchical items: @@ -361,7 +382,7 @@ up into sub-categories. If the partition method is set to disable, this value is - + Qt::Vertical @@ -374,10 +395,10 @@ up into sub-categories. If the partition method is set to disable, this value is - + - A comma-separated list of columns in which items containing + A comma-separated list of categories in which items containing periods are displayed in the tag browser trees. For example, if this box contains 'tags' then tags of the form 'Mystery.English' and 'Mystery.Thriller' will be displayed with English and Thriller diff --git a/src/calibre/gui2/tag_browser/model.py b/src/calibre/gui2/tag_browser/model.py index 61d893272c..047ae687ae 100644 --- a/src/calibre/gui2/tag_browser/model.py +++ b/src/calibre/gui2/tag_browser/model.py @@ -377,13 +377,15 @@ class TagsModel(QAbstractItemModel): # {{{ collapse_model = 'partition' collapse_template = tweaks['categories_collapsed_popularity_template'] - def process_one_node(category, state_map): # {{{ + def process_one_node(category, collapse_model, state_map): # {{{ collapse_letter = None category_node = category key = category_node.category_key is_gst = category_node.is_gst if key not in data: return + if key in gprefs['tag_browser_dont_collapse']: + collapse_model = 'disable' cat_len = len(data[key]) if cat_len <= 0: return @@ -523,7 +525,8 @@ class TagsModel(QAbstractItemModel): # {{{ # }}} for category in self.category_nodes: - process_one_node(category, state_map.get(category.category_key, {})) + process_one_node(category, collapse_model, + state_map.get(category.category_key, {})) def get_category_editor_data(self, category): for cat in self.root_item.children: