mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add search result class. Size columns for searching.
This commit is contained in:
parent
2ea80eed04
commit
8ccfab537c
@ -47,6 +47,22 @@ class SearchDialog(QDialog, Ui_Dialog):
|
|||||||
self.checker.timeout.connect(self.get_results)
|
self.checker.timeout.connect(self.get_results)
|
||||||
self.results_view.activated.connect(self.open_store)
|
self.results_view.activated.connect(self.open_store)
|
||||||
|
|
||||||
|
self.resize_columns()
|
||||||
|
|
||||||
|
def resize_columns(self):
|
||||||
|
total = 600
|
||||||
|
# Cover
|
||||||
|
self.results_view.setColumnWidth(0, 85)
|
||||||
|
total = total - 85
|
||||||
|
# Title
|
||||||
|
self.results_view.setColumnWidth(1,int(total*.35))
|
||||||
|
# Author
|
||||||
|
self.results_view.setColumnWidth(2,int(total*.35))
|
||||||
|
# Price
|
||||||
|
self.results_view.setColumnWidth(3, int(total*.10))
|
||||||
|
# Store
|
||||||
|
self.results_view.setColumnWidth(4, int(total*.20))
|
||||||
|
|
||||||
def do_search(self, checked=False):
|
def do_search(self, checked=False):
|
||||||
# Stop all running threads.
|
# Stop all running threads.
|
||||||
self.checker.stop()
|
self.checker.stop()
|
||||||
@ -117,9 +133,6 @@ class SearchThread(Thread):
|
|||||||
for res in self.store_plugin.search(self.query, timeout=self.timeout):
|
for res in self.store_plugin.search(self.query, timeout=self.timeout):
|
||||||
if self.abort.is_set():
|
if self.abort.is_set():
|
||||||
return
|
return
|
||||||
#if res.cover_url:
|
|
||||||
# with closing(self.br.open(res.cover_url, timeout=15)) as f:
|
|
||||||
# res.cover_data = f.read()
|
|
||||||
self.results.put((self.store_name, res))
|
self.results.put((self.store_name, res))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -171,12 +184,13 @@ class Matches(QAbstractItemModel):
|
|||||||
|
|
||||||
def clear_results(self):
|
def clear_results(self):
|
||||||
self.matches = []
|
self.matches = []
|
||||||
#self.cover_download_queue.queue.clear()
|
self.cover_download_queue.queue.clear()
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def add_result(self, result):
|
def add_result(self, result):
|
||||||
self.layoutAboutToBeChanged.emit()
|
self.layoutAboutToBeChanged.emit()
|
||||||
self.matches.append(result)
|
self.matches.append(result)
|
||||||
|
|
||||||
self.cover_download_queue.put(result)
|
self.cover_download_queue.put(result)
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
|
17
src/calibre/gui2/store/search_result.py
Normal file
17
src/calibre/gui2/store/search_result.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
__license__ = 'GPL 3'
|
||||||
|
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||||
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
class SearchResult(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.store = ''
|
||||||
|
self.cover_url = ''
|
||||||
|
self.cover_data = None
|
||||||
|
self.title = ''
|
||||||
|
self.author = ''
|
||||||
|
self.price = ''
|
||||||
|
self.store = ''
|
||||||
|
self.detail_item = ''
|
Loading…
x
Reference in New Issue
Block a user