mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ignore enpty valid values when creating enumerated columns instead of showing an error. Use a case-insensitive compare to check for duplicates.
This commit is contained in:
parent
4c38f87b88
commit
43bfa210c3
@ -280,14 +280,12 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
if not unicode(self.enum_box.text()).strip():
|
if not unicode(self.enum_box.text()).strip():
|
||||||
return self.simple_error('', _('You must enter at least one'
|
return self.simple_error('', _('You must enter at least one'
|
||||||
' value for enumeration columns'))
|
' value for enumeration columns'))
|
||||||
l = [v.strip() for v in unicode(self.enum_box.text()).split(',')]
|
l = [v.strip() for v in unicode(self.enum_box.text()).split(',') if v.strip()]
|
||||||
if '' in l:
|
l_lower = [v.lower() for v in l]
|
||||||
return self.simple_error('', _('You cannot provide the empty '
|
for i,v in enumerate(l_lower):
|
||||||
'value, as it is included by default'))
|
if v in l_lower[i+1:]:
|
||||||
for i in range(0, len(l)-1):
|
|
||||||
if l[i] in l[i+1:]:
|
|
||||||
return self.simple_error('', _('The value "{0}" is in the '
|
return self.simple_error('', _('The value "{0}" is in the '
|
||||||
'list more than once').format(l[i]))
|
'list more than once, perhaps with different case').format(l[i]))
|
||||||
c = unicode(self.enum_colors.text())
|
c = unicode(self.enum_colors.text())
|
||||||
if c:
|
if c:
|
||||||
c = [v.strip() for v in unicode(self.enum_colors.text()).split(',')]
|
c = [v.strip() for v in unicode(self.enum_colors.text()).split(',')]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user