This commit is contained in:
Kovid Goyal 2011-03-11 11:37:53 -07:00
commit ebd45c6393
2 changed files with 49 additions and 23 deletions

View File

@ -1013,11 +1013,13 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
query['search_field'] = unicode(self.search_field.currentText()) query['search_field'] = unicode(self.search_field.currentText())
query['search_mode'] = unicode(self.search_mode.currentText()) query['search_mode'] = unicode(self.search_mode.currentText())
query['s_r_template'] = unicode(self.s_r_template.text()) query['s_r_template'] = unicode(self.s_r_template.text())
query['s_r_src_ident'] = unicode(self.s_r_src_ident.currentText())
query['search_for'] = unicode(self.search_for.text()) query['search_for'] = unicode(self.search_for.text())
query['case_sensitive'] = self.case_sensitive.isChecked() query['case_sensitive'] = self.case_sensitive.isChecked()
query['replace_with'] = unicode(self.replace_with.text()) query['replace_with'] = unicode(self.replace_with.text())
query['replace_func'] = unicode(self.replace_func.currentText()) query['replace_func'] = unicode(self.replace_func.currentText())
query['destination_field'] = unicode(self.destination_field.currentText()) query['destination_field'] = unicode(self.destination_field.currentText())
query['s_r_dst_ident'] = unicode(self.s_r_dst_ident.text())
query['replace_mode'] = unicode(self.replace_mode.currentText()) query['replace_mode'] = unicode(self.replace_mode.currentText())
query['comma_separated'] = self.comma_separated.isChecked() query['comma_separated'] = self.comma_separated.isChecked()
query['results_count'] = self.results_count.value() query['results_count'] = self.results_count.value()
@ -1044,37 +1046,61 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
self.s_r_reset_query_fields() self.s_r_reset_query_fields()
return return
def set_index(attr, txt): def set_text(attr, key):
try: try:
attr.setCurrentIndex(attr.findText(txt)) attr.setText(item[key])
except:
pass
def set_checked(attr, key):
try:
attr.setChecked(item[key])
except:
attr.setChecked(False)
def set_value(attr, key):
try:
attr.setValue(int(item[key]))
except:
attr.setValue(0)
def set_index(attr, key):
try:
attr.setCurrentIndex(attr.findText(item[key]))
except: except:
attr.setCurrentIndex(0) attr.setCurrentIndex(0)
set_index(self.search_mode, item['search_mode']) set_index(self.search_mode, 'search_mode')
set_index(self.search_field, item['search_field']) set_index(self.search_field, 'search_field')
self.s_r_template.setText(item['s_r_template']) set_text(self.s_r_template, 's_r_template')
self.s_r_template_changed() #simulate gain/loss of focus self.s_r_template_changed() #simulate gain/loss of focus
self.search_for.setText(item['search_for'])
self.case_sensitive.setChecked(item['case_sensitive']) set_index(self.s_r_src_ident, 's_r_src_ident');
self.replace_with.setText(item['replace_with']) set_text(self.s_r_dst_ident, 's_r_dst_ident')
set_index(self.replace_func, item['replace_func']) set_text(self.search_for, 'search_for')
set_index(self.destination_field, item['destination_field']) set_checked(self.case_sensitive, 'case_sensitive')
set_index(self.replace_mode, item['replace_mode']) set_text(self.replace_with, 'replace_with')
self.comma_separated.setChecked(item['comma_separated']) set_index(self.replace_func, 'replace_func')
self.results_count.setValue(int(item['results_count'])) set_index(self.destination_field, 'destination_field')
self.starting_from.setValue(int(item['starting_from'])) set_index(self.replace_mode, 'replace_mode')
self.multiple_separator.setText(item['multiple_separator']) set_checked(self.comma_separated, 'comma_separated')
set_value(self.results_count, 'results_count')
set_value(self.starting_from, 'starting_from')
set_text(self.multiple_separator, 'multiple_separator')
def s_r_reset_query_fields(self): def s_r_reset_query_fields(self):
# Don't reset the search mode. The user will probably want to use it # Don't reset the search mode. The user will probably want to use it
# as it was # as it was
self.search_field.setCurrentIndex(0) self.search_field.setCurrentIndex(0)
self.s_r_src_ident.setCurrentIndex(0)
self.s_r_template.setText("") self.s_r_template.setText("")
self.search_for.setText("") self.search_for.setText("")
self.case_sensitive.setChecked(False) self.case_sensitive.setChecked(False)
self.replace_with.setText("") self.replace_with.setText("")
self.replace_func.setCurrentIndex(0) self.replace_func.setCurrentIndex(0)
self.destination_field.setCurrentIndex(0) self.destination_field.setCurrentIndex(0)
self.s_r_dst_ident.setText('')
self.replace_mode.setCurrentIndex(0) self.replace_mode.setCurrentIndex(0)
self.comma_separated.setChecked(True) self.comma_separated.setChecked(True)
self.results_count.setValue(999) self.results_count.setValue(999)

