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:
John Schember 2012-11-18 13:47:39 -05:00
parent b0b1b95860
commit ff12f12ec9
2 changed files with 70 additions and 21 deletions

View File

@ -31,6 +31,8 @@ class SearchDialog(QDialog, Ui_Dialog):
self.setupUi(self)
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')
# Loads variables that store various settings.
@ -60,13 +62,22 @@ class SearchDialog(QDialog, Ui_Dialog):
self.setup_store_checks()
# 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.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
self.search_edit.setMinimumContentsLength(25)
# Create and add the progress indicator
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.configure.setIcon(QIcon(I('config.png')))
@ -152,7 +163,14 @@ class SearchDialog(QDialog, Ui_Dialog):
self.results_view.model().clear_results()
# 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():
return
# Give the query to the results model so it can do

View File

@ -22,22 +22,8 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="top_layout">
<item>
<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>
<layout class="QGridLayout" name="top_layout">
<item row="2" column="2">
<widget class="HistoryLineEdit" name="search_edit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -47,13 +33,56 @@
</property>
</widget>
</item>
<item>
<item row="1" column="2">
<widget class="HistoryLineEdit" name="search_author"/>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="search">
<property name="text">
<string>Search</string>
</property>
</widget>
</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>
</item>
<item>
@ -255,17 +284,19 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>search_title</tabstop>
<tabstop>search_author</tabstop>
<tabstop>adv_search_button</tabstop>
<tabstop>search_edit</tabstop>
<tabstop>search</tabstop>
<tabstop>results_view</tabstop>
<tabstop>store_list</tabstop>
<tabstop>select_all_stores</tabstop>
<tabstop>select_invert_stores</tabstop>
<tabstop>select_none_stores</tabstop>
<tabstop>results_view</tabstop>
<tabstop>configure</tabstop>
<tabstop>open_external</tabstop>
<tabstop>close</tabstop>
<tabstop>adv_search_button</tabstop>
</tabstops>
<resources>
<include location="../../../../../resources/images.qrc"/>