From fe1316f201d541e2cbc6db34120b0daca6f66559 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Thu, 10 Jun 2010 21:16:54 +0100 Subject: [PATCH] Title sort tweak. --- resources/default_tweaks.py | 10 ++++++++++ src/calibre/ebooks/metadata/__init__.py | 9 +++++---- src/calibre/gui2/cover_flow.py | 4 +++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index e9ad64cee2..9f58ab3f03 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -61,3 +61,13 @@ sort_columns_at_startup = None # default if not set: MMM yyyy gui_pubdate_display_format = 'MMM yyyy' +# Control title sorting. +# 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' diff --git a/src/calibre/ebooks/metadata/__init__.py b/src/calibre/ebooks/metadata/__init__.py index 6b573a0420..e6551e9019 100644 --- a/src/calibre/ebooks/metadata/__init__.py +++ b/src/calibre/ebooks/metadata/__init__.py @@ -43,10 +43,11 @@ def authors_to_sort_string(authors): _title_pat = re.compile('^(A|The|An)\s+', re.IGNORECASE) def title_sort(title): - match = _title_pat.search(title) - if match: - prep = match.group(1) - title = title[len(prep):] + ', ' + prep + if tweaks['title_sorting'] == 'library_order': + match = _title_pat.search(title) + if match: + prep = match.group(1) + title = title[len(prep):] + ', ' + prep return title.strip() coding = zip( diff --git a/src/calibre/gui2/cover_flow.py b/src/calibre/gui2/cover_flow.py index 3bd554e891..27f8687b22 100644 --- a/src/calibre/gui2/cover_flow.py +++ b/src/calibre/gui2/cover_flow.py @@ -67,7 +67,9 @@ if pictureflow is not None: return ans def reset(self): - self.dataChanged.emit() + from PyQt4.Qt import SIGNAL ### TEMP + self.emit(SIGNAL('dataChanged()')) # TEMP +# self.dataChanged.emit() def image(self, index): return self.model.cover(index)