View File

@ -387,17 +387,17 @@ Searching for ``no`` or ``unchecked`` will find all books with ``No`` in the col
Hierarchical items (e.g. A.B.C) use an extended syntax to match initial parts of the hierarchy. This is done by adding a period between the exact match indicator (=) and the text. For example, the query ``tags:=.A`` will find the tags `A` and `A.B`, but will not find the tags `AA` or `AA.B`. The query ``tags:=.A.B`` will find the tags `A.B` and `A.C`, but not the tag `A`. Hierarchical items (e.g. A.B.C) use an extended syntax to match initial parts of the hierarchy. This is done by adding a period between the exact match indicator (=) and the text. For example, the query ``tags:=.A`` will find the tags `A` and `A.B`, but will not find the tags `AA` or `AA.B`. The query ``tags:=.A.B`` will find the tags `A.B` and `A.C`, but not the tag `A`.
Identifiers (e.g., isbn, doi, lccn etc) also use an extended syntax. First, note that an identifier has the form ``key:value``, as in ``isbn:123456789``. The extended syntax permits you to specify independently which key and value to search for. Both the key and the value parts of the query can use `equality`, `contains`, or `regular expression` matches. Examples: Identifiers (e.g., isbn, doi, lccn etc) also use an extended syntax. First, note that an identifier has the form ``type:value``, as in ``isbn:123456789``. The extended syntax permits you to specify independently which type and value to search for. Both the type and the value parts of the query can use `equality`, `contains`, or `regular expression` matches. Examples:
* ``identifiers:true`` will find books with any identifier. * ``identifiers:true`` will find books with any identifier.
* ``identifiers:false`` will find books with no identifier. * ``identifiers:false`` will find books with no identifier.
* ``identifiers:123`` will search for books with any key having a value containing `123`. * ``identifiers:123`` will search for books with any type having a value containing `123`.
* ``identifiers:=123456789`` will search for books with any key having a value equal to `123456789`. * ``identifiers:=123456789`` will search for books with any type having a value equal to `123456789`.
* ``identifiers:=isbn:`` and ``identifiers:isbn:true`` will find books with a key equal to isbn having any value * ``identifiers:=isbn:`` and ``identifiers:isbn:true`` will find books with a type equal to isbn having any value
* ``identifiers:=isbn:false`` will find books with no key equal to isbn. * ``identifiers:=isbn:false`` will find books with no type equal to isbn.
* ``identifiers:=isbn:123`` will find books with a key equal to isbn having a value containing `123`. * ``identifiers:=isbn:123`` will find books with a type equal to isbn having a value containing `123`.
* ``identifiers:=isbn:=123456789`` will find books with a key equal to isbn having a value equal to `123456789`. * ``identifiers:=isbn:=123456789`` will find books with a type equal to isbn having a value equal to `123456789`.
* ``identifiers:i:1`` will find books with a key containing an `i` having a value containing a `1`. * ``identifiers:i:1`` will find books with a type containing an `i` having a value containing a `1`.
.. |sbi| image:: images/search_button.png .. |sbi| image:: images/search_button.png