diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index dc691c4ffe..bde5cae128 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -414,6 +414,9 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): self.s_r_template.completer().setCaseSensitivity(Qt.CaseSensitive) self.s_r_search_mode_changed(self.search_mode.currentIndex()) + self.multiple_separator.setFixedWidth(30) + self.multiple_separator.setText(' ::: ') + self.multiple_separator.textChanged.connect(self.s_r_separator_changed) def s_r_get_field(self, mi, field): if field: @@ -451,19 +454,22 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): mi = self.db.get_metadata(self.ids[i], index_is_id=True) src = unicode(self.search_field.currentText()) t = self.s_r_get_field(mi, src) - w.setText(''.join(t[0:1])) + w.setText(unicode(self.multiple_separator.text()).join(t)) if self.search_mode.currentIndex() == 0: self.destination_field.setCurrentIndex(idx) else: + self.s_r_destination_field_changed(self.destination_field.currentText()) self.s_r_paint_results(None) def s_r_destination_field_changed(self, txt): txt = unicode(txt) + if not txt: + txt = unicode(self.search_field.currentText()) self.comma_separated.setEnabled(True) - if txt: - fm = self.db.metadata_for_field(txt) - if fm['is_multiple']: + if txt and txt in self.writable_fields: + self.destination_field_fm = self.db.metadata_for_field(txt) + if self.destination_field_fm['is_multiple']: self.comma_separated.setEnabled(False) self.comma_separated.setChecked(True) self.s_r_paint_results(None) @@ -493,6 +499,9 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): self.s_r_heading.setText('

'+self.main_heading + self.regexp_heading) self.s_r_paint_results(None) + def s_r_separator_changed(self, txt): + self.s_r_search_field_changed(self.search_field.currentIndex()) + def s_r_set_colors(self): if self.s_r_error is not None: col = 'rgb(255, 0, 0, 20%)' @@ -592,8 +601,12 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): wr = getattr(self, 'book_%d_result'%(i+1)) try: result = self.s_r_do_regexp(mi) - t = self.s_r_do_destination(mi, result[0:1]) - t = self.s_r_replace_mode_separator().join(t) + t = self.s_r_do_destination(mi, result) + if len(result) > 1 and self.destination_field_fm is not None and \ + self.destination_field_fm['is_multiple']: + t = unicode(self.multiple_separator.text()).join(t) + else: + t = self.s_r_replace_mode_separator().join(t) wr.setText(t) except Exception as e: self.s_r_error = e diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index dca7abc82c..d945909f96 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -478,7 +478,7 @@ Future conversion of these books will use the default settings. - Search mode: + Search &mode: search_mode @@ -559,7 +559,7 @@ Future conversion of these books will use the default settings. Check this box if the search string must match exactly upper and lower case. Uncheck it if case is to be ignored - Case sensitive + Cas&e sensitive true @@ -588,7 +588,7 @@ Future conversion of these books will use the default settings. - Apply function after replace: + &Apply function after replace: replace_func @@ -641,7 +641,7 @@ If blank, the source field is used if the field is modifiable - Mode: + M&ode: replace_mode @@ -658,11 +658,11 @@ If blank, the source field is used if the field is modifiable - If the replace mode is prepend or append, then this box indicates whether a comma or -nothing should be put between the original text and the inserted text + Specifies whether a comma should be put between values when copying from a +multiple-valued field to a single-valued field - use comma + &Use comma true @@ -687,7 +687,7 @@ nothing should be put between the original text and the inserted text - Test &text + Test text test_text @@ -695,14 +695,48 @@ nothing should be put between the original text and the inserted text - - - Test re&sult - - - test_result - - + + + + + Test result + + + test_result + + + + + + + Qt::Horizontal + + + + 20 + 0 + + + + + + + + Multi&ple separator: + + + multiple_separator + + + + + + + Used when displaying test results to separate values in multiple-valued fields + + + + @@ -823,7 +857,7 @@ nothing should be put between the original text and the inserted text destination_field replace_mode comma_separated - scrollArea11 + multiple_separator test_text test_result