mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Indicate number of matches when searching
This commit is contained in:
parent
6451c8b726
commit
346399d1dc
@ -861,6 +861,9 @@ class BooksView(TableView):
|
||||
def search_done(self, ok):
|
||||
self._search_done(self, ok)
|
||||
|
||||
def row_count(self):
|
||||
return self._model.count()
|
||||
|
||||
|
||||
class DeviceBooksView(BooksView):
|
||||
|
||||
|
@ -206,6 +206,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="search_count">
|
||||
<property name="text">
|
||||
<string>set in ui.py</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="clear_button">
|
||||
<property name="toolTip">
|
||||
|
@ -256,10 +256,11 @@ class SavedSearchBox(QComboBox):
|
||||
|
||||
def saved_search_selected (self, qname):
|
||||
#print 'in saved_search_selected'
|
||||
if qname is None or qname == '':
|
||||
qname = unicode(qname)
|
||||
if qname is None or not qname.strip():
|
||||
return
|
||||
self.normalize_state()
|
||||
self.search_box.set_search_string ('search:"'+unicode(qname)+'"')
|
||||
self.search_box.set_search_string(u'search:"%s"' % qname)
|
||||
self.setEditText(qname)
|
||||
self.setToolTip(self.saved_searches.lookup(qname))
|
||||
|
||||
@ -284,10 +285,11 @@ class SavedSearchBox(QComboBox):
|
||||
# SIGNALed from the main UI
|
||||
def save_search_button_clicked(self):
|
||||
#print 'in save_search_button_clicked'
|
||||
name = self.currentText()
|
||||
if self.help_state or name == '':
|
||||
name = self.search_box.text().replace('"', '')
|
||||
self.saved_searches.add(name, self.search_box.text())
|
||||
name = unicode(self.currentText())
|
||||
if self.help_state or not name.strip():
|
||||
name = unicode(self.search_box.text()).replace('"', '')
|
||||
self.saved_searches.delete(name)
|
||||
self.saved_searches.add(name, unicode(self.search_box.text()))
|
||||
# now go through an initialization cycle to ensure that the combobox has
|
||||
# the new search in it, that it is selected, and that the search box
|
||||
# references the new search instead of the text in the search.
|
||||
@ -303,6 +305,6 @@ class SavedSearchBox(QComboBox):
|
||||
idx = self.currentIndex();
|
||||
if idx < 0:
|
||||
return
|
||||
self.search_box.set_search_string (self.saved_searches.lookup(self.currentText()))
|
||||
self.search_box.set_search_string(self.saved_searches.lookup(unicode(self.currentText())))
|
||||
|
||||
|
||||
|
@ -144,8 +144,9 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
|
||||
self.search.initialize('main_search_history', colorize=True,
|
||||
help_text=_('Search (For Advanced Search click the button to the left)'))
|
||||
self.connect(self.clear_button, SIGNAL('clicked()'), self.search.clear)
|
||||
self.connect(self.clear_button, SIGNAL('clicked()'), self.search_clear)
|
||||
self.connect(self.clear_button, SIGNAL('clicked()'), self.saved_search.clear_to_help)
|
||||
self.search_clear()
|
||||
|
||||
self.saved_search.initialize(saved_searches, self.search, colorize=True,
|
||||
help_text=_('Saved Searches'))
|
||||
@ -536,8 +537,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
SIGNAL('count_changed(int)'), self.location_view.count_changed)
|
||||
self.connect(self.library_view.model(), SIGNAL('count_changed(int)'),
|
||||
self.tags_view.recount)
|
||||
self.connect(self.search, SIGNAL('cleared()'), self.tags_view.clear)
|
||||
self.connect(self.saved_search, SIGNAL('changed()'), self.tags_view.recount)
|
||||
self.connect(self.search, SIGNAL('cleared()'), self.tags_view_clear)
|
||||
self.connect(self.saved_search, SIGNAL('changed()'), self.tags_view.recount, Qt.QueuedConnection)
|
||||
if not gprefs.get('quick_start_guide_added', False):
|
||||
from calibre.ebooks.metadata import MetaInformation
|
||||
mi = MetaInformation(_('Calibre Quick Start Guide'), ['John Schember'])
|
||||
@ -779,8 +780,17 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
self.tag_match.setVisible(False)
|
||||
self.popularity.setVisible(False)
|
||||
|
||||
def tags_view_clear(self):
|
||||
self.search_count.setText(_("(all books)"))
|
||||
self.tags_view.clear()
|
||||
|
||||
def search_clear(self):
|
||||
self.search_count.setText(_("(all books)"))
|
||||
self.search.clear()
|
||||
|
||||
def search_done(self, view, ok):
|
||||
if view is self.current_view():
|
||||
self.search_count.setText(_("(%d found)") % self.current_view().row_count())
|
||||
self.search.search_done(ok)
|
||||
|
||||
def sync_cf_to_listview(self, current, previous):
|
||||
|
Loading…
x
Reference in New Issue
Block a user