From 412a30f1b567b68a30a6b9402b301b9d94036474 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 13 Dec 2008 09:03:39 +0000 Subject: [PATCH] Add text search to Bibles Add Initialise method for plugins bzr-revno: 215 --- openlp/core/lib/plugin.py | 3 ++ openlp/core/pluginmanager.py | 1 + openlp/plugins/bibles/bibleplugin.py | 36 +++++++++++++++---- openlp/plugins/bibles/lib/bibleDBimpl.py | 2 +- .../presentations/presentationplugin.py | 5 +-- openlp/plugins/songs/songsplugin.py | 9 ++--- 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 573ac24c3..0696526f2 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -129,3 +129,6 @@ class Plugin(object): def getName(self): return self.Name + + def initalise_ui(self): + return self.Name diff --git a/openlp/core/pluginmanager.py b/openlp/core/pluginmanager.py index 454d90db8..5bf402eb6 100644 --- a/openlp/core/pluginmanager.py +++ b/openlp/core/pluginmanager.py @@ -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 diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index cf6a51a92..89c2ac1ba 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -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 diff --git a/openlp/plugins/bibles/lib/bibleDBimpl.py b/openlp/plugins/bibles/lib/bibleDBimpl.py index 33dcd0085..d3705bf6e 100644 --- a/openlp/plugins/bibles/lib/bibleDBimpl.py +++ b/openlp/plugins/bibles/lib/bibleDBimpl.py @@ -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): diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 035328d7c..70542bdc5 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -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() diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 0fe74c06f..509c42e3c 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -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