mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
When listing series, sort ignoring leading English prepositions. Fixes #5090 (Series Sort)
This commit is contained in:
parent
7a737aa3a1
commit
c2f655ad71
@ -17,7 +17,7 @@ from calibre.utils.config import tweaks
|
|||||||
from calibre.utils.date import parse_date, now, UNDEFINED_DATE
|
from calibre.utils.date import parse_date, now, UNDEFINED_DATE
|
||||||
from calibre.utils.search_query_parser import SearchQueryParser
|
from calibre.utils.search_query_parser import SearchQueryParser
|
||||||
from calibre.utils.pyparsing import ParseException
|
from calibre.utils.pyparsing import ParseException
|
||||||
# from calibre.library.field_metadata import FieldMetadata
|
from calibre.ebooks.metadata import title_sort
|
||||||
|
|
||||||
class CoverCache(QThread):
|
class CoverCache(QThread):
|
||||||
|
|
||||||
@ -564,7 +564,8 @@ class ResultCache(SearchQueryParser):
|
|||||||
def seriescmp(self, x, y):
|
def seriescmp(self, x, y):
|
||||||
sidx = self.FIELD_MAP['series']
|
sidx = self.FIELD_MAP['series']
|
||||||
try:
|
try:
|
||||||
ans = cmp(self._data[x][sidx].lower(), self._data[y][sidx].lower())
|
ans = cmp(title_sort(self._data[x][sidx].lower()),
|
||||||
|
title_sort(self._data[y][sidx].lower()))
|
||||||
except AttributeError: # Some entries may be None
|
except AttributeError: # Some entries may be None
|
||||||
ans = cmp(self._data[x][sidx], self._data[y][sidx])
|
ans = cmp(self._data[x][sidx], self._data[y][sidx])
|
||||||
if ans != 0: return ans
|
if ans != 0: return ans
|
||||||
|
@ -725,6 +725,9 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
categories[category] = [Tag(formatter(r[1]), count=r[2], id=r[0],
|
categories[category] = [Tag(formatter(r[1]), count=r[2], id=r[0],
|
||||||
icon=icon, tooltip = tooltip)
|
icon=icon, tooltip = tooltip)
|
||||||
for r in data if item_not_zero_func(r)]
|
for r in data if item_not_zero_func(r)]
|
||||||
|
if category == 'series':
|
||||||
|
categories[category].sort(cmp=lambda x,y:cmp(title_sort(x.name),
|
||||||
|
title_sort(y.name)))
|
||||||
|
|
||||||
# We delayed computing the standard formats category because it does not
|
# We delayed computing the standard formats category because it does not
|
||||||
# use a view, but is computed dynamically
|
# use a view, but is computed dynamically
|
||||||
|
@ -16,7 +16,7 @@ except ImportError:
|
|||||||
|
|
||||||
from calibre import fit_image, guess_type
|
from calibre import fit_image, guess_type
|
||||||
from calibre.utils.date import fromtimestamp
|
from calibre.utils.date import fromtimestamp
|
||||||
|
from calibre.ebooks.metadata import title_sort
|
||||||
|
|
||||||
class ContentServer(object):
|
class ContentServer(object):
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ class ContentServer(object):
|
|||||||
def seriescmp(self, x, y):
|
def seriescmp(self, x, y):
|
||||||
si = self.db.FIELD_MAP['series']
|
si = self.db.FIELD_MAP['series']
|
||||||
try:
|
try:
|
||||||
ans = cmp(x[si].lower(), y[si].lower())
|
ans = cmp(title_sort(x[si].lower()), title_sort(y[si].lower()))
|
||||||
except AttributeError: # Some entries may be None
|
except AttributeError: # Some entries may be None
|
||||||
ans = cmp(x[si], y[si])
|
ans = cmp(x[si], y[si])
|
||||||
if ans != 0: return ans
|
if ans != 0: return ans
|
||||||
|
Loading…
x
Reference in New Issue
Block a user