Fix editing of series type custom columns in the book list. Fixes #8765 (Custom series like column weird behaviour)

This commit is contained in:
Kovid Goyal 2011-02-04 23:08:15 -07:00
commit 215c469093
2 changed files with 13 additions and 1 deletions

View File

@ -791,6 +791,16 @@ class BooksModel(QAbstractTableModel): # {{{
val = qt_to_dt(val, as_utc=False) val = qt_to_dt(val, as_utc=False)
elif typ == 'series': elif typ == 'series':
val = unicode(value.toString()).strip() 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': elif typ == 'composite':
tmpl = unicode(value.toString()).strip() tmpl = unicode(value.toString()).strip()
disp = cc['display'] disp = cc['display']

View File

@ -484,7 +484,9 @@ class CustomColumns(object):
if not existing: if not existing:
existing = [] existing = []
for x in set(set_val) - set(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 continue
case_change = False case_change = False
existing = list(self.all_custom(num=data['num'])) existing = list(self.all_custom(num=data['num']))