mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
commit
c33e36dc22
@ -82,7 +82,8 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
ct = c['datatype'] if not c['is_multiple'] else '*text'
|
ct = c['datatype'] if not c['is_multiple'] else '*text'
|
||||||
self.orig_column_number = c['colnum']
|
self.orig_column_number = c['colnum']
|
||||||
self.orig_column_name = col
|
self.orig_column_name = col
|
||||||
column_numbers = dict(map(lambda x:(self.column_types[x]['datatype'], x), self.column_types))
|
column_numbers = dict(map(lambda x:(self.column_types[x]['datatype'], x),
|
||||||
|
self.column_types))
|
||||||
self.column_type_box.setCurrentIndex(column_numbers[ct])
|
self.column_type_box.setCurrentIndex(column_numbers[ct])
|
||||||
self.column_type_box.setEnabled(False)
|
self.column_type_box.setEnabled(False)
|
||||||
if ct == 'datetime':
|
if ct == 'datetime':
|
||||||
@ -109,9 +110,11 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
if not col:
|
if not col:
|
||||||
return self.simple_error('', _('No lookup name was provided'))
|
return self.simple_error('', _('No lookup name was provided'))
|
||||||
if re.match('^\w*$', col) is None or not col[0].isalpha() or col.lower() != col:
|
if re.match('^\w*$', col) is None or not col[0].isalpha() or col.lower() != col:
|
||||||
return self.simple_error('', _('The lookup name must contain only lower case letters, digits and underscores, and start with a letter'))
|
return self.simple_error('', _('The lookup name must contain only '
|
||||||
|
'lower case letters, digits and underscores, and start with a letter'))
|
||||||
if col.endswith('_index'):
|
if col.endswith('_index'):
|
||||||
return self.simple_error('', _('Lookup names cannot end with _index, because these names are reserved for the index of a series column.'))
|
return self.simple_error('', _('Lookup names cannot end with _index, '
|
||||||
|
'because these names are reserved for the index of a series column.'))
|
||||||
col_heading = unicode(self.column_heading_box.text())
|
col_heading = unicode(self.column_heading_box.text())
|
||||||
col_type = self.column_types[self.column_type_box.currentIndex()]['datatype']
|
col_type = self.column_types[self.column_type_box.currentIndex()]['datatype']
|
||||||
if col_type == '*text':
|
if col_type == '*text':
|
||||||
@ -123,7 +126,8 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
return self.simple_error('', _('No column heading was provided'))
|
return self.simple_error('', _('No column heading was provided'))
|
||||||
bad_col = False
|
bad_col = False
|
||||||
if col in self.parent.custcols:
|
if col in self.parent.custcols:
|
||||||
if not self.editing_col or self.parent.custcols[col]['colnum'] != self.orig_column_number:
|
if not self.editing_col or \
|
||||||
|
self.parent.custcols[col]['colnum'] != self.orig_column_number:
|
||||||
bad_col = True
|
bad_col = True
|
||||||
if bad_col:
|
if bad_col:
|
||||||
return self.simple_error('', _('The lookup name %s is already used')%col)
|
return self.simple_error('', _('The lookup name %s is already used')%col)
|
||||||
@ -131,7 +135,8 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
bad_head = False
|
bad_head = False
|
||||||
for t in self.parent.custcols:
|
for t in self.parent.custcols:
|
||||||
if self.parent.custcols[t]['name'] == col_heading:
|
if self.parent.custcols[t]['name'] == col_heading:
|
||||||
if not self.editing_col or self.parent.custcols[t]['colnum'] != self.orig_column_number:
|
if not self.editing_col or \
|
||||||
|
self.parent.custcols[t]['colnum'] != self.orig_column_number:
|
||||||
bad_head = True
|
bad_head = True
|
||||||
for t in self.standard_colheads:
|
for t in self.standard_colheads:
|
||||||
if self.standard_colheads[t] == col_heading:
|
if self.standard_colheads[t] == col_heading:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user