Fix #1025628 (Prepopulate the "Name" field when saving changes to a named "search/replace" on "Edit Meta information" window)

This commit is contained in:
Kovid Goyal 2012-07-17 20:16:02 +05:30
commit d4b059217a
2 changed files with 16 additions and 8 deletions

View File

@ -527,7 +527,8 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
self.queries = JSONConfig("search_replace_queries")
self.query_field.addItem("")
self.query_field.addItems(sorted([q for q in self.queries], key=sort_key))
self.query_field_values = sorted([q for q in self.queries], key=sort_key)
self.query_field.addItems(self.query_field_values)
self.query_field.currentIndexChanged[str].connect(self.s_r_query_change)
self.query_field.setCurrentIndex(0)
self.search_field.setCurrentIndex(0)
@ -1030,11 +1031,16 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
self.queries.commit()
def s_r_save_query(self, *args):
name, ok = QInputDialog.getText(self, _('Save search/replace'),
_('Search/replace name:'))
if not ok:
return
dex = self.query_field_values.index(self.saved_search_name)
name = ''
while not name:
name, ok = QInputDialog.getItem(self, _('Save search/replace'),
_('Search/replace name:'), self.query_field_values, dex, True)
if not ok:
return
if not name:
error_dialog(self, _("Save search/replace"),
_("You must provide a name."), show=True)
new = True
name = unicode(name)
if name in self.queries.keys():
@ -1069,7 +1075,8 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
self.query_field.blockSignals(True)
self.query_field.clear()
self.query_field.addItem('')
self.query_field.addItems(sorted([q for q in self.queries], key=sort_key))
self.query_field_values = sorted([q for q in self.queries], key=sort_key)
self.query_field.addItems(self.query_field_values)
self.query_field.blockSignals(False)
self.query_field.setCurrentIndex(self.query_field.findText(name))
@ -1081,6 +1088,7 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
if item is None:
self.s_r_reset_query_fields()
return
self.saved_search_name = item_name
def set_text(attr, key):
try:

View File

@ -667,7 +667,7 @@ Future conversion of these books will use the default settings.</string>
<string>Load searc&amp;h/replace:</string>
</property>
<property name="buddy">
<cstring>search_field</cstring>
<cstring>query_field</cstring>
</property>
</widget>
</item>