diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 5d9111703..da01be6d1 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -481,14 +481,18 @@ class MediaManagerItem(QtGui.QWidget): log.debug(u'%s Live requested', self.plugin.name) item = None if item_id: - item = QtGui.QListWidgetItem() - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(item_id)) + item = self.createItemFromId(item_id) serviceItem = self.buildServiceItem(item) if serviceItem: if not item_id: serviceItem.from_plugin = True self.parent.liveController.addServiceItem(serviceItem) + def createItemFromId(self, item_id): + item = QtGui.QListWidgetItem() + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(item_id)) + return item + def onAddClick(self): """ Add a selected item to the current service diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index ec63dc02f..d09bc9af0 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 ############################################################################### @@ -323,7 +323,7 @@ class BibleDB(QtCore.QObject, Manager): """ return self.get_all_objects(Book, order_by_ref=Book.id) - def get_verses(self, reference_list): + def get_verses(self, reference_list, show_error=True): """ This is probably the most used function. It retrieves the list of verses based on the user's query. @@ -360,11 +360,12 @@ class BibleDB(QtCore.QObject, Manager): verse_list.extend(verses) else: log.debug(u'OpenLP failed to find book %s', book) - critical_error_message_box( - translate('BiblesPlugin', 'No Book Found'), - translate('BiblesPlugin', 'No matching book ' - 'could be found in this Bible. Check that you have ' - 'spelled the name of the book correctly.')) + if show_error: + critical_error_message_box( + translate('BiblesPlugin', 'No Book Found'), + translate('BiblesPlugin', 'No matching book ' + 'could be found in this Bible. Check that you have ' + 'spelled the name of the book correctly.')) return verse_list def verse_search(self, text): diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 6a6ef131a..d86b650d5 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -425,7 +425,7 @@ class HTTPBible(BibleDB): self.create_meta(u'proxy password', self.proxy_password) return True - def get_verses(self, reference_list): + def get_verses(self, reference_list, show_error=True): """ A reimplementation of the ``BibleDB.get_verses`` method, this one is specifically for web Bibles. It first checks to see if the particular @@ -453,11 +453,12 @@ class HTTPBible(BibleDB): if not db_book: book_details = HTTPBooks.get_book(book) if not book_details: - critical_error_message_box( - translate('BiblesPlugin', 'No Book Found'), - translate('BiblesPlugin', 'No matching ' - 'book could be found in this Bible. Check that you ' - 'have spelled the name of the book correctly.')) + if show_error: + critical_error_message_box( + translate('BiblesPlugin', 'No Book Found'), + translate('BiblesPlugin', 'No matching ' + 'book could be found in this Bible. Check that you ' + 'have spelled the name of the book correctly.')) return [] db_book = self.create_book(book_details[u'name'], book_details[u'abbreviation'], @@ -480,7 +481,7 @@ class HTTPBible(BibleDB): Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') - return BibleDB.get_verses(self, reference_list) + return BibleDB.get_verses(self, reference_list, show_error) def get_chapter(self, book, chapter): """ diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 67469e063..4299a3d89 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -231,7 +231,7 @@ class BibleManager(object): bible, book, chapter) return self.db_cache[bible].get_verse_count(book, chapter) - def get_verses(self, bible, versetext): + def get_verses(self, bible, versetext, show_error=True): """ Parses a scripture reference, fetches the verses from the Bible specified, and returns a list of ``Verse`` objects. @@ -252,32 +252,34 @@ class BibleManager(object): """ log.debug(u'BibleManager.get_verses("%s", "%s")', bible, versetext) if not bible: - Receiver.send_message(u'openlp_information_message', { - u'title': translate('BiblesPlugin.BibleManager', - 'No Bibles Available'), - u'message': translate('BiblesPlugin.BibleManager', - 'There are no Bibles currently installed. Please use the ' - 'Import Wizard to install one or more Bibles.') - }) + if show_error: + Receiver.send_message(u'openlp_information_message', { + u'title': translate('BiblesPlugin.BibleManager', + 'No Bibles Available'), + u'message': translate('BiblesPlugin.BibleManager', + 'There are no Bibles currently installed. Please use the ' + 'Import Wizard to install one or more Bibles.') + }) return None reflist = parse_reference(versetext) if reflist: - return self.db_cache[bible].get_verses(reflist) + return self.db_cache[bible].get_verses(reflist, show_error) else: - Receiver.send_message(u'openlp_information_message', { - u'title': translate('BiblesPlugin.BibleManager', - 'Scripture Reference Error'), - u'message': translate('BiblesPlugin.BibleManager', - 'Your scripture reference is either not supported by OpenLP ' - 'or is invalid. Please make sure your reference conforms to ' - 'one of the following patterns:\n\n' - 'Book Chapter\n' - 'Book Chapter-Chapter\n' - 'Book Chapter:Verse-Verse\n' - 'Book Chapter:Verse-Verse,Verse-Verse\n' - 'Book Chapter:Verse-Verse,Chapter:Verse-Verse\n' - 'Book Chapter:Verse-Chapter:Verse') - }) + if show_message: + Receiver.send_message(u'openlp_information_message', { + u'title': translate('BiblesPlugin.BibleManager', + 'Scripture Reference Error'), + u'message': translate('BiblesPlugin.BibleManager', + 'Your scripture reference is either not supported by OpenLP ' + 'or is invalid. Please make sure your reference conforms to ' + 'one of the following patterns:\n\n' + 'Book Chapter\n' + 'Book Chapter-Chapter\n' + 'Book Chapter:Verse-Verse\n' + 'Book Chapter:Verse-Verse,Verse-Verse\n' + 'Book Chapter:Verse-Verse,Chapter:Verse-Verse\n' + 'Book Chapter:Verse-Chapter:Verse') + }) return None def verse_search(self, bible, second_bible, text): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 4f349c998..a169dc401 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -590,7 +590,7 @@ class BibleMediaItem(MediaManagerItem): item_second_bible = self._decodeQtObject(bitem, 'second_bible') if item_second_bible and second_bible or not item_second_bible and \ not second_bible: - self.displayResults(bible, second_bible) + self.displayResults(bible, second_bible, self_search_results) elif critical_error_message_box( message=translate('BiblePlugin.MediaItem', 'You cannot combine single and dual Bible verse search results. ' @@ -601,6 +601,18 @@ class BibleMediaItem(MediaManagerItem): self.displayResults(bible, second_bible) def displayResults(self, bible, second_bible=u''): + """ + Displays the search results in the media manager. All data needed for + further action is saved for/in each row. + """ + items = self.buildDisplayResults(bible, second_bible, self.search_results) + for bible_verse in items: + self.listView.addItem(bible_verse) + self.listView.selectAll() + self.search_results = {} + self.second_search_results = {} + + def buildDisplayResults(self, bible, second_bible, search_results): """ Displays the search results in the media manager. All data needed for further action is saved for/in each row. @@ -620,7 +632,8 @@ class BibleMediaItem(MediaManagerItem): second_bible, u'Copyright').value second_permissions = self.parent.manager.get_meta_data( second_bible, u'Permissions').value - for count, verse in enumerate(self.search_results): + items = [] + for count, verse in enumerate(search_results): data = { 'book': QtCore.QVariant(verse.book.name), 'chapter': QtCore.QVariant(verse.chapter), @@ -652,10 +665,8 @@ class BibleMediaItem(MediaManagerItem): verse.chapter, verse_separator, verse.verse, version) bible_verse = QtGui.QListWidgetItem(bible_text) bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(data)) - self.listView.addItem(bible_verse) - self.listView.selectAll() - self.search_results = {} - self.second_search_results = {} + items.append(bible_verse) + return items def _decodeQtObject(self, bitem, key): reference = bitem.data(QtCore.Qt.UserRole) @@ -672,7 +683,10 @@ class BibleMediaItem(MediaManagerItem): service item's title. """ log.debug(u'generating slide data') - items = self.listView.selectedIndexes() + if item: + items = item + else: + items = self.listView.selectedItems() if len(items) == 0: return False bible_text = u'' @@ -681,8 +695,7 @@ class BibleMediaItem(MediaManagerItem): raw_slides = [] raw_title = [] verses = VerseReferenceList() - for item in items: - bitem = self.listView.item(item.row()) + for bitem in items: book = self._decodeQtObject(bitem, 'book') chapter = int(self._decodeQtObject(bitem, 'chapter')) verse = int(self._decodeQtObject(bitem, 'verse')) @@ -716,11 +729,11 @@ class BibleMediaItem(MediaManagerItem): else: bible_text = u'%s %s %s\n' % (bible_text, verse_text, text) if not old_item: - start_item = item - elif self.checkTitle(item, old_item): + start_item = bitem + elif self.checkTitle(bitem, old_item): raw_title.append(self.formatTitle(start_item, old_item)) - start_item = item - old_item = item + start_item = bitem + old_item = bitem old_chapter = chapter # Add footer service_item.raw_footer.append(verses.format_verses()) @@ -728,7 +741,7 @@ class BibleMediaItem(MediaManagerItem): verses.add_version(second_version, second_copyright, second_permissions) service_item.raw_footer.append(verses.format_versions()) - raw_title.append(self.formatTitle(start_item, item)) + raw_title.append(self.formatTitle(start_item, bitem)) # If there are no more items we check whether we have to add bible_text. if bible_text: raw_slides.append(bible_text.lstrip()) @@ -751,9 +764,9 @@ class BibleMediaItem(MediaManagerItem): [service_item.add_from_text(slide[:30], slide) for slide in raw_slides] return True - def formatTitle(self, start_item, old_item): + def formatTitle(self, start_bitem, old_bitem): """ - This methode is called, when we have to change the title, because + This method is called, when we have to change the title, because we are at the end of a verse range. E. g. if we want to add Genesis 1:1-6 as well as Daniel 2:14. @@ -765,10 +778,8 @@ class BibleMediaItem(MediaManagerItem): """ verse_separator = get_reference_match(u'sep_v_display') range_separator = get_reference_match(u'sep_r_display') - old_bitem = self.listView.item(old_item.row()) old_chapter = self._decodeQtObject(old_bitem, 'chapter') old_verse = self._decodeQtObject(old_bitem, 'verse') - start_bitem = self.listView.item(start_item.row()) start_book = self._decodeQtObject(start_bitem, 'book') start_chapter = self._decodeQtObject(start_bitem, 'chapter') start_verse = self._decodeQtObject(start_bitem, 'verse') @@ -789,9 +800,9 @@ class BibleMediaItem(MediaManagerItem): range_separator + old_chapter + verse_separator + old_verse return u'%s %s (%s)' % (start_book, verse_range, bibles) - def checkTitle(self, item, old_item): + def checkTitle(self, bitem, old_bitem): """ - This methode checks if we are at the end of an verse range. If that is + This method checks if we are at the end of an verse range. If that is the case, we return True, otherwise False. E. g. if we added Genesis 1:1-6, but the next verse is Daniel 2:14, we return True. @@ -802,13 +813,11 @@ class BibleMediaItem(MediaManagerItem): The item we were previously dealing with. """ # Get all the necessary meta data. - bitem = self.listView.item(item.row()) book = self._decodeQtObject(bitem, 'book') chapter = int(self._decodeQtObject(bitem, 'chapter')) verse = int(self._decodeQtObject(bitem, 'verse')) bible = self._decodeQtObject(bitem, 'bible') second_bible = self._decodeQtObject(bitem, 'second_bible') - old_bitem = self.listView.item(old_item.row()) old_book = self._decodeQtObject(old_bitem, 'book') old_chapter = int(self._decodeQtObject(old_bitem, 'chapter')) old_verse = int(self._decodeQtObject(old_bitem, 'verse')) @@ -868,3 +877,32 @@ class BibleMediaItem(MediaManagerItem): QtCore.QSettings().setValue( self.settingsSection + u'/verse layout style', QtCore.QVariant(self.settings.layout_style)) + + def hasSearch(self): + """ + Returns whether this plugin supports the search method + """ + return True + + def search(self, string): + """ + Search for some Bible verses (by reference). + """ + bible = unicode(self.quickVersionComboBox.currentText()) + search_results = self.parent.manager.get_verses(bible, string, False) + results = [] + if search_results: + versetext = u'' + for verse in search_results: + if versetext: + versetext += u' ' + versetext += verse.text + results.append([string, versetext]) + return results + + def createItemFromId(self, item_id): + item = QtGui.QListWidgetItem() + bible = unicode(self.quickVersionComboBox.currentText()) + search_results = self.parent.manager.get_verses(bible, item_id, False) + items = self.buildDisplayResults(bible, u'', search_results) + return items diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index 947b135f6..b07aaec8c 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -51,34 +51,42 @@
Back

Service Manager

-
+ Refresh +
+
+ + + + +
- Blank - Unblank - Refresh - Previous - Next + Previous Slide + Next Slide
Back

Slide Controller

+ Refresh
+ -
+
- Blank - Unblank - Refresh - Previous - Next + Previous Song + Next Song
@@ -101,8 +109,12 @@
- - + + +
+
+ +
Search