mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Clean up the new composite splitter API to ignore case and ignore dups. Make Quickview use the new API.
This commit is contained in:
parent
c24f59151c
commit
e5b664c162
@ -2351,9 +2351,15 @@ class Cache:
|
||||
|
||||
@read_api
|
||||
def split_if_is_multiple_composite(self, f, v):
|
||||
'''
|
||||
If f is a composite column lookup key and the column is is_multiple then
|
||||
split comma-separated v into unique non-empty values. The uniqueness
|
||||
comparison is case-insensitive. If values are case-insensitive equals
|
||||
then the last is returned.
|
||||
'''
|
||||
fm = self.field_metadata.get(f, None)
|
||||
if fm and fm['datatype'] == 'composite' and fm['is_multiple']:
|
||||
return [v.strip() for v in v.split(',') if v.strip()]
|
||||
return list({v.strip().lower() : v.strip() for v in v.split(',') if v.strip()}.values())
|
||||
return v
|
||||
|
||||
@read_api
|
||||
|
@ -542,10 +542,9 @@ class Quickview(QDialog, Ui_Quickview):
|
||||
self.books_table.setRowCount(0)
|
||||
|
||||
mi = self.db.new_api.get_proxy_metadata(book_id)
|
||||
vals = mi.get(key, None)
|
||||
if self.fm[key]['datatype'] == 'composite' and self.fm[key]['is_multiple']:
|
||||
sep = self.fm[key]['is_multiple'].get('cache_to_list', ',')
|
||||
vals = [v.strip() for v in vals.split(sep) if v.strip()]
|
||||
print('aaa', key, mi.get(key, None))
|
||||
vals = self.db.new_api.split_if_is_multiple_composite(key, mi.get(key, None))
|
||||
print('bbb', vals)
|
||||
try:
|
||||
# Check if we are in the GridView and there are no values for the
|
||||
# selected column. In this case switch the column to 'authors'
|
||||
|
Loading…
x
Reference in New Issue
Block a user