forked from openlp/openlp
Add text search to Bibles
Add Initialise method for plugins bzr-revno: 215
This commit is contained in:
parent
f042e5e2d8
commit
412a30f1b5
@ -129,3 +129,6 @@ class Plugin(object):
|
||||
|
||||
def getName(self):
|
||||
return self.Name
|
||||
|
||||
def initalise_ui(self):
|
||||
return self.Name
|
||||
|
@ -88,6 +88,7 @@ class PluginManager(object):
|
||||
if media_manager_item is not None:
|
||||
log.debug('Inserting media manager item from %s' % plugin.Name)
|
||||
mediatoolbox.addItem(media_manager_item, plugin.Icon, media_manager_item.Title)
|
||||
plugin.initalise_ui()
|
||||
|
||||
def hookHandleEvent(self, event):
|
||||
pass
|
||||
|
@ -182,12 +182,14 @@ class BiblePlugin(Plugin):
|
||||
QtCore.QObject.connect(self.AdvancedFromChapter, QtCore.SIGNAL("activated(int)"), self.onAdvancedFromChapter)
|
||||
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.AdvancedSearchButton, QtCore.SIGNAL("pressed()"), self.onAdvancedSearchButton)
|
||||
|
||||
self._initialiseForm()
|
||||
|
||||
QtCore.QObject.connect(self.AdvancedSearchButton, QtCore.SIGNAL("pressed()"), self.onAdvancedSearchButton)
|
||||
QtCore.QObject.connect(self.QuickSearchButton, QtCore.SIGNAL("pressed()"), self.onQuickSearchButton)
|
||||
|
||||
return self.MediaManagerItem
|
||||
|
||||
def initalise_ui(self):
|
||||
self._initialiseForm()
|
||||
|
||||
def onAdvancedVersionComboBox(self):
|
||||
self._initialiseBibleAdvanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
||||
|
||||
@ -287,7 +289,6 @@ class BiblePlugin(Plugin):
|
||||
self._adjustComboBox(1, vse, self.AdvancedToVerse)
|
||||
|
||||
def onAdvancedSearchButton(self):
|
||||
self.listView.clear() # clear the results
|
||||
bible = str(self.AdvancedVersionComboBox.currentText())
|
||||
book = str(self.AdvancedBookComboBox.currentText())
|
||||
chapfrom = int(self.AdvancedFromChapter.currentText())
|
||||
@ -295,8 +296,29 @@ class BiblePlugin(Plugin):
|
||||
versefrom = int(self.AdvancedFromVerse.currentText())
|
||||
verseto = int(self.AdvancedToVerse.currentText())
|
||||
self.searchresults = self.biblemanager.getVerseText(bible, book, chapfrom, versefrom, verseto)
|
||||
for sv , st in self.searchresults:
|
||||
self.listView.addItem(book + " " +str(chapfrom) + ":"+ str(sv))
|
||||
self._displayResults()
|
||||
|
||||
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!
|
||||
a=1
|
||||
|
@ -235,7 +235,7 @@ class BibleDBImpl(BibleCommon):
|
||||
def getBibleText(self, bookname, chapter, sverse, everse):
|
||||
log.debug( "getBibleText %s,%s,%s,%s ", bookname, chapter, sverse, everse)
|
||||
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()
|
||||
|
||||
def getVersesFromText(self,versetext):
|
||||
|
@ -68,10 +68,11 @@ class PresentationPlugin(Plugin):
|
||||
self.listView.setObjectName("listView")
|
||||
self.MediaManagerItem.PageLayout.addWidget(self.listView)
|
||||
|
||||
self.onPresentationNewClick()
|
||||
|
||||
return self.MediaManagerItem
|
||||
|
||||
def initalise_ui(self):
|
||||
self.onPresentationNewClick()
|
||||
|
||||
def onPresentationNewClick(self):
|
||||
files = self.config.get_files()
|
||||
self.listView.clear()
|
||||
|
@ -105,12 +105,13 @@ class SongsPlugin(Plugin):
|
||||
self.listView.setObjectName("listView")
|
||||
self.MediaManagerItem.PageLayout.addWidget(self.listView)
|
||||
|
||||
self.SearchTypeComboBox.addItem("Lyrics")
|
||||
self.SearchTypeComboBox.addItem("Authors")
|
||||
self.SearchTypeComboBox.addItem("Titles")
|
||||
|
||||
return self.MediaManagerItem
|
||||
|
||||
def initalise_ui(self):
|
||||
self.SearchTypeComboBox.addItem("Lyrics")
|
||||
self.SearchTypeComboBox.addItem("Titles")
|
||||
self.SearchTypeComboBox.addItem("Authors")
|
||||
|
||||
def onSongNewClick(self):
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user