mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow integer and float fields to go to -999999. -1000000 is the value of 'undefined'. Fixes #821941 ([enhancement] negative date field for ancient books)
This commit is contained in:
commit
0adb30cd32
@ -87,7 +87,7 @@ class Int(Base):
|
|||||||
self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent),
|
self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent),
|
||||||
QSpinBox(parent)]
|
QSpinBox(parent)]
|
||||||
w = self.widgets[1]
|
w = self.widgets[1]
|
||||||
w.setRange(-100, 100000000)
|
w.setRange(-1000000, 100000000)
|
||||||
w.setSpecialValueText(_('Undefined'))
|
w.setSpecialValueText(_('Undefined'))
|
||||||
w.setSingleStep(1)
|
w.setSingleStep(1)
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ class Float(Int):
|
|||||||
self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent),
|
self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent),
|
||||||
QDoubleSpinBox(parent)]
|
QDoubleSpinBox(parent)]
|
||||||
w = self.widgets[1]
|
w = self.widgets[1]
|
||||||
w.setRange(-100., float(100000000))
|
w.setRange(-1000000., float(100000000))
|
||||||
w.setDecimals(2)
|
w.setDecimals(2)
|
||||||
w.setSpecialValueText(_('Undefined'))
|
w.setSpecialValueText(_('Undefined'))
|
||||||
w.setSingleStep(1)
|
w.setSingleStep(1)
|
||||||
@ -300,7 +300,6 @@ class Series(Base):
|
|||||||
w = QDoubleSpinBox(parent)
|
w = QDoubleSpinBox(parent)
|
||||||
w.setRange(-100., float(100000000))
|
w.setRange(-100., float(100000000))
|
||||||
w.setDecimals(2)
|
w.setDecimals(2)
|
||||||
w.setSpecialValueText(_('Undefined'))
|
|
||||||
w.setSingleStep(1)
|
w.setSingleStep(1)
|
||||||
self.idx_widget=w
|
self.idx_widget=w
|
||||||
self.widgets.append(w)
|
self.widgets.append(w)
|
||||||
@ -605,7 +604,7 @@ class BulkInt(BulkBase):
|
|||||||
|
|
||||||
def setup_ui(self, parent):
|
def setup_ui(self, parent):
|
||||||
self.make_widgets(parent, QSpinBox)
|
self.make_widgets(parent, QSpinBox)
|
||||||
self.main_widget.setRange(-100, 100000000)
|
self.main_widget.setRange(-1000000, 100000000)
|
||||||
self.main_widget.setSpecialValueText(_('Undefined'))
|
self.main_widget.setSpecialValueText(_('Undefined'))
|
||||||
self.main_widget.setSingleStep(1)
|
self.main_widget.setSingleStep(1)
|
||||||
|
|
||||||
@ -627,7 +626,7 @@ class BulkFloat(BulkInt):
|
|||||||
|
|
||||||
def setup_ui(self, parent):
|
def setup_ui(self, parent):
|
||||||
self.make_widgets(parent, QDoubleSpinBox)
|
self.make_widgets(parent, QDoubleSpinBox)
|
||||||
self.main_widget.setRange(-100., float(100000000))
|
self.main_widget.setRange(-1000000., float(100000000))
|
||||||
self.main_widget.setDecimals(2)
|
self.main_widget.setDecimals(2)
|
||||||
self.main_widget.setSpecialValueText(_('Undefined'))
|
self.main_widget.setSpecialValueText(_('Undefined'))
|
||||||
self.main_widget.setSingleStep(1)
|
self.main_widget.setSingleStep(1)
|
||||||
|
@ -300,13 +300,13 @@ class CcNumberDelegate(QStyledItemDelegate): # {{{
|
|||||||
col = m.column_map[index.column()]
|
col = m.column_map[index.column()]
|
||||||
if m.custom_columns[col]['datatype'] == 'int':
|
if m.custom_columns[col]['datatype'] == 'int':
|
||||||
editor = QSpinBox(parent)
|
editor = QSpinBox(parent)
|
||||||
editor.setRange(-100, 100000000)
|
editor.setRange(-1000000, 100000000)
|
||||||
editor.setSpecialValueText(_('Undefined'))
|
editor.setSpecialValueText(_('Undefined'))
|
||||||
editor.setSingleStep(1)
|
editor.setSingleStep(1)
|
||||||
else:
|
else:
|
||||||
editor = QDoubleSpinBox(parent)
|
editor = QDoubleSpinBox(parent)
|
||||||
editor.setSpecialValueText(_('Undefined'))
|
editor.setSpecialValueText(_('Undefined'))
|
||||||
editor.setRange(-100., 100000000)
|
editor.setRange(-1000000., 100000000)
|
||||||
editor.setDecimals(2)
|
editor.setDecimals(2)
|
||||||
return editor
|
return editor
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ from calibre.gui2 import error_dialog, question_dialog
|
|||||||
from calibre.gui2.preferences.save_template_ui import Ui_Form
|
from calibre.gui2.preferences.save_template_ui import Ui_Form
|
||||||
from calibre.library.save_to_disk import FORMAT_ARG_DESCS, preprocess_template
|
from calibre.library.save_to_disk import FORMAT_ARG_DESCS, preprocess_template
|
||||||
from calibre.utils.formatter import validation_formatter
|
from calibre.utils.formatter import validation_formatter
|
||||||
|
from calibre.gui2.dialogs.template_dialog import TemplateDialog
|
||||||
|
|
||||||
|
|
||||||
class SaveTemplate(QWidget, Ui_Form):
|
class SaveTemplate(QWidget, Ui_Form):
|
||||||
@ -40,6 +41,14 @@ class SaveTemplate(QWidget, Ui_Form):
|
|||||||
self.opt_template.editTextChanged.connect(self.changed)
|
self.opt_template.editTextChanged.connect(self.changed)
|
||||||
self.opt_template.currentIndexChanged.connect(self.changed)
|
self.opt_template.currentIndexChanged.connect(self.changed)
|
||||||
self.option_name = name
|
self.option_name = name
|
||||||
|
self.open_editor.clicked.connect(self.do_open_editor)
|
||||||
|
|
||||||
|
def do_open_editor(self):
|
||||||
|
t = TemplateDialog(self, self.opt_template.text())
|
||||||
|
t.setWindowTitle(_('Edit template'))
|
||||||
|
if t.exec_():
|
||||||
|
self.opt_template.set_value(t.rule[1])
|
||||||
|
|
||||||
|
|
||||||
def changed(self, *args):
|
def changed(self, *args):
|
||||||
self.changed_signal.emit()
|
self.changed_signal.emit()
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<string>Save &template</string>
|
<string>Save &template</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>By adjusting the template below, you can control what folders the files are saved in and what filenames they are given. You can use the / character to indicate sub-folders. Available metadata variables are described below. If a particular book does not have some metadata, the variable will be replaced by the empty string.</string>
|
<string>By adjusting the template below, you can control what folders the files are saved in and what filenames they are given. You can use the / character to indicate sub-folders. Available metadata variables are described below. If a particular book does not have some metadata, the variable will be replaced by the empty string.</string>
|
||||||
@ -30,18 +30,32 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Available variables:</string>
|
<string>Available variables:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QTextBrowser" name="template_variables"/>
|
<widget class="QTextBrowser" name="template_variables"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="HistoryBox" name="opt_template"/>
|
<widget class="HistoryBox" name="opt_template">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||||
|
<horstretch>10</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="open_editor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Template Editor</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user