From 480fd141e00c92e030f13ab4d327da29519e7e54 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sat, 5 Feb 2011 05:11:24 +0000 Subject: [PATCH] Fix #8765: Custom series like column weird behaviour --- src/calibre/gui2/library/models.py | 10 ++++++++++ src/calibre/library/custom_columns.py | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 0b6991665b..2f8a747c39 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -791,6 +791,16 @@ class BooksModel(QAbstractTableModel): # {{{ val = qt_to_dt(val, as_utc=False) elif typ == 'series': val = unicode(value.toString()).strip() + if val: + pat = re.compile(r'\[([.0-9]+)\]') + match = pat.search(val) + if match is not None: + s_index = float(match.group(1)) + val = pat.sub('', val).strip() + elif val: + if tweaks['series_index_auto_increment'] != 'const': + s_index = self.db.get_next_cc_series_num_for(val, + label=label, num=None) elif typ == 'composite': tmpl = unicode(value.toString()).strip() disp = cc['display'] diff --git a/src/calibre/library/custom_columns.py b/src/calibre/library/custom_columns.py index 467a3f309e..cb735dc529 100644 --- a/src/calibre/library/custom_columns.py +++ b/src/calibre/library/custom_columns.py @@ -484,7 +484,9 @@ class CustomColumns(object): if not existing: existing = [] for x in set(set_val) - set(existing): - if x is None: + # normalized types are text and ratings, so we can do this check + # to see if we need to re-add the value + if not x: continue case_change = False existing = list(self.all_custom(num=data['num']))