From 23b67eb3b10c13e44ce771ed9c89a25024de29b0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 20 May 2010 01:49:15 -0600 Subject: [PATCH 1/3] SONY driver: Set the titleSorter attribute in the XML cache --- src/calibre/devices/prs505/sony_cache.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/calibre/devices/prs505/sony_cache.py b/src/calibre/devices/prs505/sony_cache.py index 262d1a3f64..5d4cf1d10a 100644 --- a/src/calibre/devices/prs505/sony_cache.py +++ b/src/calibre/devices/prs505/sony_cache.py @@ -16,7 +16,8 @@ from calibre import prints, guess_type from calibre.devices.errors import DeviceError from calibre.constants import DEBUG from calibre.ebooks.chardet import xml_to_unicode -from calibre.ebooks.metadata import string_to_authors, authors_to_string +from calibre.ebooks.metadata import string_to_authors, authors_to_string, \ + title_sort # Utility functions {{{ EMPTY_CARD_CACHE = '''\ @@ -344,7 +345,7 @@ class XMLCache(object): # *should* never happen if DEBUG and None in records: prints('WARNING: Some elements in the JSON cache were not' - 'found in the XML cache') + ' found in the XML cache') records = [x for x in records if x is not None] for rec in records: if rec.get('id', None) is None: @@ -413,6 +414,10 @@ class XMLCache(object): record.set('date', date) record.set('size', str(os.stat(path).st_size)) record.set('title', book.title) + ts = book.title_sort + if not ts: + ts = title_sort(book.title) + record.set('titleSorter', ts) record.set('author', authors_to_string(book.authors)) ext = os.path.splitext(path)[1] if ext: From d3ef29463fcea27377675c3c32e56421050ac0a0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 20 May 2010 08:59:57 -0600 Subject: [PATCH 2/3] Make prints more robust --- src/calibre/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index 737fa0b383..e44f8d8ec6 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -141,7 +141,10 @@ def prints(*args, **kwargs): raise arg = repr(arg) - file.write(arg) + try: + file.write(arg) + except: + file.write(repr(arg)) if i != len(args)-1: file.write(sep) file.write(end) From a28c63dc1ff86348d216364c50639446534124e1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 20 May 2010 09:22:05 -0600 Subject: [PATCH 3/3] Remove text alignment from rating/bool type columns --- src/calibre/gui2/library/views.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index bae4950de0..d2c3839466 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -111,17 +111,21 @@ class BooksView(QTableView): # {{{ ac = a if self._model.sorted_on[1] == Qt.AscendingOrder else d ac.setCheckable(True) ac.setChecked(True) - m = self.column_header_context_menu.addMenu( - _('Change text alignment for %s') % name) - al = self._model.alignment_map.get(col, 'left') - for x, t in (('left', _('Left')), ('right', _('Right')), ('center', - _('Center'))): - a = m.addAction(t, - partial(self.column_header_context_handler, - action='align_'+x, column=col)) - if al == x: - a.setCheckable(True) - a.setChecked(True) + if col not in ('ondevice', 'rating', 'inlibrary') and \ + (not self.model().is_custom_column(col) or \ + self.model().custom_columns[col]['datatype'] not in ('bool', + 'rating')): + m = self.column_header_context_menu.addMenu( + _('Change text alignment for %s') % name) + al = self._model.alignment_map.get(col, 'left') + for x, t in (('left', _('Left')), ('right', _('Right')), ('center', + _('Center'))): + a = m.addAction(t, + partial(self.column_header_context_handler, + action='align_'+x, column=col)) + if al == x: + a.setCheckable(True) + a.setChecked(True)