mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
In bulk and single edit, make the initial "up value" operation on an undefined field set the value to zero instead of -999999
This commit is contained in:
parent
bd0a2129b1
commit
3155b2717d
@ -129,13 +129,14 @@ class Int(Base):
|
||||
w.setRange(-1000000, 100000000)
|
||||
w.setSpecialValueText(_('Undefined'))
|
||||
w.setSingleStep(1)
|
||||
self.was_none = False
|
||||
w.valueChanged.connect(self.valueChanged)
|
||||
|
||||
def setter(self, val):
|
||||
if val is None:
|
||||
val = self.widgets[1].minimum()
|
||||
else:
|
||||
val = int(val)
|
||||
self.widgets[1].setValue(val)
|
||||
self.was_none = val == self.widgets[1].minimum()
|
||||
|
||||
def getter(self):
|
||||
val = self.widgets[1].value()
|
||||
@ -143,6 +144,12 @@ class Int(Base):
|
||||
val = None
|
||||
return val
|
||||
|
||||
def valueChanged(self, toWhat):
|
||||
if self.was_none and toWhat == -999999:
|
||||
self.changed_from_none = True
|
||||
self.setter(0)
|
||||
self.was_none = toWhat == self.widgets[1].minimum()
|
||||
|
||||
class Float(Int):
|
||||
|
||||
def setup_ui(self, parent):
|
||||
@ -153,11 +160,8 @@ class Float(Int):
|
||||
w.setDecimals(2)
|
||||
w.setSpecialValueText(_('Undefined'))
|
||||
w.setSingleStep(1)
|
||||
|
||||
def setter(self, val):
|
||||
if val is None:
|
||||
val = self.widgets[1].minimum()
|
||||
self.widgets[1].setValue(val)
|
||||
self.was_none = False
|
||||
w.valueChanged.connect(self.valueChanged)
|
||||
|
||||
class Rating(Base):
|
||||
|
||||
@ -797,14 +801,15 @@ class BulkInt(BulkBase):
|
||||
self.main_widget.setRange(-1000000, 100000000)
|
||||
self.main_widget.setSpecialValueText(_('Undefined'))
|
||||
self.main_widget.setSingleStep(1)
|
||||
self.was_none = False
|
||||
self.main_widget.valueChanged.connect(self.valueChanged)
|
||||
|
||||
def setter(self, val):
|
||||
if val is None:
|
||||
val = self.main_widget.minimum()
|
||||
else:
|
||||
val = int(val)
|
||||
self.main_widget.setValue(val)
|
||||
self.ignore_change_signals = False
|
||||
self.was_none = val == self.main_widget.minimum()
|
||||
|
||||
def getter(self):
|
||||
val = self.main_widget.value()
|
||||
@ -812,6 +817,12 @@ class BulkInt(BulkBase):
|
||||
val = None
|
||||
return val
|
||||
|
||||
def valueChanged(self, toWhat):
|
||||
if self.was_none and toWhat == -999999:
|
||||
self.changed_from_none = True
|
||||
self.setter(0)
|
||||
self.was_none = toWhat == self.main_widget.minimum()
|
||||
|
||||
class BulkFloat(BulkInt):
|
||||
|
||||
def setup_ui(self, parent):
|
||||
@ -820,6 +831,8 @@ class BulkFloat(BulkInt):
|
||||
self.main_widget.setDecimals(2)
|
||||
self.main_widget.setSpecialValueText(_('Undefined'))
|
||||
self.main_widget.setSingleStep(1)
|
||||
self.was_none = False
|
||||
self.main_widget.valueChanged.connect(self.valueChanged)
|
||||
|
||||
class BulkRating(BulkBase):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user