mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Store: Search, add author and title searches to search dialog because users can't be bothered to use the advanced search editor.
This commit is contained in:
parent
b0b1b95860
commit
ff12f12ec9
@ -31,6 +31,8 @@ class SearchDialog(QDialog, Ui_Dialog):
|
|||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
self.config = JSONConfig('store/search')
|
self.config = JSONConfig('store/search')
|
||||||
|
self.search_title.initialize('store_search_search_title')
|
||||||
|
self.search_author.initialize('store_search_search_author')
|
||||||
self.search_edit.initialize('store_search_search')
|
self.search_edit.initialize('store_search_search')
|
||||||
|
|
||||||
# Loads variables that store various settings.
|
# Loads variables that store various settings.
|
||||||
@ -60,13 +62,22 @@ class SearchDialog(QDialog, Ui_Dialog):
|
|||||||
self.setup_store_checks()
|
self.setup_store_checks()
|
||||||
|
|
||||||
# Set the search query
|
# Set the search query
|
||||||
|
# Title
|
||||||
|
self.search_title.setText(query)
|
||||||
|
self.search_title.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
||||||
|
self.search_title.setMinimumContentsLength(25)
|
||||||
|
# Author
|
||||||
|
self.search_author.setText(query)
|
||||||
|
self.search_author.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
||||||
|
self.search_author.setMinimumContentsLength(25)
|
||||||
|
# Keyword
|
||||||
self.search_edit.setText(query)
|
self.search_edit.setText(query)
|
||||||
self.search_edit.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
self.search_edit.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
|
||||||
self.search_edit.setMinimumContentsLength(25)
|
self.search_edit.setMinimumContentsLength(25)
|
||||||
|
|
||||||
# Create and add the progress indicator
|
# Create and add the progress indicator
|
||||||
self.pi = ProgressIndicator(self, 24)
|
self.pi = ProgressIndicator(self, 24)
|
||||||
self.top_layout.addWidget(self.pi)
|
self.top_layout.addWidget(self.pi, 1, 3, Qt.AlignHCenter)
|
||||||
|
|
||||||
self.adv_search_button.setIcon(QIcon(I('search.png')))
|
self.adv_search_button.setIcon(QIcon(I('search.png')))
|
||||||
self.configure.setIcon(QIcon(I('config.png')))
|
self.configure.setIcon(QIcon(I('config.png')))
|
||||||
@ -152,7 +163,14 @@ class SearchDialog(QDialog, Ui_Dialog):
|
|||||||
self.results_view.model().clear_results()
|
self.results_view.model().clear_results()
|
||||||
|
|
||||||
# Don't start a search if there is nothing to search for.
|
# Don't start a search if there is nothing to search for.
|
||||||
query = unicode(self.search_edit.text())
|
query = []
|
||||||
|
if self.search_title.text():
|
||||||
|
query.append(u'title:"~%s"' % unicode(self.search_title.text()).replace(" ", ".*"))
|
||||||
|
if self.search_author.text():
|
||||||
|
query.append(u'author:"~%s"' % unicode(self.search_author.text()).replace(" ", ".*"))
|
||||||
|
if self.search_edit.text():
|
||||||
|
query.append(unicode(self.search_edit.text()))
|
||||||
|
query = " ".join(query)
|
||||||
if not query.strip():
|
if not query.strip():
|
||||||
return
|
return
|
||||||
# Give the query to the results model so it can do
|
# Give the query to the results model so it can do
|
||||||
|
@ -22,22 +22,8 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="top_layout">
|
<layout class="QGridLayout" name="top_layout">
|
||||||
<item>
|
<item row="2" column="2">
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Query:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="adv_search_button">
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="HistoryLineEdit" name="search_edit">
|
<widget class="HistoryLineEdit" name="search_edit">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
@ -47,13 +33,56 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="2">
|
||||||
|
<widget class="HistoryLineEdit" name="search_author"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="3">
|
||||||
<widget class="QPushButton" name="search">
|
<widget class="QPushButton" name="search">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Search</string>
|
<string>Search</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="HistoryLineEdit" name="search_title"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Author:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Title:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Keyword:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QToolButton" name="adv_search_button">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -255,17 +284,19 @@
|
|||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
<tabstop>search_title</tabstop>
|
||||||
|
<tabstop>search_author</tabstop>
|
||||||
|
<tabstop>adv_search_button</tabstop>
|
||||||
<tabstop>search_edit</tabstop>
|
<tabstop>search_edit</tabstop>
|
||||||
<tabstop>search</tabstop>
|
<tabstop>search</tabstop>
|
||||||
<tabstop>results_view</tabstop>
|
|
||||||
<tabstop>store_list</tabstop>
|
<tabstop>store_list</tabstop>
|
||||||
<tabstop>select_all_stores</tabstop>
|
<tabstop>select_all_stores</tabstop>
|
||||||
<tabstop>select_invert_stores</tabstop>
|
<tabstop>select_invert_stores</tabstop>
|
||||||
<tabstop>select_none_stores</tabstop>
|
<tabstop>select_none_stores</tabstop>
|
||||||
|
<tabstop>results_view</tabstop>
|
||||||
<tabstop>configure</tabstop>
|
<tabstop>configure</tabstop>
|
||||||
<tabstop>open_external</tabstop>
|
<tabstop>open_external</tabstop>
|
||||||
<tabstop>close</tabstop>
|
<tabstop>close</tabstop>
|
||||||
<tabstop>adv_search_button</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../../../resources/images.qrc"/>
|
<include location="../../../../../resources/images.qrc"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user