Allow specifying a set of categories that are not partitioned even if they contain a large number of items in the Tag Browser. Preference is available under Look & Feel->Tag Browser

This commit is contained in:
Kovid Goyal 2012-02-09 19:20:30 +05:30
commit 28e6048dd8
4 changed files with 37 additions and 11 deletions

View File

@ -87,6 +87,7 @@ gprefs.defaults['toolbar_text'] = 'always'
gprefs.defaults['font'] = None gprefs.defaults['font'] = None
gprefs.defaults['tags_browser_partition_method'] = 'first letter' gprefs.defaults['tags_browser_partition_method'] = 'first letter'
gprefs.defaults['tags_browser_collapse_at'] = 100 gprefs.defaults['tags_browser_collapse_at'] = 100
gprefs.defaults['tag_browser_dont_collapse'] = []
gprefs.defaults['edit_metadata_single_layout'] = 'default' gprefs.defaults['edit_metadata_single_layout'] = 'default'
gprefs.defaults['book_display_fields'] = [ gprefs.defaults['book_display_fields'] = [
('title', False), ('authors', True), ('formats', True), ('title', False), ('authors', True), ('formats', True),

View File

@ -144,6 +144,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('tags_browser_partition_method', gprefs, choices=choices) r('tags_browser_partition_method', gprefs, choices=choices)
r('tags_browser_collapse_at', gprefs) r('tags_browser_collapse_at', gprefs)
r('default_author_link', 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() choices = set([k for k in db.field_metadata.all_field_keys()
if (db.field_metadata[k]['is_category'] and if (db.field_metadata[k]['is_category'] and

View File

@ -259,9 +259,9 @@
<widget class="QLineEdit" name="opt_default_author_link"> <widget class="QLineEdit" name="opt_default_author_link">
<property name="toolTip"> <property name="toolTip">
<string>&lt;p&gt;Enter a template to be used to create a link for <string>&lt;p&gt;Enter a template to be used to create a link for
an author in the books information dialog. This template will an author in the books information dialog. This template will
be used when no link has been provided for the author using be used when no link has been provided for the author using
Manage Authors. You can use the values {author} and Manage Authors. You can use the values {author} and
{author_sort}, and any template function.</string> {author_sort}, and any template function.</string>
</property> </property>
</widget> </widget>
@ -334,14 +334,35 @@ if you never want subcategories</string>
<widget class="QSpinBox" name="opt_tags_browser_collapse_at"> <widget class="QSpinBox" name="opt_tags_browser_collapse_at">
<property name="toolTip"> <property name="toolTip">
<string>If a Tag Browser category has more than this number of items, it is divided <string>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.</string> up into subcategories. If the partition method is set to disable, this value is ignored.</string>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>10000</number> <number>10000</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="5"> <item row="1" column="2">
<widget class="QLabel" name="label_8111">
<property name="text">
<string>Categories not to partition:</string>
</property>
<property name="buddy">
<cstring>opt_tag_browser_dont_collapse</cstring>
</property>
</widget>
</item>
<item row="1" column="3" colspan="2">
<widget class="MultiCompleteLineEdit" name="opt_tag_browser_dont_collapse">
<property name="toolTip">
<string>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.</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="5">
<widget class="QCheckBox" name="opt_show_avg_rating"> <widget class="QCheckBox" name="opt_show_avg_rating">
<property name="text"> <property name="text">
<string>Show &amp;average ratings in the tags browser</string> <string>Show &amp;average ratings in the tags browser</string>
@ -351,7 +372,7 @@ up into sub-categories. If the partition method is set to disable, this value is
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_81"> <widget class="QLabel" name="label_81">
<property name="text"> <property name="text">
<string>Categories with &amp;hierarchical items:</string> <string>Categories with &amp;hierarchical items:</string>
@ -361,7 +382,7 @@ up into sub-categories. If the partition method is set to disable, this value is
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="5"> <item row="4" column="0" colspan="5">
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -374,10 +395,10 @@ up into sub-categories. If the partition method is set to disable, this value is
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="2" colspan="3"> <item row="3" column="2" colspan="3">
<widget class="MultiCompleteLineEdit" name="opt_categories_using_hierarchy"> <widget class="MultiCompleteLineEdit" name="opt_categories_using_hierarchy">
<property name="toolTip"> <property name="toolTip">
<string>A comma-separated list of columns in which items containing <string>A comma-separated list of categories in which items containing
periods are displayed in the tag browser trees. For example, if periods are displayed in the tag browser trees. For example, if
this box contains 'tags' then tags of the form 'Mystery.English' this box contains 'tags' then tags of the form 'Mystery.English'
and 'Mystery.Thriller' will be displayed with English and Thriller and 'Mystery.Thriller' will be displayed with English and Thriller

View File

@ -377,13 +377,15 @@ class TagsModel(QAbstractItemModel): # {{{
collapse_model = 'partition' collapse_model = 'partition'
collapse_template = tweaks['categories_collapsed_popularity_template'] 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 collapse_letter = None
category_node = category category_node = category
key = category_node.category_key key = category_node.category_key
is_gst = category_node.is_gst is_gst = category_node.is_gst
if key not in data: if key not in data:
return return
if key in gprefs['tag_browser_dont_collapse']:
collapse_model = 'disable'
cat_len = len(data[key]) cat_len = len(data[key])
if cat_len <= 0: if cat_len <= 0:
return return
@ -523,7 +525,8 @@ class TagsModel(QAbstractItemModel): # {{{
# }}} # }}}
for category in self.category_nodes: 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): def get_category_editor_data(self, category):
for cat in self.root_item.children: for cat in self.root_item.children: