added an autoCompleter for bible books for 'Verse Search'

This commit is contained in:
Andreas Preikschat 2010-12-01 19:37:54 +01:00
parent 28390e965d
commit cd6948f613

View File

@ -240,6 +240,10 @@ class BibleMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedFromVerse)
QtCore.QObject.connect(self.AdvancedToChapter,
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedToChapter)
QtCore.QObject.connect(self.QuickSearchComboBox,
QtCore.SIGNAL(u'activated(int)'), self.autoCompletion)
QtCore.QObject.connect(self.QuickVersionComboBox,
QtCore.SIGNAL(u'activated(int)'), self.autoCompletion)
# Buttons
QtCore.QObject.connect(self.AdvancedSearchButton,
QtCore.SIGNAL(u'pressed()'), self.onAdvancedSearchButton)
@ -428,6 +432,21 @@ class BibleMediaItem(MediaManagerItem):
self.adjustComboBox(1, verse_count, self.AdvancedFromVerse)
self.adjustComboBox(1, verse_count, self.AdvancedToVerse)
def autoCompletion(self):
"""
This add or updates a bible book completion list for the search field.
The completion depends on the bible. It is only added when we are doing
a verse search on the quick tab, otherwise it is removed.
"""
books = []
# We have to do a 'Verse Search'.
if self.QuickSearchComboBox.currentIndex() == 0:
bible = unicode(self.QuickVersionComboBox.currentText())
if bible:
book_data = self.parent.manager.get_books(bible)
books = [book[u'name'] for book in book_data]
self.QuickSearchEdit.setCompleter(QtGui.QCompleter(books))
def onAdvancedVersionComboBox(self):
self.initialiseBible(
unicode(self.AdvancedVersionComboBox.currentText()))