This commit is contained in:
Kovid Goyal 2016-07-23 08:57:32 +05:30
parent e1c3d4afb1
commit d331c1fbe2

View File

@ -16,37 +16,68 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
# Note: in this class, we are treating is_multiple as the boolean that # Note: in this class, we are treating is_multiple as the boolean that
# custom_columns expects to find in its structure. It does not use the dict # custom_columns expects to find in its structure. It does not use the dict
column_types = { column_types = dict(enumerate((
0:{'datatype':'text', {
'datatype':'text',
'text':_('Text, column shown in the tag browser'), 'text':_('Text, column shown in the tag browser'),
'is_multiple':False}, 'is_multiple':False
1:{'datatype':'*text', },
{
'datatype':'*text',
'text':_('Comma separated text, like tags, shown in the tag browser'), 'text':_('Comma separated text, like tags, shown in the tag browser'),
'is_multiple':True}, 'is_multiple':True
2:{'datatype':'comments', },
{
'datatype':'comments',
'text':_('Long text, like comments, not shown in the tag browser'), 'text':_('Long text, like comments, not shown in the tag browser'),
'is_multiple':False}, 'is_multiple':False
3:{'datatype':'series', },
{
'datatype':'series',
'text':_('Text column for keeping series-like information'), 'text':_('Text column for keeping series-like information'),
'is_multiple':False}, 'is_multiple':False
4:{'datatype':'enumeration', },
'text':_('Text, but with a fixed set of permitted values'), 'is_multiple':False}, {
5:{'datatype':'datetime', 'datatype':'enumeration',
'text':_('Date'), 'is_multiple':False}, 'text':_('Text, but with a fixed set of permitted values'),
6:{'datatype':'float', 'is_multiple':False
'text':_('Floating point numbers'), 'is_multiple':False}, },
7:{'datatype':'int', {
'text':_('Integers'), 'is_multiple':False}, 'datatype':'datetime',
8:{'datatype':'rating', 'text':_('Date'),
'is_multiple':False
},
{
'datatype':'float',
'text':_('Floating point numbers'),
'is_multiple':False
},
{
'datatype':'int',
'text':_('Integers'),
'is_multiple':False
},
{
'datatype':'rating',
'text':_('Ratings, shown with stars'), 'text':_('Ratings, shown with stars'),
'is_multiple':False}, 'is_multiple':False
9:{'datatype':'bool', },
'text':_('Yes/No'), 'is_multiple':False}, {
10:{'datatype':'composite', 'datatype':'bool',
'text':_('Column built from other columns'), 'is_multiple':False}, 'text':_('Yes/No'),
11:{'datatype':'*composite', 'is_multiple':False
'text':_('Column built from other columns, behaves like tags'), 'is_multiple':True}, },
} {
'datatype':'composite',
'text':_('Column built from other columns'),
'is_multiple':False
},
{
'datatype':'*composite',
'text':_('Column built from other columns, behaves like tags'),
'is_multiple':True
},
)))
def __init__(self, parent, current_row, current_key, standard_colheads, standard_colnames): def __init__(self, parent, current_row, current_key, standard_colheads, standard_colnames):
QDialog.__init__(self, parent) QDialog.__init__(self, parent)
@ -231,7 +262,8 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
return self.simple_error('', _('Lookup names cannot end with _index, ' return self.simple_error('', _('Lookup names cannot end with _index, '
'because these names are reserved for the index of a series column.')) 'because these names are reserved for the index of a series column.'))
col_heading = unicode(self.column_heading_box.text()).strip() col_heading = unicode(self.column_heading_box.text()).strip()
col_type = self.column_types[self.column_type_box.currentIndex()]['datatype'] coldef = self.column_types[self.column_type_box.currentIndex()]
col_type = coldef['datatype']
if col_type[0] == '*': if col_type[0] == '*':
col_type = col_type[1:] col_type = col_type[1:]
is_multiple = True is_multiple = True