Cleanup previous PR

This commit is contained in:
Kovid Goyal 2022-04-16 21:14:30 +05:30
parent 5ec25f5ff8
commit 15560be227
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 9 additions and 10 deletions

View File

@ -286,7 +286,7 @@ class Float(Int):
self.widgets = [QLabel(label_string(self.col_metadata['name']), parent)]
self.finish_ui_setup(parent, ClearingDoubleSpinBox)
self.editor.setRange(-1000000., float(100000000))
self.editor.setDecimals(self.col_metadata['display'].get('decimals', 2))
self.editor.setDecimals(int(self.col_metadata['display'].get('decimals', 2)))
class Rating(Base):
@ -1098,7 +1098,7 @@ class BulkFloat(BulkInt):
def setup_ui(self, parent):
self.make_widgets(parent, QDoubleSpinBox)
self.main_widget.setRange(-1000000., float(100000000))
self.main_widget.setDecimals(self.col_metadata['display'].get('decimals', 2))
self.main_widget.setDecimals(int(self.col_metadata['display'].get('decimals', 2)))
self.finish_ui_setup(parent)
def set_to_undefined(self):

View File

@ -553,7 +553,7 @@ class CcNumberDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
editor = ClearingDoubleSpinBox(parent)
editor.setSpecialValueText(_('Undefined'))
editor.setRange(-1000000., 100000000.)
editor.setDecimals(m.custom_columns[col]['display'].get('decimals', 2))
editor.setDecimals(int(m.custom_columns[col]['display'].get('decimals', 2)))
return editor
def setModelData(self, editor, model, index):

View File

@ -197,7 +197,7 @@ class CreateCustomColumn(QDialog):
elif ct == '*text':
self.is_names.setChecked(c['display'].get('is_names', False))
self.description_box.setText(c['display'].get('description', ''))
self.decimals_box.setValue(min(9, max(1, c['display'].get('decimals', 2))))
self.decimals_box.setValue(min(9, max(1, int(c['display'].get('decimals', 2)))))
all_colors = [str(s) for s in list(QColor.colorNames())]
self.enum_colors_label.setToolTip('<p>' + ', '.join(all_colors) + '</p>')
@ -328,14 +328,13 @@ class CreateCustomColumn(QDialog):
h = QHBoxLayout()
self.decimals_box = fb = QSpinBox(self)
fb.setRange(1, 9)
fb.setValue(2)
h.addWidget(fb)
self.decimals_default_label = la = QLabel(_('This controls the number of decimal '
'digits you can enter when editing '
'this column using the GUI. The '
'value can be between 1 and 9'))
self.decimals_default_label = la = QLabel(_(
'Control the number of decimal digits you can enter when editing this column'))
la.setWordWrap(True)
h.addWidget(la)
self.decimals_label = add_row(_('Decimals when editing:'), h)
self.decimals_label = add_row(_('Decimals when &editing:'), h)
# Template
self.composite_box = cb = TemplateLineEditor(self)
@ -607,7 +606,7 @@ class CreateCustomColumn(QDialog):
else:
display_dict = {'number_format': None}
if col_type == 'float':
display_dict['decimals'] = self.decimals_box.value()
display_dict['decimals'] = int(self.decimals_box.value())
if default_val:
try:
if col_type == 'int':