mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Fix sorting problem in manage categories. Fix poor performance problem when dropping multiple books onto a user category. Remove 'empty field' error dialogs in bulk search/replace, instead setting the fields to their default value.
This commit is contained in:
commit
2f7549e6c5
@ -749,15 +749,9 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
|||||||
val = self.s_r_do_regexp(mi)
|
val = self.s_r_do_regexp(mi)
|
||||||
val = self.s_r_do_destination(mi, val)
|
val = self.s_r_do_destination(mi, val)
|
||||||
if dfm['is_multiple']:
|
if dfm['is_multiple']:
|
||||||
if dest == 'authors' and len(val) == 0:
|
|
||||||
error_dialog(self, _('Search/replace invalid'),
|
|
||||||
_('Authors cannot be set to the empty string. '
|
|
||||||
'Book title %s not processed')%mi.title,
|
|
||||||
show=True)
|
|
||||||
return
|
|
||||||
# convert the colon-separated pair strings back into a dict, which
|
|
||||||
# is what set_identifiers wants
|
|
||||||
if dfm['is_csp']:
|
if dfm['is_csp']:
|
||||||
|
# convert the colon-separated pair strings back into a dict,
|
||||||
|
# which is what set_identifiers wants
|
||||||
dst_id_type = unicode(self.s_r_dst_ident.text())
|
dst_id_type = unicode(self.s_r_dst_ident.text())
|
||||||
if dst_id_type:
|
if dst_id_type:
|
||||||
v = ''.join(val)
|
v = ''.join(val)
|
||||||
@ -769,11 +763,7 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
|||||||
else:
|
else:
|
||||||
val = self.s_r_replace_mode_separator().join(val)
|
val = self.s_r_replace_mode_separator().join(val)
|
||||||
if dest == 'title' and len(val) == 0:
|
if dest == 'title' and len(val) == 0:
|
||||||
error_dialog(self, _('Search/replace invalid'),
|
val = _('Unknown')
|
||||||
_('Title cannot be set to the empty string. '
|
|
||||||
'Book title %s not processed')%mi.title,
|
|
||||||
show=True)
|
|
||||||
return
|
|
||||||
|
|
||||||
if dfm['is_custom']:
|
if dfm['is_custom']:
|
||||||
extra = self.db.get_custom_extra(id, label=dfm['label'], index_is_id=True)
|
extra = self.db.get_custom_extra(id, label=dfm['label'], index_is_id=True)
|
||||||
|
@ -260,6 +260,7 @@ class TagCategories(QDialog, Ui_TagCategories):
|
|||||||
self.applied_items = [cat[2] for cat in self.categories.get(self.current_cat_name, [])]
|
self.applied_items = [cat[2] for cat in self.categories.get(self.current_cat_name, [])]
|
||||||
else:
|
else:
|
||||||
self.applied_items = []
|
self.applied_items = []
|
||||||
|
self.applied_items.sort(key=lambda x:sort_key(self.all_items[x].name))
|
||||||
self.display_filtered_categories(None)
|
self.display_filtered_categories(None)
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
|
@ -685,44 +685,37 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
|
|
||||||
def handle_user_category_drop(self, on_node, ids, column):
|
def handle_user_category_drop(self, on_node, ids, column):
|
||||||
categories = self.db.prefs.get('user_categories', {})
|
categories = self.db.prefs.get('user_categories', {})
|
||||||
category = categories.get(on_node.category_key[1:], None)
|
cat_contents = categories.get(on_node.category_key[1:], None)
|
||||||
if category is None:
|
if cat_contents is None:
|
||||||
return
|
return
|
||||||
|
cat_contents = set([(v, c) for v,c,ign in cat_contents])
|
||||||
|
|
||||||
fm_src = self.db.metadata_for_field(column)
|
fm_src = self.db.metadata_for_field(column)
|
||||||
|
label = fm_src['label']
|
||||||
|
|
||||||
for id in ids:
|
for id in ids:
|
||||||
label = fm_src['label']
|
|
||||||
if not fm_src['is_custom']:
|
if not fm_src['is_custom']:
|
||||||
if label == 'authors':
|
if label == 'authors':
|
||||||
items = self.db.get_authors_with_ids()
|
|
||||||
items = [(i[0], i[1].replace('|', ',')) for i in items]
|
|
||||||
value = self.db.authors(id, index_is_id=True)
|
value = self.db.authors(id, index_is_id=True)
|
||||||
value = [v.replace('|', ',') for v in value.split(',')]
|
value = [v.replace('|', ',') for v in value.split(',')]
|
||||||
elif label == 'publisher':
|
elif label == 'publisher':
|
||||||
items = self.db.get_publishers_with_ids()
|
|
||||||
value = self.db.publisher(id, index_is_id=True)
|
value = self.db.publisher(id, index_is_id=True)
|
||||||
elif label == 'series':
|
elif label == 'series':
|
||||||
items = self.db.get_series_with_ids()
|
|
||||||
value = self.db.series(id, index_is_id=True)
|
value = self.db.series(id, index_is_id=True)
|
||||||
else:
|
else:
|
||||||
items = self.db.get_custom_items_with_ids(label=label)
|
|
||||||
if fm_src['datatype'] != 'composite':
|
if fm_src['datatype'] != 'composite':
|
||||||
value = self.db.get_custom(id, label=label, index_is_id=True)
|
value = self.db.get_custom(id, label=label, index_is_id=True)
|
||||||
else:
|
else:
|
||||||
value = self.db.get_property(id, loc=fm_src['rec_index'],
|
value = self.db.get_property(id, loc=fm_src['rec_index'],
|
||||||
index_is_id=True)
|
index_is_id=True)
|
||||||
if value is None:
|
if value:
|
||||||
return
|
if not isinstance(value, list):
|
||||||
if not isinstance(value, list):
|
value = [value]
|
||||||
value = [value]
|
cat_contents |= set([(v, column) for v in value])
|
||||||
for val in value:
|
|
||||||
for (v, c, id) in category:
|
categories[on_node.category_key[1:]] = [[v, c, 0] for v,c in cat_contents]
|
||||||
if v == val and c == column:
|
self.db.prefs.set('user_categories', categories)
|
||||||
break
|
self.refresh_required.emit()
|
||||||
else:
|
|
||||||
category.append([val, column, 0])
|
|
||||||
categories[on_node.category_key[1:]] = category
|
|
||||||
self.db.prefs.set('user_categories', categories)
|
|
||||||
self.refresh_required.emit()
|
|
||||||
|
|
||||||
def handle_drop(self, on_node, ids):
|
def handle_drop(self, on_node, ids):
|
||||||
#print 'Dropped ids:', ids, on_node.tag
|
#print 'Dropped ids:', ids, on_node.tag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user