mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement searching on series index
This commit is contained in:
commit
a545bd1d81
@ -105,6 +105,8 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
return self.simple_error('', _('No lookup name was provided'))
|
return self.simple_error('', _('No lookup name was provided'))
|
||||||
if re.match('^\w*$', col) is None or not col[0].isalpha() or col.lower() != col:
|
if re.match('^\w*$', col) is None or not col[0].isalpha() or col.lower() != col:
|
||||||
return self.simple_error('', _('The lookup name must contain only lower case letters, digits and underscores, and start with a letter'))
|
return self.simple_error('', _('The lookup name must contain only lower case letters, digits and underscores, and start with a letter'))
|
||||||
|
if col.endswith('_index'):
|
||||||
|
return self.simple_error('', _('Lookup names cannot end with _index, because these names are reserved for the index of a series column.'))
|
||||||
col_heading = unicode(self.column_heading_box.text())
|
col_heading = unicode(self.column_heading_box.text())
|
||||||
col_type = self.column_types[self.column_type_box.currentIndex()]['datatype']
|
col_type = self.column_types[self.column_type_box.currentIndex()]['datatype']
|
||||||
if col_type == '*text':
|
if col_type == '*text':
|
||||||
|
@ -264,7 +264,11 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
# account for the series index column. Field_metadata knows that
|
# account for the series index column. Field_metadata knows that
|
||||||
# the series index is one larger than the series. If you change
|
# the series index is one larger than the series. If you change
|
||||||
# it here, be sure to change it there as well.
|
# it here, be sure to change it there as well.
|
||||||
self.FIELD_MAP[str(col)+'_s_index'] = base = base+1
|
self.FIELD_MAP[str(col)+'_index'] = base = base+1
|
||||||
|
self.field_metadata.set_field_record_index(
|
||||||
|
self.custom_column_num_map[col]['label']+'_index',
|
||||||
|
base,
|
||||||
|
prefer_custom=True)
|
||||||
|
|
||||||
self.FIELD_MAP['cover'] = base+1
|
self.FIELD_MAP['cover'] = base+1
|
||||||
self.field_metadata.set_field_record_index('cover', base+1, prefer_custom=False)
|
self.field_metadata.set_field_record_index('cover', base+1, prefer_custom=False)
|
||||||
|
@ -36,7 +36,7 @@ class FieldMetadata(dict):
|
|||||||
treated as a single term. If not None, it contains a string, and the field
|
treated as a single term. If not None, it contains a string, and the field
|
||||||
is assumed to contain a list of terms separated by that string
|
is assumed to contain a list of terms separated by that string
|
||||||
|
|
||||||
kind == standard: is a db field.
|
kind == field: is a db field.
|
||||||
kind == category: standard tag category that isn't a field. see news.
|
kind == category: standard tag category that isn't a field. see news.
|
||||||
kind == user: user-defined tag category.
|
kind == user: user-defined tag category.
|
||||||
kind == search: saved-searches category.
|
kind == search: saved-searches category.
|
||||||
@ -239,7 +239,7 @@ class FieldMetadata(dict):
|
|||||||
'is_multiple':None,
|
'is_multiple':None,
|
||||||
'kind':'field',
|
'kind':'field',
|
||||||
'name':None,
|
'name':None,
|
||||||
'search_terms':[],
|
'search_terms':['series_index'],
|
||||||
'is_custom':False,
|
'is_custom':False,
|
||||||
'is_category':False}),
|
'is_category':False}),
|
||||||
('sort', {'table':None,
|
('sort', {'table':None,
|
||||||
@ -395,6 +395,18 @@ class FieldMetadata(dict):
|
|||||||
'is_editable': is_editable,}
|
'is_editable': is_editable,}
|
||||||
self._add_search_terms_to_map(key, [key])
|
self._add_search_terms_to_map(key, [key])
|
||||||
self.custom_label_to_key_map[label] = key
|
self.custom_label_to_key_map[label] = key
|
||||||
|
if datatype == 'series':
|
||||||
|
key += '_index'
|
||||||
|
self._tb_cats[key] = {'table':None, 'column':None,
|
||||||
|
'datatype':'float', 'is_multiple':False,
|
||||||
|
'kind':'field', 'name':'',
|
||||||
|
'search_terms':[key], 'label':label+'_index',
|
||||||
|
'colnum':None, 'display':{},
|
||||||
|
'is_custom':False, 'is_category':False,
|
||||||
|
'link_column':None, 'category_sort':None,
|
||||||
|
'is_editable': False,}
|
||||||
|
self._add_search_terms_to_map(key, [key])
|
||||||
|
self.custom_label_to_key_map[label+'_index'] = key
|
||||||
|
|
||||||
def remove_custom_fields(self):
|
def remove_custom_fields(self):
|
||||||
for key in self.get_custom_fields():
|
for key in self.get_custom_fields():
|
||||||
|
@ -212,9 +212,10 @@ metadata.
|
|||||||
You can build advanced search queries easily using the :guilabel:`Advanced Search Dialog`, accessed by
|
You can build advanced search queries easily using the :guilabel:`Advanced Search Dialog`, accessed by
|
||||||
clicking the button |sbi|.
|
clicking the button |sbi|.
|
||||||
|
|
||||||
Available fields for searching are: ``tag, title, author, publisher, series, rating, cover, comments, format,
|
Available fields for searching are: ``tag, title, author, publisher, series, series_index, rating, cover,
|
||||||
isbn, date, pubdate, search, size`` and custom columns. If a device is plugged in, the ``ondevice`` field
|
comments, format, isbn, date, pubdate, search, size`` and custom columns. If a device is plugged in, the
|
||||||
becomes available. To find the search name for a custom column, hover your mouse over the column header.
|
``ondevice`` field becomes available. To find the search name for a custom column, hover your mouse over the
|
||||||
|
column header.
|
||||||
|
|
||||||
The syntax for searching for dates is::
|
The syntax for searching for dates is::
|
||||||
|
|
||||||
@ -223,9 +224,8 @@ The syntax for searching for dates is::
|
|||||||
pubdate:=2009 Will find all books published in 2009
|
pubdate:=2009 Will find all books published in 2009
|
||||||
|
|
||||||
If the date is ambiguous, the current locale is used for date comparison. For example, in an mm/dd/yyyy
|
If the date is ambiguous, the current locale is used for date comparison. For example, in an mm/dd/yyyy
|
||||||
locale, 2/1/2009 is interpreted as 1 Feb 2009. In a dd/mm/yyyy locale, it is interpreted as 2 Jan 2009.
|
locale, 2/1/2009 is interpreted as 1 Feb 2009. In a dd/mm/yyyy locale, it is interpreted as 2 Jan 2009. Some
|
||||||
|
special date strings are available. The string ``today`` translates to today's date, whatever it is. The
|
||||||
Some special date strings are available. The string ``today`` translates to today's date, whatever it is. The
|
|
||||||
strings `yesterday`` and ``thismonth`` also work. In addition, the string ``daysago`` can be used to compare
|
strings `yesterday`` and ``thismonth`` also work. In addition, the string ``daysago`` can be used to compare
|
||||||
to a date some number of days ago, for example: date:>10daysago, date:<=45daysago.
|
to a date some number of days ago, for example: date:>10daysago, date:<=45daysago.
|
||||||
|
|
||||||
@ -234,9 +234,15 @@ You can search for books that have a format of a certain size like this::
|
|||||||
size:>1.1M Will find books with a format larger than 1.1MB
|
size:>1.1M Will find books with a format larger than 1.1MB
|
||||||
size:<=1K Will find books with a format smaller than 1KB
|
size:<=1K Will find books with a format smaller than 1KB
|
||||||
|
|
||||||
Dates and numeric fields support the operators ``=`` (equals), ``>`` (greater than), ``>=`` (greater than or
|
Dates and numeric fields support the relational operators ``=`` (equals), ``>`` (greater than), ``>=``
|
||||||
equal to), ``<`` (less than), ``<=`` (less than or equal to), and ``!=`` (not equal to). Rating fields are
|
(greater than or equal to), ``<`` (less than), ``<=`` (less than or equal to), and ``!=`` (not equal to).
|
||||||
considered to be numeric. For example, the search ``rating:>=3`` will find all books rated 3 or higher.
|
Rating fields are considered to be numeric. For example, the search ``rating:>=3`` will find all books rated 3
|
||||||
|
or higher.
|
||||||
|
|
||||||
|
Series indices are searchable. For the standard series, the search name is 'series_index'. For
|
||||||
|
custom series columns, use the column search name followed by _index. For example, to search the indices for a
|
||||||
|
custom series column named ``#my_series``, you would use the search name ``#my_series_index``.
|
||||||
|
Series indices are numbers, so you can use the relational operators described above.
|
||||||
|
|
||||||
The special field ``search`` is used for saved searches. So if you save a search with the name
|
The special field ``search`` is used for saved searches. So if you save a search with the name
|
||||||
"My spouse's books" you can enter ``search:"My spouse's books"`` in the search bar to reuse the saved
|
"My spouse's books" you can enter ``search:"My spouse's books"`` in the search bar to reuse the saved
|
||||||
|
Loading…
x
Reference in New Issue
Block a user