From 267687f424a3527aac683a1ea00c0d87244b0fe9 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sun, 29 May 2011 15:48:20 +0100 Subject: [PATCH 1/3] ... --- src/calibre/manual/template_lang.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/manual/template_lang.rst b/src/calibre/manual/template_lang.rst index ec398b5d28..f1d2844d37 100644 --- a/src/calibre/manual/template_lang.rst +++ b/src/calibre/manual/template_lang.rst @@ -114,6 +114,8 @@ The syntax for using functions is ``{field:function(arguments)}``, or ``{field:f If you have programming experience, please note that the syntax in this mode (single function) is not what you might expect. Strings are not quoted. Spaces are significant. All arguments must be constants; there is no sub-evaluation. Use :ref:`template program mode ` and :ref:`general program mode ` to avoid these differences. +Many functions use regular expressions. In all cases, regular expression matching is case-insensitive. + The functions available are: * ``lowercase()`` -- return value of the field in lower case. From 35bf5ed46e359a13211abd3f71a78da16de309db Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sun, 29 May 2011 17:36:06 +0100 Subject: [PATCH 2/3] Refresh the db when on_device is refreshed only if composite columns are defined. --- src/calibre/gui2/library/models.py | 2 +- src/calibre/library/caches.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 793f2d353b..554b104c34 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -125,7 +125,7 @@ class BooksModel(QAbstractTableModel): # {{{ def refresh_ondevice(self): self.db.refresh_ondevice() - self.refresh(reset=False) + self.resort() self.research() def set_book_on_device_func(self, func): diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 98fd3a9fbc..2ad425fc00 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -914,6 +914,8 @@ class ResultCache(SearchQueryParser): # {{{ return len(self._map) def refresh_ondevice(self, db): + if self.composites: + self.refresh(db) ondevice_col = self.FIELD_MAP['ondevice'] for item in self._data: if item is not None: From f25c4232618063c096653faee6e2337b39fa43bf Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sun, 29 May 2011 18:28:21 +0100 Subject: [PATCH 3/3] Got the ondevice composite column optimization to work. --- src/calibre/library/caches.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 2ad425fc00..470bbcdfa8 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -200,6 +200,11 @@ class CacheRow(list): # {{{ def __getslice__(self, i, j): return self.__getitem__(slice(i, j)) + def refresh_composites(self): + for c in self._composites: + self[c] = None + self._must_do = True + # }}} class ResultCache(SearchQueryParser): # {{{ @@ -914,12 +919,11 @@ class ResultCache(SearchQueryParser): # {{{ return len(self._map) def refresh_ondevice(self, db): - if self.composites: - self.refresh(db) ondevice_col = self.FIELD_MAP['ondevice'] for item in self._data: if item is not None: item[ondevice_col] = db.book_on_device_string(item[0]) + item.refresh_composites() def refresh(self, db, field=None, ascending=True): temp = db.conn.get('SELECT * FROM meta2')