Add text search to Bibles

Add Initialise method for plugins

bzr-revno: 215
This commit is contained in:
Tim Bentley 2008-12-13 09:03:39 +00:00
parent f042e5e2d8
commit 412a30f1b5
6 changed files with 42 additions and 14 deletions

View File

@ -129,3 +129,6 @@ class Plugin(object):
def getName(self): def getName(self):
return self.Name return self.Name
def initalise_ui(self):
return self.Name

View File

@ -88,6 +88,7 @@ class PluginManager(object):
if media_manager_item is not None: if media_manager_item is not None:
log.debug('Inserting media manager item from %s' % plugin.Name) log.debug('Inserting media manager item from %s' % plugin.Name)
mediatoolbox.addItem(media_manager_item, plugin.Icon, media_manager_item.Title) mediatoolbox.addItem(media_manager_item, plugin.Icon, media_manager_item.Title)
plugin.initalise_ui()
def hookHandleEvent(self, event): def hookHandleEvent(self, event):
pass pass

View File

@ -183,11 +183,13 @@ class BiblePlugin(Plugin):
QtCore.QObject.connect(self.AdvancedFromVerse, QtCore.SIGNAL("activated(int)"), self.onAdvancedFromVerse) QtCore.QObject.connect(self.AdvancedFromVerse, QtCore.SIGNAL("activated(int)"), self.onAdvancedFromVerse)
QtCore.QObject.connect(self.AdvancedToChapter, QtCore.SIGNAL("activated(int)"), self.onAdvancedToChapter) QtCore.QObject.connect(self.AdvancedToChapter, QtCore.SIGNAL("activated(int)"), self.onAdvancedToChapter)
QtCore.QObject.connect(self.AdvancedSearchButton, QtCore.SIGNAL("pressed()"), self.onAdvancedSearchButton) QtCore.QObject.connect(self.AdvancedSearchButton, QtCore.SIGNAL("pressed()"), self.onAdvancedSearchButton)
QtCore.QObject.connect(self.QuickSearchButton, QtCore.SIGNAL("pressed()"), self.onQuickSearchButton)
self._initialiseForm()
return self.MediaManagerItem return self.MediaManagerItem
def initalise_ui(self):
self._initialiseForm()
def onAdvancedVersionComboBox(self): def onAdvancedVersionComboBox(self):
self._initialiseBibleAdvanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info self._initialiseBibleAdvanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
@ -287,7 +289,6 @@ class BiblePlugin(Plugin):
self._adjustComboBox(1, vse, self.AdvancedToVerse) self._adjustComboBox(1, vse, self.AdvancedToVerse)
def onAdvancedSearchButton(self): def onAdvancedSearchButton(self):
self.listView.clear() # clear the results
bible = str(self.AdvancedVersionComboBox.currentText()) bible = str(self.AdvancedVersionComboBox.currentText())
book = str(self.AdvancedBookComboBox.currentText()) book = str(self.AdvancedBookComboBox.currentText())
chapfrom = int(self.AdvancedFromChapter.currentText()) chapfrom = int(self.AdvancedFromChapter.currentText())
@ -295,8 +296,29 @@ class BiblePlugin(Plugin):
versefrom = int(self.AdvancedFromVerse.currentText()) versefrom = int(self.AdvancedFromVerse.currentText())
verseto = int(self.AdvancedToVerse.currentText()) verseto = int(self.AdvancedToVerse.currentText())
self.searchresults = self.biblemanager.getVerseText(bible, book, chapfrom, versefrom, verseto) self.searchresults = self.biblemanager.getVerseText(bible, book, chapfrom, versefrom, verseto)
for sv , st in self.searchresults: self._displayResults()
self.listView.addItem(book + " " +str(chapfrom) + ":"+ str(sv))
def onQuickSearchButton(self):
bible = str(self.QuickVersionComboBox.currentText())
text = str(self.QuickSearchEdit.displayText())
if self.QuickSearchComboBox.currentText() == "Text Search":
self._searchText(bible, text)
else:
self._verseSearch()
def _searchText(self, bible, text):
self.searchresults = self.biblemanager.getVersesFromText(bible,text)
self._displayResults()
def _verseSearch(self):
self._displayResults()
def _displayResults(self):
self.listView.clear() # clear the results
print self.searchresults
for book, chap, vse , txt in self.searchresults:
self.listView.addItem(book + " " +str(chap) + ":"+ str(vse))
def _initialiseBibleQuick(self, bible): # not sure if needed yet! def _initialiseBibleQuick(self, bible): # not sure if needed yet!
a=1 a=1

View File

@ -235,7 +235,7 @@ class BibleDBImpl(BibleCommon):
def getBibleText(self, bookname, chapter, sverse, everse): def getBibleText(self, bookname, chapter, sverse, everse):
log.debug( "getBibleText %s,%s,%s,%s ", bookname, chapter, sverse, everse) log.debug( "getBibleText %s,%s,%s,%s ", bookname, chapter, sverse, everse)
metadata.bind.echo = False metadata.bind.echo = False
s = text (""" select verse.verse, verse.text FROM verse , book where verse.book_id == book.id AND verse.chapter == :c AND (verse.verse between :v1 and :v2) and book.name == :b """) s = text (""" select name,chapter,verse.verse, verse.text FROM verse , book where verse.book_id == book.id AND verse.chapter == :c AND (verse.verse between :v1 and :v2) and book.name == :b """)
return self.db.execute(s, c=chapter, v1=sverse , v2=everse, b=bookname).fetchall() return self.db.execute(s, c=chapter, v1=sverse , v2=everse, b=bookname).fetchall()
def getVersesFromText(self,versetext): def getVersesFromText(self,versetext):

View File

@ -68,10 +68,11 @@ class PresentationPlugin(Plugin):
self.listView.setObjectName("listView") self.listView.setObjectName("listView")
self.MediaManagerItem.PageLayout.addWidget(self.listView) self.MediaManagerItem.PageLayout.addWidget(self.listView)
self.onPresentationNewClick()
return self.MediaManagerItem return self.MediaManagerItem
def initalise_ui(self):
self.onPresentationNewClick()
def onPresentationNewClick(self): def onPresentationNewClick(self):
files = self.config.get_files() files = self.config.get_files()
self.listView.clear() self.listView.clear()

View File

@ -105,12 +105,13 @@ class SongsPlugin(Plugin):
self.listView.setObjectName("listView") self.listView.setObjectName("listView")
self.MediaManagerItem.PageLayout.addWidget(self.listView) self.MediaManagerItem.PageLayout.addWidget(self.listView)
self.SearchTypeComboBox.addItem("Lyrics")
self.SearchTypeComboBox.addItem("Authors")
self.SearchTypeComboBox.addItem("Titles")
return self.MediaManagerItem return self.MediaManagerItem
def initalise_ui(self):
self.SearchTypeComboBox.addItem("Lyrics")
self.SearchTypeComboBox.addItem("Titles")
self.SearchTypeComboBox.addItem("Authors")
def onSongNewClick(self): def onSongNewClick(self):
pass pass