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:
|
else:
|
||||||
prefix = ''
|
prefix = ''
|
||||||
category = tag.category if key != 'news' else 'tag'
|
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
|
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)))
|
ans.append('%s%s:%s'%(prefix, category, len(tag.name)))
|
||||||
else:
|
else:
|
||||||
@ -1604,8 +1607,9 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
n = name.replace(r'"', r'\"')
|
n = name.replace(r'"', r'\"')
|
||||||
if name.startswith('.'):
|
if name.startswith('.'):
|
||||||
n = '.' + n
|
n = '.' + n
|
||||||
ans.append('%s%s:"=%s%s"'%(prefix, category,
|
ans.append('%s%s:"=%s%s%s"'%(prefix, category,
|
||||||
'.' if use_prefix else '', n))
|
'.' if use_prefix else '', n,
|
||||||
|
':' if add_colon else ''))
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
def find_item_node(self, key, txt, start_path, equals_match=False):
|
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.
|
# No need for ICU here.
|
||||||
categories['formats'].sort(key = lambda x:x.name)
|
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. ####
|
#### Now do the user-defined categories. ####
|
||||||
user_categories = dict.copy(self.clean_user_categories())
|
user_categories = dict.copy(self.clean_user_categories())
|
||||||
|
|
||||||
|
@ -16,7 +16,8 @@ class TagsIcons(dict):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
category_icons = ['authors', 'series', 'formats', 'publisher', 'rating',
|
category_icons = ['authors', 'series', 'formats', 'publisher', 'rating',
|
||||||
'news', 'tags', 'custom:', 'user:', 'search',]
|
'news', 'tags', 'custom:', 'user:', 'search',
|
||||||
|
'identifiers']
|
||||||
def __init__(self, icon_dict):
|
def __init__(self, icon_dict):
|
||||||
for a in self.category_icons:
|
for a in self.category_icons:
|
||||||
if a not in icon_dict:
|
if a not in icon_dict:
|
||||||
@ -24,16 +25,17 @@ class TagsIcons(dict):
|
|||||||
self[a] = icon_dict[a]
|
self[a] = icon_dict[a]
|
||||||
|
|
||||||
category_icon_map = {
|
category_icon_map = {
|
||||||
'authors' : 'user_profile.png',
|
'authors' : 'user_profile.png',
|
||||||
'series' : 'series.png',
|
'series' : 'series.png',
|
||||||
'formats' : 'book.png',
|
'formats' : 'book.png',
|
||||||
'publisher' : 'publisher.png',
|
'publisher' : 'publisher.png',
|
||||||
'rating' : 'rating.png',
|
'rating' : 'rating.png',
|
||||||
'news' : 'news.png',
|
'news' : 'news.png',
|
||||||
'tags' : 'tags.png',
|
'tags' : 'tags.png',
|
||||||
'custom:' : 'column.png',
|
'custom:' : 'column.png',
|
||||||
'user:' : 'tb_folder.png',
|
'user:' : 'tb_folder.png',
|
||||||
'search' : 'search.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))):
|
for category in sorted(categories, key=lambda x: sort_key(getter(x))):
|
||||||
if len(categories[category]) == 0:
|
if len(categories[category]) == 0:
|
||||||
continue
|
continue
|
||||||
if category == 'formats':
|
if category in ('formats', 'identifiers'):
|
||||||
continue
|
continue
|
||||||
meta = category_meta.get(category, None)
|
meta = category_meta.get(category, None)
|
||||||
if meta is None:
|
if meta is None:
|
||||||
|
@ -580,7 +580,7 @@ class OPDSServer(object):
|
|||||||
for category in sorted(categories, key=lambda x: sort_key(getter(x))):
|
for category in sorted(categories, key=lambda x: sort_key(getter(x))):
|
||||||
if len(categories[category]) == 0:
|
if len(categories[category]) == 0:
|
||||||
continue
|
continue
|
||||||
if category == 'formats':
|
if category in ('formats', 'identifiers'):
|
||||||
continue
|
continue
|
||||||
meta = category_meta.get(category, None)
|
meta = category_meta.get(category, None)
|
||||||
if meta is None:
|
if meta is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user