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() return rows[0].row()
def _get_author(self, row): def _get_author(self, row):
author = '' authors = []
if self.gui.current_view() is self.gui.library_view: if self.gui.current_view() is self.gui.library_view:
author = self.gui.library_view.model().authors(row) a = self.gui.library_view.model().authors(row)
if author: authors = a.split(',')
author = author.replace('|', ' ')
else: else:
mi = self.gui.current_view().model().get_book_display_info(row) 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): def search_author(self):
row = self._get_selected_row() 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' url = 'http://www.bewrite.net/mm5/merchant.mvc?Screen=SFNT'
if external or self.config.get('open_external', False): if external or self.config.get('open_external', False):
if detail_item: open_url(QUrl(url_slash_cleaner(detail_item if detail_item else url)))
url = url + detail_item
open_url(QUrl(url_slash_cleaner(url)))
else: else:
detail_url = None d = WebStoreDialog(self.gui, url, parent, detail_item)
if detail_item:
detail_url = url + detail_item
d = WebStoreDialog(self.gui, url, parent, detail_url)
d.setWindowTitle(self.name) d.setWindowTitle(self.name)
d.set_tags(self.config.get('tags', '')) d.set_tags(self.config.get('tags', ''))
d.exec_() d.exec_()

View File

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

View File

@ -34,7 +34,14 @@
</widget> </widget>
</item> </item>
<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>
<item> <item>
<widget class="QPushButton" name="search_button"> <widget class="QPushButton" name="search_button">
@ -107,6 +114,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>HistoryLineEdit</class>
<extends>QLineEdit</extends>
<header>widgets.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections> <connections>
<connection> <connection>

View File

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

View File

@ -38,7 +38,14 @@
</widget> </widget>
</item> </item>
<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>
<item> <item>
<widget class="QPushButton" name="search"> <widget class="QPushButton" name="search">
@ -201,6 +208,11 @@
<extends>QTreeView</extends> <extends>QTreeView</extends>
<header>results_view.h</header> <header>results_view.h</header>
</customwidget> </customwidget>
<customwidget>
<class>HistoryLineEdit</class>
<extends>QLineEdit</extends>
<header>widgets.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../../../../resources/images.qrc"/> <include location="../../../../resources/images.qrc"/>