Get Books: Store last few searches in history

This commit is contained in:
Kovid Goyal 2011-05-14 18:50:08 -06:00
commit f5f801f59e
6 changed files with 46 additions and 15 deletions

View File

@ -52,16 +52,23 @@ class StoreAction(InterfaceAction):
return rows[0].row()
def _get_author(self, row):
author = ''
authors = []
if self.gui.current_view() is self.gui.library_view:
author = self.gui.library_view.model().authors(row)
if author:
author = author.replace('|', ' ')
a = self.gui.library_view.model().authors(row)
authors = a.split(',')
else:
mi = self.gui.current_view().model().get_book_display_info(row)
author = ' & '.join(mi.authors)
authors = mi.authors
return author
corrected_authors = []
for x in authors:
a = x.split('|')
a.reverse()
a = ' '.join(a)
corrected_authors.append(a)
return ' & '.join(corrected_authors)
def search_author(self):
row = self._get_selected_row()

View File

@ -26,14 +26,9 @@ class BeWriteStore(BasicStoreConfig, StorePlugin):
url = 'http://www.bewrite.net/mm5/merchant.mvc?Screen=SFNT'
if external or self.config.get('open_external', False):
if detail_item:
url = url + detail_item
open_url(QUrl(url_slash_cleaner(url)))
open_url(QUrl(url_slash_cleaner(detail_item if detail_item else url)))
else:
detail_url = None
if detail_item:
detail_url = url + detail_item
d = WebStoreDialog(self.gui, url, parent, detail_url)
d = WebStoreDialog(self.gui, url, parent, detail_item)
d.setWindowTitle(self.name)
d.set_tags(self.config.get('tags', ''))
d.exec_()

View File

@ -20,6 +20,7 @@ class MobeReadStoreDialog(QDialog, Ui_Dialog):
self.setupUi(self)
self.plugin = plugin
self.search_query.initialize('store_mobileread_search')
self.adv_search_button.setIcon(QIcon(I('search.png')))

View File

@ -34,7 +34,14 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="search_query"/>
<widget class="HistoryLineEdit" name="search_query">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="search_button">
@ -107,6 +114,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HistoryLineEdit</class>
<extends>QLineEdit</extends>
<header>widgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>

View File

@ -28,6 +28,8 @@ class SearchDialog(QDialog, Ui_Dialog):
self.setupUi(self)
self.config = JSONConfig('store/search')
self.search_edit.initialize('store_search_search')
# We keep a cache of store plugins and reference them by name.
self.store_plugins = istores

View File

@ -38,7 +38,14 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="search_edit"/>
<widget class="HistoryLineEdit" name="search_edit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="search">
@ -201,6 +208,11 @@
<extends>QTreeView</extends>
<header>results_view.h</header>
</customwidget>
<customwidget>
<class>HistoryLineEdit</class>
<extends>QLineEdit</extends>
<header>widgets.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../resources/images.qrc"/>