mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Enhancement #8030: View "next testexample" in Multiple Value Metadata Fields
This commit is contained in:
parent
daeff6833c
commit
779922d1f3
@ -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('<p>'+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
|
||||
|
@ -478,7 +478,7 @@ Future conversion of these books will use the default settings.</string>
|
||||
<item>
|
||||
<widget class="QLabel" name="xlabel_24">
|
||||
<property name="text">
|
||||
<string>Search mode:</string>
|
||||
<string>Search &mode:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>search_mode</cstring>
|
||||
@ -559,7 +559,7 @@ Future conversion of these books will use the default settings.</string>
|
||||
<string>Check this box if the search string must match exactly upper and lower case. Uncheck it if case is to be ignored</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Case sensitive</string>
|
||||
<string>Cas&e sensitive</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
@ -588,7 +588,7 @@ Future conversion of these books will use the default settings.</string>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_41">
|
||||
<property name="text">
|
||||
<string>Apply function after replace:</string>
|
||||
<string>&Apply function after replace:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>replace_func</cstring>
|
||||
@ -641,7 +641,7 @@ If blank, the source field is used if the field is modifiable</string>
|
||||
<item>
|
||||
<widget class="QLabel" name="replace_mode_label">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
<string>M&ode:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>replace_mode</cstring>
|
||||
@ -658,11 +658,11 @@ If blank, the source field is used if the field is modifiable</string>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="comma_separated">
|
||||
<property name="toolTip">
|
||||
<string>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</string>
|
||||
<string>Specifies whether a comma should be put between values when copying from a
|
||||
multiple-valued field to a single-valued field</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>use comma</string>
|
||||
<string>&Use comma</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
@ -687,7 +687,7 @@ nothing should be put between the original text and the inserted text</string>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLabel" name="xlabel_3">
|
||||
<property name="text">
|
||||
<string>Test &text</string>
|
||||
<string>Test text</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>test_text</cstring>
|
||||
@ -695,14 +695,48 @@ nothing should be put between the original text and the inserted text</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="2">
|
||||
<widget class="QLabel" name="label_51">
|
||||
<property name="text">
|
||||
<string>Test re&sult</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>test_result</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_21">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_51">
|
||||
<property name="text">
|
||||
<string>Test result</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>test_result</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="HSpacer_347">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="xlabel_41">
|
||||
<property name="text">
|
||||
<string>Multi&ple separator:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>multiple_separator</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="multiple_separator">
|
||||
<property name="toolTip">
|
||||
<string>Used when displaying test results to separate values in multiple-valued fields</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="4">
|
||||
<widget class="QScrollArea" name="scrollArea11">
|
||||
@ -823,7 +857,7 @@ nothing should be put between the original text and the inserted text</string>
|
||||
<tabstop>destination_field</tabstop>
|
||||
<tabstop>replace_mode</tabstop>
|
||||
<tabstop>comma_separated</tabstop>
|
||||
<tabstop>scrollArea11</tabstop>
|
||||
<tabstop>multiple_separator</tabstop>
|
||||
<tabstop>test_text</tabstop>
|
||||
<tabstop>test_result</tabstop>
|
||||
</tabstops>
|
||||
|
Loading…
x
Reference in New Issue
Block a user