1) add tooltips

2) change main heading text depending on the mode
3) add an error if attempting to assign '' to authors or title
This commit is contained in:
Charles Haley 2010-09-20 19:49:03 +01:00
parent ea44e9053f
commit e2f4b969bc
2 changed files with 84 additions and 16 deletions

View File

@ -208,25 +208,43 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
self.book_1_text.setObjectName(name)
self.testgrid.addWidget(w, i+offset, 2, 1, 1)
self.s_r_heading.setText('<p>'+ _(
self.main_heading = _(
'<b>You can destroy your library using this feature.</b> '
'Changes are permanent. There is no undo function. '
' This feature is experimental, and there may be bugs. '
'You are strongly encouraged to back up your library '
'before proceeding.'
) + '<p>' + _(
+ '<p>' +
'Search and replace in text fields using character matching '
'or regular expressions. In character mode, search text '
'found in the specified field is replaced with replace '
'text. In regular expression mode, the search text is an '
'or regular expressions. ')
self.character_heading = _(
'In character mode, the field is searched for the entered '
'search text. The text is replaced by the specified replacement '
'text everywhere it is found in the specified field. After '
'replacement is finished, the text can be changed to '
'upper-case, lower-case, or title-case. If the case-sensitive '
'check box is checked, the search text must match exactly. If '
'it is unchecked, the search text will match both upper- and '
'lower-case letters'
)
self.regexp_heading = _(
'In regular expression mode, the search text is an '
'arbitrary python-compatible regular expression. The '
'replacement text can contain backreferences to parenthesized '
'expressions in the pattern. The search is not anchored, '
'and can match and replace multiple times on the same string. '
'The modification functions (lower-case etc) are applied to the '
'matched text, not to the field as a whole. '
'The destination box specifies the field where the result after '
'matching and replacement is to be assigned. You can replace '
'the text in the field, or prepend or append the matched text. '
'See <a href="http://docs.python.org/library/re.html"> '
'this reference</a> for more information, and in particular '
'the \'sub\' function.'
))
'this reference</a> for more information on python\'s regular '
'expressions, and in particular the \'sub\' function.'
)
self.search_mode.addItems(self.s_r_match_modes)
self.search_mode.setCurrentIndex(dynamic.get('s_r_search_mode', 0))
self.replace_mode.addItems(self.s_r_replace_modes)
@ -298,12 +316,14 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
self.replace_mode.setVisible(False)
self.replace_mode_label.setVisible(False)
self.comma_separated.setVisible(False)
self.s_r_heading.setText('<p>'+self.main_heading + self.character_heading)
else:
self.destination_field.setVisible(True)
self.destination_field_label.setVisible(True)
self.replace_mode.setVisible(True)
self.replace_mode_label.setVisible(True)
self.comma_separated.setVisible(True)
self.s_r_heading.setText('<p>'+self.main_heading + self.regexp_heading)
self.s_r_paint_results(None)
def s_r_set_colors(self):
@ -434,8 +454,20 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
# The standard tags and authors values want to be lists.
# All custom columns are to be strings
val = dfm['is_multiple'].join(val)
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)
continue
else:
val = self.s_r_replace_mode_separator().join(val)
if dest == 'title' and len(val) == 0:
error_dialog(self, _('Search/replace invalid'),
_('Title cannot be set to the empty string. '
'Book title %s not processed')%mi.title,
show=True)
continue
if dfm['is_custom']:
extra = self.db.get_custom_extra(id, label=dfm['label'], index_is_id=True)

View File

@ -351,7 +351,11 @@ Future conversion of these books will use the default settings.</string>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="search_field"/>
<widget class="QComboBox" name="search_field">
<property name="toolTip">
<string>The name of the field that you want to search</string>
</property>
</widget>
</item>
<item row="3" column="2">
<layout class="QHBoxLayout" name="HLayout_3">
@ -361,12 +365,16 @@ Future conversion of these books will use the default settings.</string>
<string>Search mode:</string>
</property>
<property name="buddy">
<cstring>search_field</cstring>
<cstring>search_mode</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="search_mode"/>
<widget class="QComboBox" name="search_mode">
<property name="toolTip">
<string>Choose whether to use basic text matching or advanced regular expression matching</string>
</property>
</widget>
</item>
<item>
<spacer name="HSpacer_2">
@ -394,7 +402,11 @@ Future conversion of these books will use the default settings.</string>
</widget>
</item>
<item row="4" column="1">
<widget class="HistoryLineEdit" name="search_for"/>
<widget class="HistoryLineEdit" name="search_for">
<property name="toolTip">
<string>Enter the what you are looking for, either plain text or a regular expression, depending on the mode</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QCheckBox" name="case_sensitive">
@ -404,6 +416,9 @@ Future conversion of these books will use the default settings.</string>
<property name="checked" >
<bool>true</bool>
</property>
<property name="toolTip">
<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>
</widget>
</item>
<item row="5" column="0">
@ -417,7 +432,11 @@ Future conversion of these books will use the default settings.</string>
</widget>
</item>
<item row="5" column="1">
<widget class="HistoryLineEdit" name="replace_with"/>
<widget class="HistoryLineEdit" name="replace_with">
<property name="toolTip">
<string>The replacement text. The matched search text will be replaced with this string</string>
</property>
</widget>
</item>
<item row="5" column="2">
<layout class="QHBoxLayout" name="verticalLayout">
@ -432,7 +451,12 @@ Future conversion of these books will use the default settings.</string>
</widget>
</item>
<item>
<widget class="QComboBox" name="replace_func"/>
<widget class="QComboBox" name="replace_func">
<property name="toolTip">
<string>Specify how the text is to be processed after matching and replacement. In character mode, the entire
field is processed. In regular expression mode, only the matched text is processed</string>
</property>
</widget>
</item>
<item>
<spacer name="HSpacer_1">
@ -460,7 +484,11 @@ Future conversion of these books will use the default settings.</string>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="destination_field"/>
<widget class="QComboBox" name="destination_field">
<property name="toolTip">
<string>The field that the text will be put into after all replacements. If blank, the source field is used.</string>
</property>
</widget>
</item>
<item row="6" column="2">
<layout class="QHBoxLayout" name="verticalLayout">
@ -475,7 +503,11 @@ Future conversion of these books will use the default settings.</string>
</widget>
</item>
<item>
<widget class="QComboBox" name="replace_mode"/>
<widget class="QComboBox" name="replace_mode">
<property name="toolTip">
<string>Specify how the text should be copied into the destination.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="comma_separated">
@ -485,6 +517,10 @@ Future conversion of these books will use the default settings.</string>
<property name="checked" >
<bool>true</bool>
</property>
<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>
</property>
</widget>
</item>
<item>