mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
commit
76c53ca61f
@ -6,67 +6,18 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
|
||||
from calibre.ebooks.conversion.config import load_defaults
|
||||
from calibre.gui2 import gprefs
|
||||
|
||||
from catalog_epub_mobi_ui import Ui_Form
|
||||
from PyQt4.Qt import QWidget, QLineEdit
|
||||
from PyQt4.Qt import QCheckBox, QComboBox, QDoubleSpinBox, QLineEdit, \
|
||||
QRadioButton, QWidget
|
||||
|
||||
class PluginWidget(QWidget,Ui_Form):
|
||||
|
||||
TITLE = _('E-book options')
|
||||
HELP = _('Options specific to')+' EPUB/MOBI '+_('output')
|
||||
|
||||
CheckBoxControls = [
|
||||
'generate_titles',
|
||||
'generate_series',
|
||||
'generate_genres',
|
||||
'generate_recently_added',
|
||||
'generate_descriptions',
|
||||
'include_hr'
|
||||
]
|
||||
ComboBoxControls = [
|
||||
'read_source_field',
|
||||
'exclude_source_field',
|
||||
'header_note_source_field',
|
||||
'merge_source_field'
|
||||
]
|
||||
LineEditControls = [
|
||||
'exclude_genre',
|
||||
'exclude_pattern',
|
||||
'exclude_tags',
|
||||
'read_pattern',
|
||||
'wishlist_tag'
|
||||
]
|
||||
RadioButtonControls = [
|
||||
'merge_before',
|
||||
'merge_after'
|
||||
]
|
||||
SpinBoxControls = [
|
||||
'thumb_width'
|
||||
]
|
||||
|
||||
OPTION_FIELDS = zip(CheckBoxControls,
|
||||
[True for i in CheckBoxControls],
|
||||
['check_box' for i in CheckBoxControls])
|
||||
OPTION_FIELDS += zip(ComboBoxControls,
|
||||
[None for i in ComboBoxControls],
|
||||
['combo_box' for i in ComboBoxControls])
|
||||
OPTION_FIELDS += zip(RadioButtonControls,
|
||||
[None for i in RadioButtonControls],
|
||||
['radio_button' for i in RadioButtonControls])
|
||||
|
||||
# LineEditControls
|
||||
OPTION_FIELDS += zip(['exclude_genre'],['\[.+\]'],['line_edit'])
|
||||
OPTION_FIELDS += zip(['exclude_pattern'],[None],['line_edit'])
|
||||
OPTION_FIELDS += zip(['exclude_tags'],['~,'+_('Catalog')],['line_edit'])
|
||||
OPTION_FIELDS += zip(['read_pattern'],['+'],['line_edit'])
|
||||
OPTION_FIELDS += zip(['wishlist_tag'],['Wishlist'],['line_edit'])
|
||||
|
||||
# SpinBoxControls
|
||||
OPTION_FIELDS += zip(['thumb_width'],[1.00],['spin_box'])
|
||||
|
||||
# Output synced to the connected device?
|
||||
sync_enabled = True
|
||||
|
||||
@ -76,8 +27,69 @@ class PluginWidget(QWidget,Ui_Form):
|
||||
def __init__(self, parent=None):
|
||||
QWidget.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self._initControlArrays()
|
||||
|
||||
def _initControlArrays(self):
|
||||
|
||||
CheckBoxControls = []
|
||||
ComboBoxControls = []
|
||||
DoubleSpinBoxControls = []
|
||||
LineEditControls = []
|
||||
RadioButtonControls = []
|
||||
|
||||
for item in self.__dict__:
|
||||
if type(self.__dict__[item]) is QCheckBox:
|
||||
CheckBoxControls.append(str(self.__dict__[item].objectName()))
|
||||
elif type(self.__dict__[item]) is QComboBox:
|
||||
ComboBoxControls.append(str(self.__dict__[item].objectName()))
|
||||
elif type(self.__dict__[item]) is QDoubleSpinBox:
|
||||
DoubleSpinBoxControls.append(str(self.__dict__[item].objectName()))
|
||||
elif type(self.__dict__[item]) is QLineEdit:
|
||||
LineEditControls.append(str(self.__dict__[item].objectName()))
|
||||
elif type(self.__dict__[item]) is QRadioButton:
|
||||
RadioButtonControls.append(str(self.__dict__[item].objectName()))
|
||||
|
||||
option_fields = zip(CheckBoxControls,
|
||||
[True for i in CheckBoxControls],
|
||||
['check_box' for i in CheckBoxControls])
|
||||
option_fields += zip(ComboBoxControls,
|
||||
[None for i in ComboBoxControls],
|
||||
['combo_box' for i in ComboBoxControls])
|
||||
option_fields += zip(RadioButtonControls,
|
||||
[None for i in RadioButtonControls],
|
||||
['radio_button' for i in RadioButtonControls])
|
||||
|
||||
# LineEditControls
|
||||
option_fields += zip(['exclude_genre'],['\[.+\]'],['line_edit'])
|
||||
option_fields += zip(['exclude_pattern'],[None],['line_edit'])
|
||||
option_fields += zip(['exclude_tags'],['~,'+_('Catalog')],['line_edit'])
|
||||
option_fields += zip(['read_pattern'],['+'],['line_edit'])
|
||||
option_fields += zip(['wishlist_tag'],['Wishlist'],['line_edit'])
|
||||
|
||||
# SpinBoxControls
|
||||
option_fields += zip(['thumb_width'],[1.00],['spin_box'])
|
||||
|
||||
self.OPTION_FIELDS = option_fields
|
||||
|
||||
def initialize(self, name, db):
|
||||
'''
|
||||
|
||||
CheckBoxControls (c_type: check_box):
|
||||
['generate_titles','generate_series','generate_genres',
|
||||
'generate_recently_added','generate_descriptions','include_hr']
|
||||
ComboBoxControls (c_type: combo_box):
|
||||
['read_source_field','exclude_source_field','header_note_source_field',
|
||||
'merge_source_field']
|
||||
LineEditControls (c_type: line_edit):
|
||||
['exclude_genre','exclude_pattern','exclude_tags','read_pattern',
|
||||
'wishlist_tag']
|
||||
RadioButtonControls (c_type: radio_button):
|
||||
['merge_before','merge_after']
|
||||
SpinBoxControls (c_type: spin_box):
|
||||
['thumb_width']
|
||||
|
||||
'''
|
||||
|
||||
self.name = name
|
||||
self.db = db
|
||||
self.populateComboBoxes()
|
||||
@ -135,7 +147,7 @@ class PluginWidget(QWidget,Ui_Form):
|
||||
def options(self):
|
||||
# Save/return the current options
|
||||
# exclude_genre stores literally
|
||||
# generate_titles, generate_recently_added, numbers_as_text stores as True/False
|
||||
# generate_titles, generate_recently_added store as True/False
|
||||
# others store as lists
|
||||
|
||||
opts_dict = {}
|
||||
|
@ -1536,18 +1536,6 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
notes = ' · '.join(notes)
|
||||
elif field_md['datatype'] == 'datetime':
|
||||
notes = format_date(notes,'dd MMM yyyy')
|
||||
elif field_md['datatype'] == 'composite':
|
||||
m = re.match(r'\[(.+)\]$', notes)
|
||||
if m is not None:
|
||||
# Sniff for special pseudo-list string "[<item, item>]"
|
||||
bracketed_content = m.group(1)
|
||||
if ',' in bracketed_content:
|
||||
# Recast the comma-separated items as a list
|
||||
items = bracketed_content.split(',')
|
||||
items = [i.strip() for i in items]
|
||||
notes = ' · '.join(items)
|
||||
else:
|
||||
notes = bracketed_content
|
||||
this_title['notes'] = {'source':field_md['name'],
|
||||
'content':notes}
|
||||
|
||||
@ -4381,6 +4369,7 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
formats.append(format.rpartition('.')[2].upper())
|
||||
formats = ' · '.join(formats)
|
||||
|
||||
# Date of publication
|
||||
pubdate = book['date']
|
||||
pubmonth, pubyear = pubdate.split(' ')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user