Tag Browser: Add an option in Preferences->Look & Feel->Tag Browser to turn off the display of counts in the Tag Browser

This commit is contained in:
Kovid Goyal 2016-09-06 17:46:12 +05:30
parent 88eabfc7d0
commit e3a77bf17f
4 changed files with 27 additions and 9 deletions

View File

@ -145,6 +145,7 @@ defs['show_emblems'] = False
defs['emblem_size'] = 32
defs['emblem_position'] = 'left'
defs['metadata_diff_mark_rejected'] = False
defs['tag_browser_show_counts'] = True
del defs
# }}}

View File

@ -288,6 +288,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('cover_grid_disk_cache_size', gprefs)
r('cover_grid_spacing', gprefs)
r('cover_grid_show_title', gprefs)
r('tag_browser_show_counts', gprefs)
r('cover_flow_queue_length', config, restart_required=True)
r('cover_browser_reflections', gprefs)

View File

@ -898,14 +898,14 @@ then the tags will be displayed each on their own line.</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="opt_tag_browser_old_look">
<property name="text">
<string>Use &amp;alternating row colors in the Tag Browser</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="opt_tag_browser_hide_empty_categories">
<property name="toolTip">
<string>When checked, calibre will automatically hide any category
@ -932,7 +932,7 @@ if you never want subcategories</string>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Tags browser category &amp;partitioning method:</string>
<string>&amp;Tags browser category partitioning method:</string>
</property>
<property name="buddy">
<cstring>opt_tags_browser_partition_method</cstring>
@ -949,6 +949,18 @@ if you never want subcategories</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="opt_tag_browser_show_counts">
<property name="toolTip">
<string>Show counts for items in the Tag Browser. Such as the number of books
by each author, the number of authors, etc. If you turn it off, you can still
see the counts by hovering your mouse over any item.</string>
</property>
<property name="text">
<string>Show &amp;counts in the Tag Browser</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">

View File

@ -59,13 +59,17 @@ class TagDelegate(QStyledItemDelegate): # {{{
def draw_text(self, style, painter, option, widget, index, item):
tr = style.subElementRect(style.SE_ItemViewItemText, option, widget)
count = unicode(index.data(COUNT_ROLE))
width = painter.fontMetrics().boundingRect(count).width()
text = index.data(Qt.DisplayRole)
r = QRect(tr)
r.setRight(r.right() - 1), r.setLeft(r.right() - width - 4)
painter.drawText(r, Qt.AlignCenter | Qt.TextSingleLine, count)
tr.setRight(r.left() - 1)
hover = option.state & style.State_MouseOver
if hover or gprefs['tag_browser_show_counts']:
count = unicode(index.data(COUNT_ROLE))
width = painter.fontMetrics().boundingRect(count).width()
r = QRect(tr)
r.setRight(r.right() - 1), r.setLeft(r.right() - width - 4)
painter.drawText(r, Qt.AlignCenter | Qt.TextSingleLine, count)
tr.setRight(r.left() - 1)
else:
tr.setRight(tr.right() - 1)
is_rating = item.type == TagTreeItem.TAG and not self.rating_pat.sub('', text)
if is_rating:
painter.setFont(self.rating_font)