mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
...
This commit is contained in:
commit
a243e66f33
@ -112,7 +112,7 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
getattr(self, 'enum_'+x).setVisible(col_type == 'enumeration')
|
getattr(self, 'enum_'+x).setVisible(col_type == 'enumeration')
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
col = unicode(self.column_name_box.text())
|
col = unicode(self.column_name_box.text()).strip()
|
||||||
if not col:
|
if not col:
|
||||||
return self.simple_error('', _('No lookup name was provided'))
|
return self.simple_error('', _('No lookup name was provided'))
|
||||||
if re.match('^\w*$', col) is None or not col[0].isalpha() or col.lower() != col:
|
if re.match('^\w*$', col) is None or not col[0].isalpha() or col.lower() != col:
|
||||||
@ -121,7 +121,7 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
if col.endswith('_index'):
|
if col.endswith('_index'):
|
||||||
return self.simple_error('', _('Lookup names cannot end with _index, '
|
return self.simple_error('', _('Lookup names cannot end with _index, '
|
||||||
'because these names are reserved for the index of a series column.'))
|
'because these names are reserved for the index of a series column.'))
|
||||||
col_heading = unicode(self.column_heading_box.text())
|
col_heading = unicode(self.column_heading_box.text()).strip()
|
||||||
col_type = self.column_types[self.column_type_box.currentIndex()]['datatype']
|
col_type = self.column_types[self.column_type_box.currentIndex()]['datatype']
|
||||||
if col_type == '*text':
|
if col_type == '*text':
|
||||||
col_type='text'
|
col_type='text'
|
||||||
@ -153,22 +153,21 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
display_dict = {}
|
display_dict = {}
|
||||||
|
|
||||||
if col_type == 'datetime':
|
if col_type == 'datetime':
|
||||||
if self.date_format_box.text():
|
if self.date_format_box.text().strip():
|
||||||
display_dict = {'date_format':unicode(self.date_format_box.text())}
|
display_dict = {'date_format':unicode(self.date_format_box.text()).strip()}
|
||||||
else:
|
else:
|
||||||
display_dict = {'date_format': None}
|
display_dict = {'date_format': None}
|
||||||
elif col_type == 'composite':
|
elif col_type == 'composite':
|
||||||
if not self.composite_box.text():
|
if not self.composite_box.text().strip():
|
||||||
return self.simple_error('', _('You must enter a template for'
|
return self.simple_error('', _('You must enter a template for'
|
||||||
' composite columns'))
|
' composite columns'))
|
||||||
display_dict = {'composite_template':unicode(self.composite_box.text())}
|
display_dict = {'composite_template':unicode(self.composite_box.text()).strip()}
|
||||||
elif col_type == 'enumeration':
|
elif col_type == 'enumeration':
|
||||||
if not self.enum_box.text():
|
if not self.enum_box.text():
|
||||||
return self.simple_error('', _('You must enter at least one'
|
return self.simple_error('', _('You must enter at least one'
|
||||||
' value for enumeration columns'))
|
' value for enumeration columns'))
|
||||||
l = [v.strip() for v in unicode(self.enum_box.text()).split(',')]
|
l = [v.strip() for v in unicode(self.enum_box.text()).split(',')]
|
||||||
for v in l:
|
if '' in l:
|
||||||
if not v:
|
|
||||||
return self.simple_error('', _('You cannot provide the empty '
|
return self.simple_error('', _('You cannot provide the empty '
|
||||||
'value, as it is included by default'))
|
'value, as it is included by default'))
|
||||||
for i in range(0, len(l)-1):
|
for i in range(0, len(l)-1):
|
||||||
|
@ -7,6 +7,8 @@ __docformat__ = 'restructuredtext en'
|
|||||||
Browsing book collection by tags.
|
Browsing book collection by tags.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import traceback
|
||||||
|
|
||||||
from itertools import izip
|
from itertools import izip
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
@ -755,13 +757,15 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
try:
|
try:
|
||||||
tb_cats.add_user_category(label=cat_name, name=user_cat)
|
tb_cats.add_user_category(label=cat_name, name=user_cat)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
import traceback
|
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
for cat in sorted(self.db.prefs.get('grouped_search_terms', {}),
|
for cat in sorted(self.db.prefs.get('grouped_search_terms', {}).keys(),
|
||||||
key=sort_key):
|
key=sort_key):
|
||||||
if (u'@' + cat) in data:
|
if (u'@' + cat) in data:
|
||||||
|
try:
|
||||||
tb_cats.add_user_category(label=u'@' + cat, name=cat)
|
tb_cats.add_user_category(label=u'@' + cat, name=cat)
|
||||||
|
except ValueError:
|
||||||
|
traceback.print_exc()
|
||||||
self.db.data.change_search_locations(self.db.field_metadata.get_search_terms())
|
self.db.data.change_search_locations(self.db.field_metadata.get_search_terms())
|
||||||
|
|
||||||
if len(saved_searches().names()):
|
if len(saved_searches().names()):
|
||||||
|
@ -353,12 +353,23 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
# Reconstruct the user categories, putting them into field_metadata
|
# Reconstruct the user categories, putting them into field_metadata
|
||||||
# Assumption is that someone else will fix them if they change.
|
# Assumption is that someone else will fix them if they change.
|
||||||
self.field_metadata.remove_dynamic_categories()
|
self.field_metadata.remove_dynamic_categories()
|
||||||
tb_cats = self.field_metadata
|
|
||||||
for user_cat in sorted(self.prefs.get('user_categories', {}).keys(), key=sort_key):
|
for user_cat in sorted(self.prefs.get('user_categories', {}).keys(), key=sort_key):
|
||||||
cat_name = '@' + user_cat # add the '@' to avoid name collision
|
cat_name = '@' + user_cat # add the '@' to avoid name collision
|
||||||
tb_cats.add_user_category(label=cat_name, name=user_cat)
|
self.field_metadata.add_user_category(label=cat_name, name=user_cat)
|
||||||
|
|
||||||
|
# add grouped search term user categories
|
||||||
|
muc = self.prefs.get('grouped_search_make_user_categories', [])
|
||||||
|
for cat in sorted(self.prefs.get('grouped_search_terms', {}).keys(), key=sort_key):
|
||||||
|
if cat in muc:
|
||||||
|
# There is a chance that these can be duplicates of an existing
|
||||||
|
# user category. Print the exception and continue.
|
||||||
|
try:
|
||||||
|
self.field_metadata.add_user_category(label=u'@' + cat, name=cat)
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
if len(saved_searches().names()):
|
if len(saved_searches().names()):
|
||||||
tb_cats.add_search_category(label='search', name=_('Searches'))
|
self.field_metadata.add_search_category(label='search', name=_('Searches'))
|
||||||
|
|
||||||
self.field_metadata.add_grouped_search_terms(
|
self.field_metadata.add_grouped_search_terms(
|
||||||
self.prefs.get('grouped_search_terms', {}))
|
self.prefs.get('grouped_search_terms', {}))
|
||||||
|
@ -603,7 +603,9 @@ class BrowseServer(object):
|
|||||||
val = ''
|
val = ''
|
||||||
if add_category_links:
|
if add_category_links:
|
||||||
added_key = False
|
added_key = False
|
||||||
if val and key in ('authors', 'publisher', 'series', 'tags'):
|
fm = mi.metadata_for_field(key)
|
||||||
|
if val and fm and fm['is_category'] and \
|
||||||
|
key != 'formats' and fm['datatype'] not in ['rating']:
|
||||||
categories = mi.get(key)
|
categories = mi.get(key)
|
||||||
if isinstance(categories, basestring):
|
if isinstance(categories, basestring):
|
||||||
categories = [categories]
|
categories = [categories]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user