mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a tweak to Preferences->Tweaks to control the order in which categories appear in the Tag Browser
This commit is contained in:
commit
2653da4ecf
@ -128,6 +128,17 @@ categories_collapsed_name_template = r'{first.sort:shorten(4,,0)} - {last.sort:s
|
||||
categories_collapsed_rating_template = r'{first.avg_rating:4.2f:ifempty(0)} - {last.avg_rating:4.2f:ifempty(0)}'
|
||||
categories_collapsed_popularity_template = r'{first.count:d} - {last.count:d}'
|
||||
|
||||
#: Control order of categories in the tag browser
|
||||
# Change the following dict to change the order that categories are displayed in
|
||||
# the tag browser. Items are named using their lookup name, and will be sorted
|
||||
# using the number supplied. The lookup name '*' stands for all names that
|
||||
# otherwise do not appear. Two names with the same value will be sorted
|
||||
# according the the default order; the one used when the dict is empty.
|
||||
# Example: tag_browser_category_order = {'series':1, 'tags':2, '*':3}
|
||||
# resulting in the order series, tags, then everything else in default order.
|
||||
tag_browser_category_order = {'*':1}
|
||||
|
||||
|
||||
#: Specify columns to sort the booklist by on startup
|
||||
# Provide a set of columns to be sorted on when calibre starts
|
||||
# The argument is None if saved sort history is to be used
|
||||
|
@ -10,6 +10,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import traceback, cPickle, copy
|
||||
from itertools import repeat
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt4.Qt import (QAbstractItemModel, QIcon, QVariant, QFont, Qt,
|
||||
QMimeData, QModelIndex, pyqtSignal, QObject)
|
||||
@ -831,7 +832,12 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
if lower(t.name).find(self.filter_categories_by) >= 0]
|
||||
|
||||
tb_categories = self.db.field_metadata
|
||||
for category in tb_categories:
|
||||
y = tweaks['tag_browser_category_order']
|
||||
deforder = y.get('*', 100)
|
||||
order = defaultdict(lambda : deforder)
|
||||
order.update(y)
|
||||
tb_keys = sorted(tb_categories.iterkeys(), key=lambda x: order[x])
|
||||
for category in tb_keys:
|
||||
if category in data: # The search category can come and go
|
||||
self.row_map.append(category)
|
||||
self.categories[category] = tb_categories[category]['name']
|
||||
|
Loading…
x
Reference in New Issue
Block a user