mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
907fd3262f
@ -681,6 +681,7 @@ class CreateNewCustomColumn(object):
|
|||||||
DUPLICATE_KEY = 3
|
DUPLICATE_KEY = 3
|
||||||
INVALID_TYPE = 4
|
INVALID_TYPE = 4
|
||||||
INVALID_IS_MULTIPLE = 5
|
INVALID_IS_MULTIPLE = 5
|
||||||
|
INVALID_DISPLAY = 6
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Open a dialog to create a new custom column with given lookup_name,
|
Open a dialog to create a new custom column with given lookup_name,
|
||||||
@ -694,10 +695,46 @@ class CreateNewCustomColumn(object):
|
|||||||
|
|
||||||
The parameter 'gui' is the main calibre gui (calibre.gui2.ui.get_gui())
|
The parameter 'gui' is the main calibre gui (calibre.gui2.ui.get_gui())
|
||||||
|
|
||||||
The method returns a tuple (Result.enum_value, message). If tuple[0] is
|
The 'display' parameter is used to pass item- and type-specific information
|
||||||
Result.COLUMN_ADDED then the message is the lookup name including the '#',
|
for the column. It is a dict. The easiest way to see the current values for
|
||||||
otherwise it is a potentially localized error message. You or the user must
|
'display' for a particular column is to create a column like you want then
|
||||||
restart calibre for the column to be actually added.
|
look for the lookup name in the file metadata_db_prefs_backup.json.
|
||||||
|
|
||||||
|
The permitted key:value pairs for each type are as follows. Note that this
|
||||||
|
list might be incorrect. As said above, the best way to get current values
|
||||||
|
is to create a similar column and look at the values in 'display'.
|
||||||
|
all types:
|
||||||
|
'default_value': a string representation of the default value for the
|
||||||
|
column. Permitted values are type specific
|
||||||
|
'description': a string containing the column's description
|
||||||
|
comments columns:
|
||||||
|
'heading_position': a string specifying where a comment heading goes: hide, above, side
|
||||||
|
'interpret_as': a string specifying the comment's purpose:
|
||||||
|
html, short-text, long-text, markdown
|
||||||
|
composite columns:
|
||||||
|
'composite_template': the template for a composite column
|
||||||
|
'composite_sort': a string specifying how the composite is to be sorted
|
||||||
|
'make_category': True or False -- whether the column is shown in the tag browser
|
||||||
|
'contains_html': True or False -- whether the column is interpreted as HTML
|
||||||
|
'use_decorations': True or False -- should check marks be displayed
|
||||||
|
datetime columns:
|
||||||
|
'date_format': a string specifying the display format
|
||||||
|
enumerated columns
|
||||||
|
'enum_values': a string containing comma-separated valid values for an enumeration
|
||||||
|
'enum_colors': a string containing comma-separated colors for an enumeration
|
||||||
|
'use_decorations': True or False -- should check marks be displayed
|
||||||
|
float and int columns:
|
||||||
|
'number_format': the format to apply for numeric columns
|
||||||
|
rating columns:
|
||||||
|
'allow_half_stars': True or False -- are half-stars allowed
|
||||||
|
text columns:
|
||||||
|
'is_names': True or False -- whether the items are comma or ampersand separated
|
||||||
|
'use_decorations': True or False -- should check marks be displayed
|
||||||
|
|
||||||
|
This method returns a tuple (Result.enum_value, message). If tuple[0] is
|
||||||
|
Result.COLUMN_ADDED then the message is the lookup name including the '#'.
|
||||||
|
You or the user must restart calibre for the column to be actually added.
|
||||||
|
Otherwise it is a potentially localized error message.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
from calibre.gui2.preferences.create_custom_column import CreateNewCustomColumn
|
from calibre.gui2.preferences.create_custom_column import CreateNewCustomColumn
|
||||||
@ -706,7 +743,7 @@ class CreateNewCustomColumn(object):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
def create_new_custom_column(self, gui, lookup_name, column_heading,
|
def create_new_custom_column(self, gui, lookup_name, column_heading,
|
||||||
datatype, is_multiple, freeze_key=True):
|
datatype, is_multiple, display={}, freeze_key=True):
|
||||||
db = gui.library_view.model().db
|
db = gui.library_view.model().db
|
||||||
self.custcols = copy.deepcopy(db.field_metadata.custom_field_metadata())
|
self.custcols = copy.deepcopy(db.field_metadata.custom_field_metadata())
|
||||||
if not lookup_name.startswith('#'):
|
if not lookup_name.startswith('#'):
|
||||||
@ -719,6 +756,10 @@ class CreateNewCustomColumn(object):
|
|||||||
if is_multiple and '*' + datatype not in CreateCustomColumn.column_types_map:
|
if is_multiple and '*' + datatype not in CreateCustomColumn.column_types_map:
|
||||||
return(self.Result.INVALID_IS_MULTIPLE,
|
return(self.Result.INVALID_IS_MULTIPLE,
|
||||||
_("You cannot specify is_multiple for the datatype %s") % datatype)
|
_("You cannot specify is_multiple for the datatype %s") % datatype)
|
||||||
|
if not isinstance(display, dict):
|
||||||
|
return(self.Result.INVALID_DISPLAY,
|
||||||
|
_("The display parameter must a python dict"))
|
||||||
|
|
||||||
if not column_heading:
|
if not column_heading:
|
||||||
column_heading = lookup_name
|
column_heading = lookup_name
|
||||||
self.key = lookup_name
|
self.key = lookup_name
|
||||||
@ -726,7 +767,7 @@ class CreateNewCustomColumn(object):
|
|||||||
'label': lookup_name,
|
'label': lookup_name,
|
||||||
'name': column_heading,
|
'name': column_heading,
|
||||||
'datatype': datatype,
|
'datatype': datatype,
|
||||||
'display': {},
|
'display': display,
|
||||||
'normalized': None,
|
'normalized': None,
|
||||||
'colnum': None,
|
'colnum': None,
|
||||||
'is_multiple': is_multiple,
|
'is_multiple': is_multiple,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user