diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index 9f58ab3f03..bda839b28f 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -61,13 +61,13 @@ sort_columns_at_startup = None # default if not set: MMM yyyy gui_pubdate_display_format = 'MMM yyyy' -# Control title sorting. +# Control title and series sorting in the library view. # If set to 'library_order', Leading articles such as The and A will be ignored. # If set to 'strictly_alphabetic', the titles will be sorted without processing # For example, with library_order, The Client will sort under 'C'. With # strictly_alphabetic, the book will sort under 'T'. # This flag affects Calibre's library display. It has no effect on devices. In -# addition, books added before changing the flag will retain their order until -# the title is edited. Double-clicking on a title and hitting return without -# changing anything is sufficient to change the sort. -title_sorting = 'library_order' +# addition, titles for books added before changing the flag will retain their +# order until the title is edited. Double-clicking on a title and hitting return +# without changing anything is sufficient to change the sort. +title_series_sorting = 'library_order' diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index e2ecdd9f55..95ca4cc826 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -619,9 +619,12 @@ class ResultCache(SearchQueryParser): if self.first_sort: subsort = True self.first_sort = False - fcmp = self.seriescmp if field == 'series' else \ - functools.partial(self.cmp, self.FIELD_MAP[field], subsort=subsort, - asstr=as_string) + fcmp = self.seriescmp \ + if field == 'series' and \ + tweaks['title_sorting'] == 'library_order' \ + else \ + functools.partial(self.cmp, self.FIELD_MAP[field], + subsort=subsort, asstr=as_string) self._map.sort(cmp=fcmp, reverse=not ascending) self._map_filtered = [id for id in self._map if id in self._map_filtered] diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 64fcfd7a6e..0168737fca 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -736,7 +736,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): icon=icon, tooltip = tooltip) for r in data if item_not_zero_func(r)] if category == 'series' and not sort_on_count: - if tweaks['title_sorting'] == 'library_order': + if tweaks['title_series_sorting'] == 'library_order': ts = lambda x: title_sort(x) else: ts = lambda x:x @@ -954,7 +954,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): title = title.decode(preferred_encoding, 'replace') self.conn.execute('UPDATE books SET title=? WHERE id=?', (title, id)) self.data.set(id, self.FIELD_MAP['title'], title, row_is_id=True) - if tweaks['title_sorting'] == 'library_order': + if tweaks['title_series_sorting'] == 'library_order': self.data.set(id, self.FIELD_MAP['sort'], title_sort(title), row_is_id=True) else: self.data.set(id, self.FIELD_MAP['sort'], title, row_is_id=True) diff --git a/src/calibre/library/sqlite.py b/src/calibre/library/sqlite.py index ca501b9300..adf6691671 100644 --- a/src/calibre/library/sqlite.py +++ b/src/calibre/library/sqlite.py @@ -116,7 +116,7 @@ class DBThread(Thread): self.conn.create_aggregate('concat', 1, Concatenate) self.conn.create_aggregate('sortconcat', 2, SortedConcatenate) self.conn.create_aggregate('sort_concat', 2, SafeSortedConcatenate) - if tweaks['title_sorting'] == 'library_order': + if tweaks['title_series_sorting'] == 'library_order': self.conn.create_function('title_sort', 1, title_sort) else: self.conn.create_function('title_sort', 1, lambda x:x)