mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Add identifiers to the Tag Browser
This commit is contained in:
commit
a1b1fae333
BIN
resources/images/id_card.png
Normal file
BIN
resources/images/id_card.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
@ -1588,6 +1588,9 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
else:
|
||||
prefix = ''
|
||||
category = tag.category if key != 'news' else 'tag'
|
||||
if self.db.field_metadata[tag.category]['is_csp']:
|
||||
add_colon = True
|
||||
|
||||
if tag.name and tag.name[0] == u'\u2605': # char is a star. Assume rating
|
||||
ans.append('%s%s:%s'%(prefix, category, len(tag.name)))
|
||||
else:
|
||||
@ -1604,8 +1607,9 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
n = name.replace(r'"', r'\"')
|
||||
if name.startswith('.'):
|
||||
n = '.' + n
|
||||
ans.append('%s%s:"=%s%s"'%(prefix, category,
|
||||
'.' if use_prefix else '', n))
|
||||
ans.append('%s%s:"=%s%s%s"'%(prefix, category,
|
||||
'.' if use_prefix else '', n,
|
||||
':' if add_colon else ''))
|
||||
return ans
|
||||
|
||||
def find_item_node(self, key, txt, start_path, equals_match=False):
|
||||
|
@ -1493,6 +1493,34 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
# No need for ICU here.
|
||||
categories['formats'].sort(key = lambda x:x.name)
|
||||
|
||||
# Now do identifiers. This works like formats
|
||||
categories['identifiers'] = []
|
||||
icon = None
|
||||
if icon_map and 'identifiers' in icon_map:
|
||||
icon = icon_map['identifiers']
|
||||
for ident in self.conn.get('SELECT DISTINCT type FROM identifiers'):
|
||||
ident = ident[0]
|
||||
if ids is not None:
|
||||
count = self.conn.get('''SELECT COUNT(book)
|
||||
FROM identifiers
|
||||
WHERE type="%s" AND
|
||||
books_list_filter(book)'''%ident,
|
||||
all=False)
|
||||
else:
|
||||
count = self.conn.get('''SELECT COUNT(id)
|
||||
FROM identifiers
|
||||
WHERE type="%s"'''%ident,
|
||||
all=False)
|
||||
if count > 0:
|
||||
categories['identifiers'].append(Tag(ident, count=count, icon=icon,
|
||||
category='identifiers'))
|
||||
|
||||
if sort == 'popularity':
|
||||
categories['identifiers'].sort(key=lambda x: x.count, reverse=True)
|
||||
else: # no ratings exist to sort on
|
||||
# No need for ICU here.
|
||||
categories['identifiers'].sort(key = lambda x:x.name)
|
||||
|
||||
#### Now do the user-defined categories. ####
|
||||
user_categories = dict.copy(self.clean_user_categories())
|
||||
|
||||
|
@ -16,7 +16,8 @@ class TagsIcons(dict):
|
||||
'''
|
||||
|
||||
category_icons = ['authors', 'series', 'formats', 'publisher', 'rating',
|
||||
'news', 'tags', 'custom:', 'user:', 'search',]
|
||||
'news', 'tags', 'custom:', 'user:', 'search',
|
||||
'identifiers']
|
||||
def __init__(self, icon_dict):
|
||||
for a in self.category_icons:
|
||||
if a not in icon_dict:
|
||||
@ -24,16 +25,17 @@ class TagsIcons(dict):
|
||||
self[a] = icon_dict[a]
|
||||
|
||||
category_icon_map = {
|
||||
'authors' : 'user_profile.png',
|
||||
'series' : 'series.png',
|
||||
'formats' : 'book.png',
|
||||
'publisher' : 'publisher.png',
|
||||
'rating' : 'rating.png',
|
||||
'news' : 'news.png',
|
||||
'tags' : 'tags.png',
|
||||
'custom:' : 'column.png',
|
||||
'user:' : 'tb_folder.png',
|
||||
'search' : 'search.png'
|
||||
'authors' : 'user_profile.png',
|
||||
'series' : 'series.png',
|
||||
'formats' : 'book.png',
|
||||
'publisher' : 'publisher.png',
|
||||
'rating' : 'rating.png',
|
||||
'news' : 'news.png',
|
||||
'tags' : 'tags.png',
|
||||
'custom:' : 'column.png',
|
||||
'user:' : 'tb_folder.png',
|
||||
'search' : 'search.png',
|
||||
'identifiers': 'id_card.png'
|
||||
}
|
||||
|
||||
|
||||
|
@ -346,7 +346,7 @@ class BrowseServer(object):
|
||||
for category in sorted(categories, key=lambda x: sort_key(getter(x))):
|
||||
if len(categories[category]) == 0:
|
||||
continue
|
||||
if category == 'formats':
|
||||
if category in ('formats', 'identifiers'):
|
||||
continue
|
||||
meta = category_meta.get(category, None)
|
||||
if meta is None:
|
||||
|
@ -580,7 +580,7 @@ class OPDSServer(object):
|
||||
for category in sorted(categories, key=lambda x: sort_key(getter(x))):
|
||||
if len(categories[category]) == 0:
|
||||
continue
|
||||
if category == 'formats':
|
||||
if category in ('formats', 'identifiers'):
|
||||
continue
|
||||
meta = category_meta.get(category, None)
|
||||
if meta is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user