From 06cf6dcc203c47b26dcf0ea5c1e0821d47a0b3ca Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 9 Nov 2010 17:56:16 +0100 Subject: [PATCH 01/19] changed bible importer finish message, clean ups --- .../plugins/bibles/forms/bibleimportform.py | 26 +++++++++++++------ openlp/plugins/bibles/lib/http.py | 7 +++-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 2e11c30ad..9053c123e 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -168,7 +168,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): license_version = unicode(self.field(u'license_version').toString()) license_copyright = \ unicode(self.field(u'license_copyright').toString()) - if license_version == u'': + if not license_version: QtGui.QMessageBox.critical(self, translate('BiblesPlugin.ImportWizardForm', 'Empty Version Name'), @@ -176,7 +176,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): 'You need to specify a version name for your Bible.')) self.VersionNameEdit.setFocus() return False - elif license_copyright == u'': + elif not license_copyright: QtGui.QMessageBox.critical(self, translate('BiblesPlugin.ImportWizardForm', 'Empty Copyright'), @@ -317,7 +317,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): """ Load the list of Crosswalk and BibleGateway bibles. """ - #Load and store Crosswalk Bibles + # Load and store Crosswalk Bibles. filepath = AppLocation.get_directory(AppLocation.PluginsDir) filepath = os.path.join(filepath, u'bibles', u'resources') books_file = None @@ -341,7 +341,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): finally: if books_file: books_file.close() - #Load and store BibleGateway Bibles + # Load and store BibleGateway Bibles. books_file = None try: self.web_bible_list[WebDownload.BibleGateway] = {} @@ -379,12 +379,17 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): Receiver.send_message(u'openlp_process_events') def preImport(self): + bible_type = self.field(u'source_format').toInt()[0] self.finishButton.setVisible(False) self.ImportProgressBar.setMinimum(0) self.ImportProgressBar.setMaximum(1188) self.ImportProgressBar.setValue(0) - self.ImportProgressLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Starting import...')) + if bible_type == BibleFormat.WebDownload: + self.ImportProgressLabel.setText(translate( + 'BiblesPlugin.ImportWizardForm', 'Starting Registering bible...')) + else: + self.ImportProgressLabel.setText(translate( + 'BiblesPlugin.ImportWizardForm', 'Starting import...')) Receiver.send_message(u'openlp_process_events') def performImport(self): @@ -438,8 +443,13 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): self.manager.save_meta_data(license_version, license_version, license_copyright, license_permissions) self.manager.reload_bibles() - self.ImportProgressLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Finished import.')) + if bible_type == BibleFormat.WebDownload: + self.ImportProgressLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Registered ' + 'bible. Verses will be downloaded as required.')) + else: + self.ImportProgressLabel.setText(translate( + 'BiblesPlugin.ImportWizardForm', 'Finished import.')) else: self.ImportProgressLabel.setText( translate('BiblesPlugin.ImportWizardForm', diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index e6a474f5c..361525563 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -364,12 +364,11 @@ class HTTPBible(BibleDB): if self.proxy_server: self.create_meta(u'proxy server', self.proxy_server) if self.proxy_username: - # store the proxy userid + # Store the proxy userid. self.create_meta(u'proxy username', self.proxy_username) if self.proxy_password: - # store the proxy password + # Store the proxy password. self.create_meta(u'proxy password', self.proxy_password) - self.wizard.incrementProgressBar('Registered.') return True def get_verses(self, reference_list): @@ -417,7 +416,7 @@ class HTTPBible(BibleDB): ## to request ac and get Acts back. bookname = search_results.book Receiver.send_message(u'openlp_process_events') - # check to see if book/chapter exists + # Check to see if book/chapter exists. db_book = self.get_book(bookname) self.create_chapter(db_book.id, search_results.chapter, search_results.verselist) From f8b793ca3bfeaac747eab323d128407c3d751fee Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 9 Nov 2010 18:10:37 +0100 Subject: [PATCH 02/19] removed whitespaces, added second blank line before class --- openlp/plugins/bibles/lib/mediaitem.py | 1 + openlp/plugins/songs/forms/songmaintenanceform.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index bb3c1b26d..d00e94fe0 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -47,6 +47,7 @@ class BibleListView(BaseListWithDnD): self.parent().onListViewResize(event.size().width(), event.size().width()) + class BibleMediaItem(MediaManagerItem): """ This is the custom media manager item for Bibles. diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 7c13e0989..e057bb516 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -405,7 +405,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def mergeAuthors(self, old_author): """ Merges two authors into one author. - + ``old_author`` The author which will be deleted afterwards. """ @@ -427,7 +427,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def mergeTopics(self, old_topic): """ Merges two topics into one topic. - + ``old_topic`` The topic which will be deleted afterwards. """ @@ -447,7 +447,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def mergeBooks(self, old_book): """ Merges two books into one book. - + ``old_book`` The book which will be deleted afterwards. """ From 802e886e9621931505a9b0f4e311fca73e128cc0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 9 Nov 2010 18:23:18 +0100 Subject: [PATCH 03/19] removed whitespaces --- openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 9afc4a4b2..84137630f 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -267,7 +267,7 @@ class BibleManager(object): ``text`` The text to search for (unicode). """ - log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text) + log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text) if text: return self.db_cache[bible].verse_search(text) else: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index d00e94fe0..79f3fde59 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -546,7 +546,7 @@ class BibleMediaItem(MediaManagerItem): self.dual_search_results = self.parent.manager.get_verses( dual_bible, text) else: - # We are doing a ' Text Search'. + # We are doing a 'Text Search'. bibles = self.parent.manager.get_bibles() self.search_results = self.parent.manager.verse_search(bible, text) if dual_bible and self.search_results: From 45945cc3025e6c15a756c4a56730ab18fa684f8c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 12 Nov 2010 14:50:13 +0100 Subject: [PATCH 04/19] -docs/comments -disabled text mode for webbibles -"dual" instead of "second" --- openlp/plugins/bibles/lib/manager.py | 20 +++- openlp/plugins/bibles/lib/mediaitem.py | 142 +++++++++++++++++-------- 2 files changed, 115 insertions(+), 47 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 84137630f..13f96cca9 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -257,17 +257,34 @@ class BibleManager(object): 'Book Chapter:Verse-Chapter:Verse')) return None - def verse_search(self, bible, text): + def verse_search(self, bible, dual_bible, text): """ Does a verse search for the given bible and text. ``bible`` The bible to seach in (unicode). + ``dual_bible`` + The dual bible (unicode). We do not search in this bible. + ``text`` The text to search for (unicode). """ log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text) + # Check if the bible or dual_bible is a web bible. + webbible = self.db_cache[bible].get_object(BibleMeta, + u'download source') + dual_webbible = u'' + if dual_bible: + dual_webbible = self.db_cache[dual_bible].get_object(BibleMeta, + u'download source') + if webbible or dual_webbible: + QtGui.QMessageBox.information(self.parent.mediaItem, + translate('BiblesPlugin.BibleManager', + 'Web Bible cannot be used'), + translate('BiblesPlugin.BibleManager', 'You cannot use text ' + 'search with web bible.')) + return None if text: return self.db_cache[bible].verse_search(text) else: @@ -317,4 +334,3 @@ class BibleManager(object): """ for bible in self.db_cache: self.db_cache[bible].finalise() - diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 79f3fde59..6f82f6f08 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -60,7 +60,7 @@ class BibleMediaItem(MediaManagerItem): self.IconPath = u'songs/song' self.ListViewWithDnD_class = BibleListView MediaManagerItem.__init__(self, parent, icon, title) - # place to store the search results for both bibles + # Place to store the search results for both bibles. self.search_results = {} self.dual_search_results = {} QtCore.QObject.connect(Receiver.get_receiver(), @@ -100,14 +100,14 @@ class BibleMediaItem(MediaManagerItem): QtGui.QComboBox.AdjustToMinimumContentsLength) self.QuickVersionComboBox.setObjectName(u'VersionComboBox') self.QuickLayout.addWidget(self.QuickVersionComboBox, 0, 1, 1, 2) - self.QuickSecondVersionLabel = QtGui.QLabel(self.QuickTab) - self.QuickSecondVersionLabel.setObjectName(u'QuickSecondVersionLabel') - self.QuickLayout.addWidget(self.QuickSecondVersionLabel, 1, 0, 1, 1) - self.QuickSecondBibleComboBox = QtGui.QComboBox(self.QuickTab) - self.QuickSecondBibleComboBox.setSizeAdjustPolicy( + self.QuickDualVersionLabel = QtGui.QLabel(self.QuickTab) + self.QuickDualVersionLabel.setObjectName(u'QuickDualVersionLabel') + self.QuickLayout.addWidget(self.QuickDualVersionLabel, 1, 0, 1, 1) + self.QuickDualBibleComboBox = QtGui.QComboBox(self.QuickTab) + self.QuickDualBibleComboBox.setSizeAdjustPolicy( QtGui.QComboBox.AdjustToMinimumContentsLength) - self.QuickSecondBibleComboBox.setObjectName(u'SecondBible') - self.QuickLayout.addWidget(self.QuickSecondBibleComboBox, 1, 1, 1, 2) + self.QuickDualBibleComboBox.setObjectName(u'DualBible') + self.QuickLayout.addWidget(self.QuickDualBibleComboBox, 1, 1, 1, 2) self.QuickSearchLabel = QtGui.QLabel(self.QuickTab) self.QuickSearchLabel.setObjectName(u'QuickSearchLabel') self.QuickLayout.addWidget(self.QuickSearchLabel, 2, 0, 1, 1) @@ -161,16 +161,16 @@ class BibleMediaItem(MediaManagerItem): QtGui.QComboBox.AdjustToMinimumContentsLength) self.AdvancedVersionComboBox.setObjectName(u'AdvancedVersionComboBox') self.AdvancedLayout.addWidget(self.AdvancedVersionComboBox, 0, 1, 1, 2) - self.AdvancedSecondBibleLabel = QtGui.QLabel(self.AdvancedTab) - self.AdvancedSecondBibleLabel.setObjectName(u'AdvancedSecondBibleLabel') - self.AdvancedLayout.addWidget(self.AdvancedSecondBibleLabel, 1, 0, 1, 1) - self.AdvancedSecondBibleComboBox = QtGui.QComboBox(self.AdvancedTab) - self.AdvancedSecondBibleComboBox.setSizeAdjustPolicy( + self.AdvancedDualBibleLabel = QtGui.QLabel(self.AdvancedTab) + self.AdvancedDualBibleLabel.setObjectName(u'AdvancedDualBibleLabel') + self.AdvancedLayout.addWidget(self.AdvancedDualBibleLabel, 1, 0, 1, 1) + self.AdvancedDualBibleComboBox = QtGui.QComboBox(self.AdvancedTab) + self.AdvancedDualBibleComboBox.setSizeAdjustPolicy( QtGui.QComboBox.AdjustToMinimumContentsLength) - self.AdvancedSecondBibleComboBox.setObjectName( - u'AdvancedSecondBibleComboBox') + self.AdvancedDualBibleComboBox.setObjectName( + u'AdvancedDualBibleComboBox') self.AdvancedLayout.addWidget( - self.AdvancedSecondBibleComboBox, 1, 1, 1, 2) + self.AdvancedDualBibleComboBox, 1, 1, 1, 2) self.AdvancedBookLabel = QtGui.QLabel(self.AdvancedTab) self.AdvancedBookLabel.setObjectName(u'AdvancedBookLabel') self.AdvancedLayout.addWidget(self.AdvancedBookLabel, 2, 0, 1, 1) @@ -227,7 +227,7 @@ class BibleMediaItem(MediaManagerItem): self.AdvancedLayout.addWidget(self.AdvancedMessage, 8, 0, 1, 3) self.SearchTabWidget.addTab(self.AdvancedTab, translate('BiblesPlugin.MediaItem', 'Advanced')) - # Add the search tab widget to the page layout + # Add the search tab widget to the page layout. self.pageLayout.addWidget(self.SearchTabWidget) # Combo Boxes QtCore.QObject.connect(self.AdvancedVersionComboBox, @@ -273,21 +273,21 @@ class BibleMediaItem(MediaManagerItem): log.debug(u'configUpdated') if QtCore.QSettings().value(self.settingsSection + u'/dual bibles', QtCore.QVariant(True)).toBool(): - self.AdvancedSecondBibleLabel.setVisible(True) - self.AdvancedSecondBibleComboBox.setVisible(True) - self.QuickSecondVersionLabel.setVisible(True) - self.QuickSecondBibleComboBox.setVisible(True) + self.AdvancedDualBibleLabel.setVisible(True) + self.AdvancedDualBibleComboBox.setVisible(True) + self.QuickDualVersionLabel.setVisible(True) + self.QuickDualBibleComboBox.setVisible(True) else: - self.AdvancedSecondBibleLabel.setVisible(False) - self.AdvancedSecondBibleComboBox.setVisible(False) - self.QuickSecondVersionLabel.setVisible(False) - self.QuickSecondBibleComboBox.setVisible(False) + self.AdvancedDualBibleLabel.setVisible(False) + self.AdvancedDualBibleComboBox.setVisible(False) + self.QuickDualVersionLabel.setVisible(False) + self.QuickDualBibleComboBox.setVisible(False) def retranslateUi(self): log.debug(u'retranslateUi') self.QuickVersionLabel.setText( translate('BiblesPlugin.MediaItem', 'Version:')) - self.QuickSecondVersionLabel.setText( + self.QuickDualVersionLabel.setText( translate('BiblesPlugin.MediaItem', 'Dual:')) self.QuickSearchLabel.setText( translate('BiblesPlugin.MediaItem', 'Search type:')) @@ -299,7 +299,7 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'Results:')) self.AdvancedVersionLabel.setText( translate('BiblesPlugin.MediaItem', 'Version:')) - self.AdvancedSecondBibleLabel.setText( + self.AdvancedDualBibleLabel.setText( translate('BiblesPlugin.MediaItem', 'Dual:')) self.AdvancedBookLabel.setText( translate('BiblesPlugin.MediaItem', 'Book:')) @@ -339,7 +339,7 @@ class BibleMediaItem(MediaManagerItem): self.QuickMessage.setText(text) self.AdvancedMessage.setText(text) Receiver.send_message(u'openlp_process_events') - # minor delay to get the events processed + # Minor delay to get the events processed. time.sleep(0.1) def onListViewResize(self, width, height): @@ -364,26 +364,29 @@ class BibleMediaItem(MediaManagerItem): if not hasattr(self, u'import_wizard'): self.import_wizard = BibleImportForm(self, self.parent.manager, self.parent) - self.import_wizard.exec_() - self.reloadBibles() + # Do not reload if the import was canceled. + if self.import_wizard.exec_() == 1: + self.reloadBibles() def loadBibles(self): log.debug(u'Loading Bibles') self.QuickVersionComboBox.clear() - self.QuickSecondBibleComboBox.clear() + self.QuickDualBibleComboBox.clear() self.AdvancedVersionComboBox.clear() - self.AdvancedSecondBibleComboBox.clear() - self.QuickSecondBibleComboBox.addItem(u'') - self.AdvancedSecondBibleComboBox.addItem(u'') + self.AdvancedDualBibleComboBox.clear() + self.QuickDualBibleComboBox.addItem(u'') + self.AdvancedDualBibleComboBox.addItem(u'') + # Get all bibles and sort the list. bibles = self.parent.manager.get_bibles().keys() - # load bibles into the combo boxes + bibles.sort() + # Load the bibles into the combo boxes. first = True for bible in bibles: if bible: self.QuickVersionComboBox.addItem(bible) - self.QuickSecondBibleComboBox.addItem(bible) + self.QuickDualBibleComboBox.addItem(bible) self.AdvancedVersionComboBox.addItem(bible) - self.AdvancedSecondBibleComboBox.addItem(bible) + self.AdvancedDualBibleComboBox.addItem(bible) if first: first = False self.initialiseBible(bible) @@ -483,6 +486,17 @@ class BibleMediaItem(MediaManagerItem): def adjustComboBox(self, range_from, range_to, combo, restore=False): """ + Adjusts the give como boxe to the given values. + + ``range_from`` + The first number of the range (int). + + ``range_to`` + The last number of the range (int). + + ``combo`` + The combo box itself (QComboBox). + ``restore`` If True, then the combo's currentText will be restored after adjusting (if possible). @@ -491,16 +505,19 @@ class BibleMediaItem(MediaManagerItem): if restore: old_text = unicode(combo.currentText()) combo.clear() - for i in range(int(range_from), int(range_to) + 1): + for i in range(range_from, range_to + 1): combo.addItem(unicode(i)) if restore and combo.findText(old_text) != -1: combo.setCurrentIndex(combo.findText(old_text)) def onAdvancedSearchButton(self): + """ + Does an advanced search and saves the search reasults + """ log.debug(u'Advanced Search Button pressed') self.AdvancedSearchButton.setEnabled(False) bible = unicode(self.AdvancedVersionComboBox.currentText()) - dual_bible = unicode(self.AdvancedSecondBibleComboBox.currentText()) + dual_bible = unicode(self.AdvancedDualBibleComboBox.currentText()) book = unicode(self.AdvancedBookComboBox.currentText()) chapter_from = int(self.AdvancedFromChapter.currentText()) chapter_to = int(self.AdvancedToChapter.currentText()) @@ -537,7 +554,7 @@ class BibleMediaItem(MediaManagerItem): log.debug(u'Quick Search Button pressed') self.QuickSearchButton.setEnabled(False) bible = unicode(self.QuickVersionComboBox.currentText()) - dual_bible = unicode(self.QuickSecondBibleComboBox.currentText()) + dual_bible = unicode(self.QuickDualBibleComboBox.currentText()) text = unicode(self.QuickSearchEdit.text()) if self.QuickSearchComboBox.currentIndex() == 0: # We are doing a 'Verse Search'. @@ -548,7 +565,8 @@ class BibleMediaItem(MediaManagerItem): else: # We are doing a 'Text Search'. bibles = self.parent.manager.get_bibles() - self.search_results = self.parent.manager.verse_search(bible, text) + self.search_results = self.parent.manager.verse_search(bible, + dual_bible, text) if dual_bible and self.search_results: text = [] for verse in self.search_results: @@ -632,7 +650,7 @@ class BibleMediaItem(MediaManagerItem): 'dual_permissions': QtCore.QVariant(u''), 'dual_text': QtCore.QVariant(u'') } - bible_text = u' %s %d:%d (%s)' % (verse.book.name, + bible_text = u'%s %d:%d (%s)' % (verse.book.name, verse.chapter, verse.verse, version.value) bible_verse = QtGui.QListWidgetItem(bible_text) bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(vdict)) @@ -662,7 +680,7 @@ class BibleMediaItem(MediaManagerItem): if len(items) == 0: return False bible_text = u'' - old_chapter = u'' + old_chapter = -1 raw_footer = [] raw_slides = [] raw_title = [] @@ -750,6 +768,12 @@ class BibleMediaItem(MediaManagerItem): This methode 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. + + ``start_item`` + The first item of a range. + + ``old_item`` + The last item of a range. """ old_bitem = self.listView.item(old_item.row()) old_chapter = int(self._decodeQtObject(old_bitem, 'chapter')) @@ -786,9 +810,16 @@ class BibleMediaItem(MediaManagerItem): def checkTitle(self, item, old_item): """ This methode checks if we are at the end of an verse range. If that is - the case, we return True, else False. E. g. if we added Genesis 1:1-6, - but the next verse is Daniel 2:14. + 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. + + ``item`` + The item we are dealing with at the moment. + + ``old_item`` + 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')) @@ -803,17 +834,38 @@ class BibleMediaItem(MediaManagerItem): old_dual_bible = self._decodeQtObject(old_bitem, 'dual_bible') if old_bible != bible or old_dual_bible != dual_bible or \ old_book != book: + # The bible, dual bible or book has changed. return True elif old_verse + 1 != verse and old_chapter == chapter: + # We are still in the same chapter, but a verse has been skipped. return True elif old_chapter + 1 == chapter and (verse != 1 or old_verse != self.parent.manager.get_verse_count( old_bible, old_book, old_chapter)): + # We are in the following chapter, but the last verse was not the + # last verse of the previous chapter or the current verse is not the + # first one of a chapter. return True else: return False def formatVerse(self, old_chapter, chapter, verse): + """ + Formats and returns the text, each verse starts with, for the given + chapter and verse. The text is either surrounded by round, square, + curly brackets or no brackets at all. For example:: + + u'{su}1:1{/su}' + + ``old_chapter`` + The previous verse's chapter number (int). + + ``chapter`` + The chapter number (int). + + ``verse`` + The verse number (int). + """ if not self.parent.settings_tab.show_new_chapters or \ old_chapter != chapter: verse_text = u'%s:%s' % (chapter, verse) From b34bb86b7c23b79442075af20fdd760650920fe7 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 12 Nov 2010 18:54:34 +0100 Subject: [PATCH 05/19] spelling --- openlp/plugins/bibles/lib/mediaitem.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 6f82f6f08..535ba30cf 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -364,7 +364,7 @@ class BibleMediaItem(MediaManagerItem): if not hasattr(self, u'import_wizard'): self.import_wizard = BibleImportForm(self, self.parent.manager, self.parent) - # Do not reload if the import was canceled. + # If the import was not canceled then reload. if self.import_wizard.exec_() == 1: self.reloadBibles() @@ -486,7 +486,7 @@ class BibleMediaItem(MediaManagerItem): def adjustComboBox(self, range_from, range_to, combo, restore=False): """ - Adjusts the give como boxe to the given values. + Adjusts the given como box to the given values. ``range_from`` The first number of the range (int). @@ -512,7 +512,7 @@ class BibleMediaItem(MediaManagerItem): def onAdvancedSearchButton(self): """ - Does an advanced search and saves the search reasults + Does an advanced search and saves the search results. """ log.debug(u'Advanced Search Button pressed') self.AdvancedSearchButton.setEnabled(False) @@ -843,8 +843,8 @@ class BibleMediaItem(MediaManagerItem): old_verse != self.parent.manager.get_verse_count( old_bible, old_book, old_chapter)): # We are in the following chapter, but the last verse was not the - # last verse of the previous chapter or the current verse is not the - # first one of a chapter. + # last verse of the chapter or the current verse is not the + # first one of the chapter. return True else: return False From 46321741adba557e71b3cfb251514beb27bcda84 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 12 Nov 2010 22:34:06 +0100 Subject: [PATCH 06/19] make sure, that the bible list in the importer is sorted --- .../plugins/bibles/forms/bibleimportform.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 9053c123e..75fc9e82e 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -207,9 +207,11 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): The index of the combo box. """ self.BibleComboBox.clear() - for bible in self.web_bible_list[index].keys(): - self.BibleComboBox.addItem(unicode( - translate('BiblesPlugin.ImportWizardForm', bible))) + bibles = [unicode(translate('BiblesPlugin.ImportWizardForm', bible)) for + bible in self.web_bible_list[index].keys()] + bibles.sort() + for bible in bibles: + self.BibleComboBox.addItem(bible) def onOsisFileButtonClicked(self): """ @@ -386,7 +388,8 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): self.ImportProgressBar.setValue(0) if bible_type == BibleFormat.WebDownload: self.ImportProgressLabel.setText(translate( - 'BiblesPlugin.ImportWizardForm', 'Starting Registering bible...')) + 'BiblesPlugin.ImportWizardForm', + 'Starting Registering bible...')) else: self.ImportProgressLabel.setText(translate( 'BiblesPlugin.ImportWizardForm', 'Starting import...')) @@ -400,26 +403,26 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): unicode(self.field(u'license_permissions').toString()) importer = None if bible_type == BibleFormat.OSIS: - # Import an OSIS bible + # Import an OSIS bible. importer = self.manager.import_bible(BibleFormat.OSIS, name=license_version, filename=unicode(self.field(u'osis_location').toString()) ) elif bible_type == BibleFormat.CSV: - # Import a CSV bible + # Import a CSV bible. importer = self.manager.import_bible(BibleFormat.CSV, name=license_version, booksfile=unicode(self.field(u'csv_booksfile').toString()), versefile=unicode(self.field(u'csv_versefile').toString()) ) elif bible_type == BibleFormat.OpenSong: - # Import an OpenSong bible + # Import an OpenSong bible. importer = self.manager.import_bible(BibleFormat.OpenSong, name=license_version, filename=unicode(self.field(u'opensong_file').toString()) ) elif bible_type == BibleFormat.WebDownload: - # Import a bible from the web + # Import a bible from the web. self.ImportProgressBar.setMaximum(1) download_location = self.field(u'web_location').toInt()[0] bible_version = unicode(self.BibleComboBox.currentText()) From a0bbe7671710ebbc0fcbe768499c11524622e754 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 12 Nov 2010 22:51:18 +0100 Subject: [PATCH 07/19] comments/missing lines --- openlp/plugins/bibles/lib/db.py | 4 ++++ openlp/plugins/bibles/lib/mediaitem.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 8f5c7dc79..b8ddc4bb0 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -44,24 +44,28 @@ class BibleMeta(BaseModel): """ pass + class Testament(BaseModel): """ Bible Testaments """ pass + class Book(BaseModel): """ Song model """ pass + class Verse(BaseModel): """ Topic model """ pass + def init_schema(url): """ Setup a bible database connection and initialise the database schema. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 535ba30cf..fe6c786d7 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -84,7 +84,7 @@ class BibleMediaItem(MediaManagerItem): self.SearchTabWidget.sizePolicy().hasHeightForWidth()) self.SearchTabWidget.setSizePolicy(sizePolicy) self.SearchTabWidget.setObjectName(u'SearchTabWidget') - # Add the Quick Search tab + # Add the Quick Search tab. self.QuickTab = QtGui.QWidget() self.QuickTab.setObjectName(u'QuickTab') self.QuickLayout = QtGui.QGridLayout(self.QuickTab) @@ -145,7 +145,7 @@ class BibleMediaItem(MediaManagerItem): QuickSpacerItem = QtGui.QSpacerItem(20, 35, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.QuickLayout.addItem(QuickSpacerItem, 6, 2, 1, 1) - # Add the Advanced Search tab + # Add the Advanced Search tab. self.AdvancedTab = QtGui.QWidget() self.AdvancedTab.setObjectName(u'AdvancedTab') self.AdvancedLayout = QtGui.QGridLayout(self.AdvancedTab) From 093dc1afcaf7a125181426592ae0557cecc441e9 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 12 Nov 2010 23:02:25 +0100 Subject: [PATCH 08/19] make sure that the theme list (in the settings are sorted), docs/comments --- openlp/core/ui/themestab.py | 10 ++++++++-- openlp/plugins/bibles/lib/biblestab.py | 14 ++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 853865bb5..5ee36e174 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -183,13 +183,19 @@ class ThemesTab(SettingsTab): def updateThemeList(self, theme_list): """ - Called from ThemeManager when the Themes have changed + Called from ThemeManager when the Themes have changed. + + ``theme_list`` + The list of available themes:: + + [u'Song Theme', u'Bible Theme'] """ - #reload as may have been triggered by the ThemeManager + # Reload as may have been triggered by the ThemeManager. self.global_theme = unicode(QtCore.QSettings().value( self.settingsSection + u'/global theme', QtCore.QVariant(u'')).toString()) self.DefaultComboBox.clear() + theme_list.sort() for theme in theme_list: self.DefaultComboBox.addItem(theme) id = self.DefaultComboBox.findText( diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index b7d1b9bde..5546a2ccc 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -190,13 +190,13 @@ class BiblesTab(SettingsTab): def onNewChaptersCheckBoxChanged(self, check_state): self.show_new_chapters = False - # we have a set value convert to True/False + # We have a set value convert to True/False. if check_state == QtCore.Qt.Checked: self.show_new_chapters = True def onBibleDualCheckBox(self, check_state): self.dual_bibles = False - # we have a set value convert to True/False + # We have a set value convert to True/False. if check_state == QtCore.Qt.Checked: self.dual_bibles = True @@ -234,16 +234,22 @@ class BiblesTab(SettingsTab): def updateThemeList(self, theme_list): """ - Called from ThemeManager when the Themes have changed + Called from ThemeManager when the Themes have changed. + + ``theme_list`` + The list of available themes:: + + [u'Song Theme', u'Bible Theme'] """ self.BibleThemeComboBox.clear() self.BibleThemeComboBox.addItem(u'') + theme_list.sort() for theme in theme_list: self.BibleThemeComboBox.addItem(theme) index = self.BibleThemeComboBox.findText( unicode(self.bible_theme), QtCore.Qt.MatchExactly) if index == -1: - # Not Found + # Not Found. index = 0 self.bible_theme = u'' self.BibleThemeComboBox.setCurrentIndex(index) From 38397f07a2af3de26889960eeb8b6692b3d2e4f3 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 12 Nov 2010 23:27:57 +0100 Subject: [PATCH 09/19] changed texts again --- openlp/plugins/bibles/forms/bibleimportform.py | 9 +++++---- openlp/plugins/bibles/lib/manager.py | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 75fc9e82e..749f1f938 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -133,7 +133,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): self.OSISLocationEdit.setFocus() return False elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: - if self.field(u'csv_booksfile').toString() == u'': + if not self.field(u'csv_booksfile').toString(): QtGui.QMessageBox.critical(self, translate('BiblesPlugin.ImportWizardForm', 'Invalid Books File'), @@ -142,7 +142,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): 'the Bible to use in the import.')) self.BooksLocationEdit.setFocus() return False - elif self.field(u'csv_versefile').toString() == u'': + elif not self.field(u'csv_versefile').toString(): QtGui.QMessageBox.critical(self, translate('BiblesPlugin.ImportWizardForm', 'Invalid Verse File'), @@ -153,7 +153,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): return False elif self.field(u'source_format').toInt()[0] == \ BibleFormat.OpenSong: - if self.field(u'opensong_file').toString() == u'': + if not self.field(u'opensong_file').toString(): QtGui.QMessageBox.critical(self, translate('BiblesPlugin.ImportWizardForm', 'Invalid OpenSong Bible'), @@ -449,7 +449,8 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): if bible_type == BibleFormat.WebDownload: self.ImportProgressLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Registered ' - 'bible. Verses will be downloaded as required.')) + 'bible. Please note, that verses will be downloaded on\n' + 'demand and thus an internet connection is required.')) else: self.ImportProgressLabel.setText(translate( 'BiblesPlugin.ImportWizardForm', 'Finished import.')) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 13f96cca9..2f468d01c 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -282,8 +282,8 @@ class BibleManager(object): QtGui.QMessageBox.information(self.parent.mediaItem, translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'), - translate('BiblesPlugin.BibleManager', 'You cannot use text ' - 'search with web bible.')) + translate('BiblesPlugin.BibleManager', 'Text Search is not ' + 'available with Web Bibles.')) return None if text: return self.db_cache[bible].verse_search(text) From 272eea72b7f06e20622f06882708b4faa9937681 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 13 Nov 2010 08:17:39 +0100 Subject: [PATCH 10/19] removed theme sorting --- openlp/core/ui/themestab.py | 1 - openlp/plugins/bibles/lib/biblestab.py | 1 - 2 files changed, 2 deletions(-) diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 5ee36e174..5a2bd2b15 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -195,7 +195,6 @@ class ThemesTab(SettingsTab): self.settingsSection + u'/global theme', QtCore.QVariant(u'')).toString()) self.DefaultComboBox.clear() - theme_list.sort() for theme in theme_list: self.DefaultComboBox.addItem(theme) id = self.DefaultComboBox.findText( diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 5546a2ccc..225fc9c47 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -243,7 +243,6 @@ class BiblesTab(SettingsTab): """ self.BibleThemeComboBox.clear() self.BibleThemeComboBox.addItem(u'') - theme_list.sort() for theme in theme_list: self.BibleThemeComboBox.addItem(theme) index = self.BibleThemeComboBox.findText( From a357bdf6a0318a4f595fcbdaffbb9462b90fb7b1 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 13 Nov 2010 21:13:24 +0100 Subject: [PATCH 11/19] improved performance --- openlp/core/ui/themestab.py | 2 +- openlp/plugins/bibles/lib/biblestab.py | 2 +- openlp/plugins/bibles/lib/db.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 7 ++----- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 5a2bd2b15..fe1f95aee 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -188,7 +188,7 @@ class ThemesTab(SettingsTab): ``theme_list`` The list of available themes:: - [u'Song Theme', u'Bible Theme'] + [u'Bible Theme', u'Song Theme'] """ # Reload as may have been triggered by the ThemeManager. self.global_theme = unicode(QtCore.QSettings().value( diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 225fc9c47..10c7fbe3b 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -239,7 +239,7 @@ class BiblesTab(SettingsTab): ``theme_list`` The list of available themes:: - [u'Song Theme', u'Bible Theme'] + [u'Bible Theme', u'Song Theme'] """ self.BibleThemeComboBox.clear() self.BibleThemeComboBox.addItem(u'') diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index b8ddc4bb0..9852ed16b 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -244,7 +244,7 @@ class BibleDB(QtCore.QObject, Manager): and the value is the verse text. """ log.debug(u'create_chapter %s,%s', book_id, chapter) - # text list has book and chapter as first two elements of the array + # Text list has book and chapter as first two elements of the array. for verse_number, verse_text in textlist.iteritems(): verse = Verse.populate( book_id = book_id, diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index fe6c786d7..596059255 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -532,6 +532,7 @@ class BibleMediaItem(MediaManagerItem): if self.ClearAdvancedSearchComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0: + # Check if the first item is a dual bible item or not. bitem = self.listView.item(0) item_dual_bible = self._decodeQtObject(bitem, 'dual_bible') if item_dual_bible and dual_bible or not item_dual_bible and \ @@ -611,8 +612,6 @@ class BibleMediaItem(MediaManagerItem): u'Permissions') if not dual_permissions: dual_permissions = u'' - # We count the number of rows which are maybe already present. - start_count = self.listView.count() for count, verse in enumerate(self.search_results): if dual_bible: vdict = { @@ -655,9 +654,7 @@ class BibleMediaItem(MediaManagerItem): bible_verse = QtGui.QListWidgetItem(bible_text) bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(vdict)) self.listView.addItem(bible_verse) - row = self.listView.setCurrentRow(count + start_count) - if row: - row.setSelected(True) + self.listView.selectAll() self.search_results = {} self.dual_search_results = {} From 80721aad3598545ab6ec9dc3cd48159a08e468cc Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 15 Nov 2010 18:47:33 +0100 Subject: [PATCH 12/19] replaced 'dual' --- openlp/plugins/bibles/lib/biblestab.py | 28 ++-- openlp/plugins/bibles/lib/manager.py | 16 +- openlp/plugins/bibles/lib/mediaitem.py | 202 ++++++++++++------------- 3 files changed, 123 insertions(+), 123 deletions(-) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 10c7fbe3b..a52c31fb7 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -110,9 +110,9 @@ class BiblesTab(SettingsTab): self.BibleThemeComboBox.setObjectName(u'BibleThemeComboBox') self.BibleThemeComboBox.addItem(QtCore.QString()) self.BibleThemeLayout.addWidget(self.BibleThemeComboBox) - self.BibleDualCheckBox = QtGui.QCheckBox(self.VerseDisplayGroupBox) - self.BibleDualCheckBox.setObjectName(u'BibleDualCheckBox') - self.VerseDisplayLayout.addWidget(self.BibleDualCheckBox, 3, 0, 1, 1) + self.BibleSecondCheckBox = QtGui.QCheckBox(self.VerseDisplayGroupBox) + self.BibleSecondCheckBox.setObjectName(u'BibleSecondCheckBox') + self.VerseDisplayLayout.addWidget(self.BibleSecondCheckBox, 3, 0, 1, 1) self.VerseDisplayLayout.addWidget(self.BibleThemeWidget, 4, 0, 1, 1) self.ChangeNoteLabel = QtGui.QLabel(self.VerseDisplayGroupBox) self.ChangeNoteLabel.setObjectName(u'ChangeNoteLabel') @@ -143,8 +143,8 @@ class BiblesTab(SettingsTab): self.LayoutStyleComboBox, QtCore.SIGNAL(u'activated(int)'), self.onLayoutStyleComboBoxChanged) QtCore.QObject.connect( - self.BibleDualCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), - self.onBibleDualCheckBox) + self.BibleSecondCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), + self.onBibleSecondCheckBox) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) @@ -176,8 +176,8 @@ class BiblesTab(SettingsTab): translate('BiblesPlugin.BiblesTab', '[ And ]')) self.ChangeNoteLabel.setText(translate('BiblesPlugin.BiblesTab', 'Note:\nChanges do not affect verses already in the service.')) - self.BibleDualCheckBox.setText( - translate('BiblesPlugin.BiblesTab', 'Display dual Bible verses')) + self.BibleSecondCheckBox.setText( + translate('BiblesPlugin.BiblesTab', 'Display second Bible verses')) def onBibleThemeComboBoxChanged(self): self.bible_theme = self.BibleThemeComboBox.currentText() @@ -194,11 +194,11 @@ class BiblesTab(SettingsTab): if check_state == QtCore.Qt.Checked: self.show_new_chapters = True - def onBibleDualCheckBox(self, check_state): - self.dual_bibles = False + def onBibleSecondCheckBox(self, check_state): + self.second_bibles = False # We have a set value convert to True/False. if check_state == QtCore.Qt.Checked: - self.dual_bibles = True + self.second_bibles = True def load(self): settings = QtCore.QSettings() @@ -211,12 +211,12 @@ class BiblesTab(SettingsTab): u'verse layout style', QtCore.QVariant(0)).toInt()[0] self.bible_theme = unicode( settings.value(u'bible theme', QtCore.QVariant(u'')).toString()) - self.dual_bibles = settings.value( - u'dual bibles', QtCore.QVariant(True)).toBool() + self.second_bibles = settings.value( + u'second bibles', QtCore.QVariant(True)).toBool() self.NewChaptersCheckBox.setChecked(self.show_new_chapters) self.DisplayStyleComboBox.setCurrentIndex(self.display_style) self.LayoutStyleComboBox.setCurrentIndex(self.layout_style) - self.BibleDualCheckBox.setChecked(self.dual_bibles) + self.BibleSecondCheckBox.setChecked(self.second_bibles) settings.endGroup() def save(self): @@ -228,7 +228,7 @@ class BiblesTab(SettingsTab): QtCore.QVariant(self.display_style)) settings.setValue(u'verse layout style', QtCore.QVariant(self.layout_style)) - settings.setValue(u'dual bibles', QtCore.QVariant(self.dual_bibles)) + settings.setValue(u'second bibles', QtCore.QVariant(self.second_bibles)) settings.setValue(u'bible theme', QtCore.QVariant(self.bible_theme)) settings.endGroup() diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 2f468d01c..6b4d7c800 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -257,28 +257,28 @@ class BibleManager(object): 'Book Chapter:Verse-Chapter:Verse')) return None - def verse_search(self, bible, dual_bible, text): + def verse_search(self, bible, second_bible, text): """ Does a verse search for the given bible and text. ``bible`` The bible to seach in (unicode). - ``dual_bible`` - The dual bible (unicode). We do not search in this bible. + ``second_bible`` + The second bible (unicode). We do not search in this bible. ``text`` The text to search for (unicode). """ log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text) - # Check if the bible or dual_bible is a web bible. + # Check if the bible or second_bible is a web bible. webbible = self.db_cache[bible].get_object(BibleMeta, u'download source') - dual_webbible = u'' - if dual_bible: - dual_webbible = self.db_cache[dual_bible].get_object(BibleMeta, + second_webbible = u'' + if second_bible: + second_webbible = self.db_cache[second_bible].get_object(BibleMeta, u'download source') - if webbible or dual_webbible: + if webbible or second_webbible: QtGui.QMessageBox.information(self.parent.mediaItem, translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'), diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 596059255..4ef4c0eff 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -62,7 +62,7 @@ class BibleMediaItem(MediaManagerItem): MediaManagerItem.__init__(self, parent, icon, title) # Place to store the search results for both bibles. self.search_results = {} - self.dual_search_results = {} + self.second_search_results = {} QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles) @@ -100,14 +100,14 @@ class BibleMediaItem(MediaManagerItem): QtGui.QComboBox.AdjustToMinimumContentsLength) self.QuickVersionComboBox.setObjectName(u'VersionComboBox') self.QuickLayout.addWidget(self.QuickVersionComboBox, 0, 1, 1, 2) - self.QuickDualVersionLabel = QtGui.QLabel(self.QuickTab) - self.QuickDualVersionLabel.setObjectName(u'QuickDualVersionLabel') - self.QuickLayout.addWidget(self.QuickDualVersionLabel, 1, 0, 1, 1) - self.QuickDualBibleComboBox = QtGui.QComboBox(self.QuickTab) - self.QuickDualBibleComboBox.setSizeAdjustPolicy( + self.QuickSecondVersionLabel = QtGui.QLabel(self.QuickTab) + self.QuickSecondVersionLabel.setObjectName(u'QuickSecondVersionLabel') + self.QuickLayout.addWidget(self.QuickSecondVersionLabel, 1, 0, 1, 1) + self.QuickSecondBibleComboBox = QtGui.QComboBox(self.QuickTab) + self.QuickSecondBibleComboBox.setSizeAdjustPolicy( QtGui.QComboBox.AdjustToMinimumContentsLength) - self.QuickDualBibleComboBox.setObjectName(u'DualBible') - self.QuickLayout.addWidget(self.QuickDualBibleComboBox, 1, 1, 1, 2) + self.QuickSecondBibleComboBox.setObjectName(u'SecondBible') + self.QuickLayout.addWidget(self.QuickSecondBibleComboBox, 1, 1, 1, 2) self.QuickSearchLabel = QtGui.QLabel(self.QuickTab) self.QuickSearchLabel.setObjectName(u'QuickSearchLabel') self.QuickLayout.addWidget(self.QuickSearchLabel, 2, 0, 1, 1) @@ -161,16 +161,16 @@ class BibleMediaItem(MediaManagerItem): QtGui.QComboBox.AdjustToMinimumContentsLength) self.AdvancedVersionComboBox.setObjectName(u'AdvancedVersionComboBox') self.AdvancedLayout.addWidget(self.AdvancedVersionComboBox, 0, 1, 1, 2) - self.AdvancedDualBibleLabel = QtGui.QLabel(self.AdvancedTab) - self.AdvancedDualBibleLabel.setObjectName(u'AdvancedDualBibleLabel') - self.AdvancedLayout.addWidget(self.AdvancedDualBibleLabel, 1, 0, 1, 1) - self.AdvancedDualBibleComboBox = QtGui.QComboBox(self.AdvancedTab) - self.AdvancedDualBibleComboBox.setSizeAdjustPolicy( + self.AdvancedSecondBibleLabel = QtGui.QLabel(self.AdvancedTab) + self.AdvancedSecondBibleLabel.setObjectName(u'AdvancedSecondBibleLabel') + self.AdvancedLayout.addWidget(self.AdvancedSecondBibleLabel, 1, 0, 1, 1) + self.AdvancedSecondBibleComboBox = QtGui.QComboBox(self.AdvancedTab) + self.AdvancedSecondBibleComboBox.setSizeAdjustPolicy( QtGui.QComboBox.AdjustToMinimumContentsLength) - self.AdvancedDualBibleComboBox.setObjectName( - u'AdvancedDualBibleComboBox') + self.AdvancedSecondBibleComboBox.setObjectName( + u'AdvancedSecondBibleComboBox') self.AdvancedLayout.addWidget( - self.AdvancedDualBibleComboBox, 1, 1, 1, 2) + self.AdvancedSecondBibleComboBox, 1, 1, 1, 2) self.AdvancedBookLabel = QtGui.QLabel(self.AdvancedTab) self.AdvancedBookLabel.setObjectName(u'AdvancedBookLabel') self.AdvancedLayout.addWidget(self.AdvancedBookLabel, 2, 0, 1, 1) @@ -271,24 +271,24 @@ class BibleMediaItem(MediaManagerItem): def configUpdated(self): log.debug(u'configUpdated') - if QtCore.QSettings().value(self.settingsSection + u'/dual bibles', + if QtCore.QSettings().value(self.settingsSection + u'/second bibles', QtCore.QVariant(True)).toBool(): - self.AdvancedDualBibleLabel.setVisible(True) - self.AdvancedDualBibleComboBox.setVisible(True) - self.QuickDualVersionLabel.setVisible(True) - self.QuickDualBibleComboBox.setVisible(True) + self.AdvancedSecondBibleLabel.setVisible(True) + self.AdvancedSecondBibleComboBox.setVisible(True) + self.QuickSecondVersionLabel.setVisible(True) + self.QuickSecondBibleComboBox.setVisible(True) else: - self.AdvancedDualBibleLabel.setVisible(False) - self.AdvancedDualBibleComboBox.setVisible(False) - self.QuickDualVersionLabel.setVisible(False) - self.QuickDualBibleComboBox.setVisible(False) + self.AdvancedSecondBibleLabel.setVisible(False) + self.AdvancedSecondBibleComboBox.setVisible(False) + self.QuickSecondVersionLabel.setVisible(False) + self.QuickSecondBibleComboBox.setVisible(False) def retranslateUi(self): log.debug(u'retranslateUi') self.QuickVersionLabel.setText( translate('BiblesPlugin.MediaItem', 'Version:')) - self.QuickDualVersionLabel.setText( - translate('BiblesPlugin.MediaItem', 'Dual:')) + self.QuickSecondVersionLabel.setText( + translate('BiblesPlugin.MediaItem', 'Second:')) self.QuickSearchLabel.setText( translate('BiblesPlugin.MediaItem', 'Search type:')) self.QuickSearchLabel.setText( @@ -299,8 +299,8 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'Results:')) self.AdvancedVersionLabel.setText( translate('BiblesPlugin.MediaItem', 'Version:')) - self.AdvancedDualBibleLabel.setText( - translate('BiblesPlugin.MediaItem', 'Dual:')) + self.AdvancedSecondBibleLabel.setText( + translate('BiblesPlugin.MediaItem', 'Second:')) self.AdvancedBookLabel.setText( translate('BiblesPlugin.MediaItem', 'Book:')) self.AdvancedChapterLabel.setText( @@ -371,11 +371,11 @@ class BibleMediaItem(MediaManagerItem): def loadBibles(self): log.debug(u'Loading Bibles') self.QuickVersionComboBox.clear() - self.QuickDualBibleComboBox.clear() + self.QuickSecondBibleComboBox.clear() self.AdvancedVersionComboBox.clear() - self.AdvancedDualBibleComboBox.clear() - self.QuickDualBibleComboBox.addItem(u'') - self.AdvancedDualBibleComboBox.addItem(u'') + self.AdvancedSecondBibleComboBox.clear() + self.QuickSecondBibleComboBox.addItem(u'') + self.AdvancedSecondBibleComboBox.addItem(u'') # Get all bibles and sort the list. bibles = self.parent.manager.get_bibles().keys() bibles.sort() @@ -384,9 +384,9 @@ class BibleMediaItem(MediaManagerItem): for bible in bibles: if bible: self.QuickVersionComboBox.addItem(bible) - self.QuickDualBibleComboBox.addItem(bible) + self.QuickSecondBibleComboBox.addItem(bible) self.AdvancedVersionComboBox.addItem(bible) - self.AdvancedDualBibleComboBox.addItem(bible) + self.AdvancedSecondBibleComboBox.addItem(bible) if first: first = False self.initialiseBible(bible) @@ -517,7 +517,7 @@ class BibleMediaItem(MediaManagerItem): log.debug(u'Advanced Search Button pressed') self.AdvancedSearchButton.setEnabled(False) bible = unicode(self.AdvancedVersionComboBox.currentText()) - dual_bible = unicode(self.AdvancedDualBibleComboBox.currentText()) + second_bible = unicode(self.AdvancedSecondBibleComboBox.currentText()) book = unicode(self.AdvancedBookComboBox.currentText()) chapter_from = int(self.AdvancedFromChapter.currentText()) chapter_to = int(self.AdvancedToChapter.currentText()) @@ -526,76 +526,76 @@ class BibleMediaItem(MediaManagerItem): versetext = u'%s %s:%s-%s:%s' % (book, chapter_from, verse_from, chapter_to, verse_to) self.search_results = self.parent.manager.get_verses(bible, versetext) - if dual_bible: - self.dual_search_results = self.parent.manager.get_verses( - dual_bible, versetext) + if second_bible: + self.second_search_results = self.parent.manager.get_verses( + second_bible, versetext) if self.ClearAdvancedSearchComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0: - # Check if the first item is a dual bible item or not. + # Check if the first item is a second bible item or not. bitem = self.listView.item(0) - item_dual_bible = self._decodeQtObject(bitem, 'dual_bible') - if item_dual_bible and dual_bible or not item_dual_bible and \ - not dual_bible: - self.displayResults(bible, dual_bible) + 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) elif QtGui.QMessageBox.critical(self, translate('BiblePlugin.MediaItem', 'Error'), translate('BiblePlugin.MediaItem', 'You cannot combine single ' - 'and dual bible verses. Do you want to delete your search ' + 'and second bible verses. Do you want to delete your search ' 'results and start a new search?'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: self.listView.clear() - self.displayResults(bible, dual_bible) + self.displayResults(bible, second_bible) else: - self.displayResults(bible, dual_bible) + self.displayResults(bible, second_bible) self.AdvancedSearchButton.setEnabled(True) def onQuickSearchButton(self): log.debug(u'Quick Search Button pressed') self.QuickSearchButton.setEnabled(False) bible = unicode(self.QuickVersionComboBox.currentText()) - dual_bible = unicode(self.QuickDualBibleComboBox.currentText()) + second_bible = unicode(self.QuickSecondBibleComboBox.currentText()) text = unicode(self.QuickSearchEdit.text()) if self.QuickSearchComboBox.currentIndex() == 0: # We are doing a 'Verse Search'. self.search_results = self.parent.manager.get_verses(bible, text) - if dual_bible and self.search_results: - self.dual_search_results = self.parent.manager.get_verses( - dual_bible, text) + if second_bible and self.search_results: + self.second_search_results = self.parent.manager.get_verses( + second_bible, text) else: # We are doing a 'Text Search'. bibles = self.parent.manager.get_bibles() self.search_results = self.parent.manager.verse_search(bible, - dual_bible, text) - if dual_bible and self.search_results: + second_bible, text) + if second_bible and self.search_results: text = [] for verse in self.search_results: text.append((verse.book.name, verse.chapter, verse.verse, verse.verse)) - self.dual_search_results = bibles[dual_bible].get_verses(text) + self.second_search_results = bibles[second_bible].get_verses(text) if self.ClearQuickSearchComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0 and self.search_results: bitem = self.listView.item(0) - item_dual_bible = self._decodeQtObject(bitem, 'dual_bible') - if item_dual_bible and dual_bible or not item_dual_bible and \ - not dual_bible: - self.displayResults(bible, dual_bible) + 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) elif QtGui.QMessageBox.critical(self, translate('BiblePlugin.MediaItem', 'Error'), translate('BiblePlugin.MediaItem', 'You cannot combine single ' - 'and dual bible verses. Do you want to delete your search ' + 'and second bible verses. Do you want to delete your search ' 'results and start a new search?'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: self.listView.clear() - self.displayResults(bible, dual_bible) + self.displayResults(bible, second_bible) elif self.search_results: - self.displayResults(bible, dual_bible) + self.displayResults(bible, second_bible) self.QuickSearchButton.setEnabled(True) - def displayResults(self, bible, dual_bible=u''): + 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. @@ -603,17 +603,17 @@ class BibleMediaItem(MediaManagerItem): version = self.parent.manager.get_meta_data(bible, u'Version') copyright = self.parent.manager.get_meta_data(bible, u'Copyright') permissions = self.parent.manager.get_meta_data(bible, u'Permissions') - if dual_bible: - dual_version = self.parent.manager.get_meta_data(dual_bible, + if second_bible: + second_version = self.parent.manager.get_meta_data(second_bible, u'Version') - dual_copyright = self.parent.manager.get_meta_data(dual_bible, + second_copyright = self.parent.manager.get_meta_data(second_bible, u'Copyright') - dual_permissions = self.parent.manager.get_meta_data(dual_bible, + second_permissions = self.parent.manager.get_meta_data(second_bible, u'Permissions') - if not dual_permissions: - dual_permissions = u'' + if not second_permissions: + second_permissions = u'' for count, verse in enumerate(self.search_results): - if dual_bible: + if second_bible: vdict = { 'book': QtCore.QVariant(verse.book.name), 'chapter': QtCore.QVariant(verse.chapter), @@ -623,16 +623,16 @@ class BibleMediaItem(MediaManagerItem): 'copyright': QtCore.QVariant(copyright.value), 'permissions': QtCore.QVariant(permissions.value), 'text': QtCore.QVariant(verse.text), - 'dual_bible': QtCore.QVariant(dual_bible), - 'dual_version': QtCore.QVariant(dual_version.value), - 'dual_copyright': QtCore.QVariant(dual_copyright.value), - 'dual_permissions': QtCore.QVariant(dual_permissions.value), - 'dual_text': QtCore.QVariant( - self.dual_search_results[count].text) + 'second_bible': QtCore.QVariant(second_bible), + 'second_version': QtCore.QVariant(second_version.value), + 'second_copyright': QtCore.QVariant(second_copyright.value), + 'second_permissions': QtCore.QVariant(second_permissions.value), + 'second_text': QtCore.QVariant( + self.second_search_results[count].text) } bible_text = u' %s %d:%d (%s, %s)' % (verse.book.name, verse.chapter, verse.verse, version.value, - dual_version.value) + second_version.value) else: vdict = { 'book': QtCore.QVariant(verse.book.name), @@ -643,11 +643,11 @@ class BibleMediaItem(MediaManagerItem): 'copyright': QtCore.QVariant(copyright.value), 'permissions': QtCore.QVariant(permissions.value), 'text': QtCore.QVariant(verse.text), - 'dual_bible': QtCore.QVariant(u''), - 'dual_version': QtCore.QVariant(u''), - 'dual_copyright': QtCore.QVariant(u''), - 'dual_permissions': QtCore.QVariant(u''), - 'dual_text': QtCore.QVariant(u'') + 'second_bible': QtCore.QVariant(u''), + 'second_version': QtCore.QVariant(u''), + 'second_copyright': QtCore.QVariant(u''), + 'second_permissions': QtCore.QVariant(u''), + 'second_text': QtCore.QVariant(u'') } bible_text = u'%s %d:%d (%s)' % (verse.book.name, verse.chapter, verse.verse, version.value) @@ -656,7 +656,7 @@ class BibleMediaItem(MediaManagerItem): self.listView.addItem(bible_verse) self.listView.selectAll() self.search_results = {} - self.dual_search_results = {} + self.second_search_results = {} def _decodeQtObject(self, bitem, key): reference = bitem.data(QtCore.Qt.UserRole) @@ -692,22 +692,22 @@ class BibleMediaItem(MediaManagerItem): copyright = self._decodeQtObject(bitem, 'copyright') permissions = self._decodeQtObject(bitem, 'permissions') text = self._decodeQtObject(bitem, 'text') - dual_bible = self._decodeQtObject(bitem, 'dual_bible') - dual_version = self._decodeQtObject(bitem, 'dual_version') - dual_copyright = self._decodeQtObject(bitem, 'dual_copyright') - dual_permissions = self._decodeQtObject(bitem, 'dual_permissions') - dual_text = self._decodeQtObject(bitem, 'dual_text') + second_bible = self._decodeQtObject(bitem, 'second_bible') + second_version = self._decodeQtObject(bitem, 'second_version') + second_copyright = self._decodeQtObject(bitem, 'second_copyright') + second_permissions = self._decodeQtObject(bitem, 'second_permissions') + second_text = self._decodeQtObject(bitem, 'second_text') verse_text = self.formatVerse(old_chapter, chapter, verse) footer = u'%s (%s %s %s)' % (book, version, copyright, permissions) if footer not in raw_footer: raw_footer.append(footer) - if dual_bible: - footer = u'%s (%s %s %s)' % (book, dual_version, dual_copyright, - dual_permissions) + if second_bible: + footer = u'%s (%s %s %s)' % (book, second_version, second_copyright, + second_permissions) if footer not in raw_footer: raw_footer.append(footer) bible_text = u'%s %s\n\n%s %s' % (verse_text, text, verse_text, - dual_text) + second_text) raw_slides.append(bible_text) bible_text = u'' # If we are 'Verse Per Slide' then create a new slide. @@ -735,7 +735,7 @@ class BibleMediaItem(MediaManagerItem): raw_slides.append(bible_text) bible_text = u'' # Service Item: Capabilities - if self.parent.settings_tab.layout_style == 2 and not dual_bible: + if self.parent.settings_tab.layout_style == 2 and not second_bible: # Split the line but do not replace line breaks in renderer. service_item.add_capability(ItemCapabilities.NoLineBreaks) service_item.add_capability(ItemCapabilities.AllowsPreview) @@ -780,18 +780,18 @@ class BibleMediaItem(MediaManagerItem): start_chapter = int(self._decodeQtObject(start_bitem, 'chapter')) start_verse = int(self._decodeQtObject(start_bitem, 'verse')) start_bible = self._decodeQtObject(start_bitem, 'bible') - start_dual_bible = self._decodeQtObject(start_bitem, 'dual_bible') - if start_dual_bible: + start_second_bible = self._decodeQtObject(start_bitem, 'second_bible') + if start_second_bible: if start_verse == old_verse and start_chapter == old_chapter: title = u'%s %s:%s (%s, %s)' % (start_book, start_chapter, - start_verse, start_bible, start_dual_bible) + start_verse, start_bible, start_second_bible) elif start_chapter == old_chapter: title = u'%s %s:%s-%s (%s, %s)' % (start_book, start_chapter, - start_verse, old_verse, start_bible, start_dual_bible) + start_verse, old_verse, start_bible, start_second_bible) else: title = u'%s %s:%s-%s:%s (%s, %s)' % (start_book, start_chapter, start_verse, old_chapter, old_verse, start_bible, - start_dual_bible) + start_second_bible) else: if start_verse == old_verse and start_chapter == old_chapter: title = u'%s %s:%s (%s)' % (start_book, start_chapter, @@ -822,16 +822,16 @@ class BibleMediaItem(MediaManagerItem): chapter = int(self._decodeQtObject(bitem, 'chapter')) verse = int(self._decodeQtObject(bitem, 'verse')) bible = self._decodeQtObject(bitem, 'bible') - dual_bible = self._decodeQtObject(bitem, 'dual_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')) old_bible = self._decodeQtObject(old_bitem, 'bible') - old_dual_bible = self._decodeQtObject(old_bitem, 'dual_bible') - if old_bible != bible or old_dual_bible != dual_bible or \ + old_second_bible = self._decodeQtObject(old_bitem, 'second_bible') + if old_bible != bible or old_second_bible != second_bible or \ old_book != book: - # The bible, dual bible or book has changed. + # The bible, second bible or book has changed. return True elif old_verse + 1 != verse and old_chapter == chapter: # We are still in the same chapter, but a verse has been skipped. From 588cfa111f496b0802c37f1ac1d324f57dcc57c5 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 16 Nov 2010 18:57:13 +0100 Subject: [PATCH 13/19] long lines --- openlp/plugins/bibles/lib/mediaitem.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 4ef4c0eff..342d79c9e 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -573,7 +573,8 @@ class BibleMediaItem(MediaManagerItem): for verse in self.search_results: text.append((verse.book.name, verse.chapter, verse.verse, verse.verse)) - self.second_search_results = bibles[second_bible].get_verses(text) + self.second_search_results = \ + bibles[second_bible].get_verses(text) if self.ClearQuickSearchComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0 and self.search_results: @@ -626,7 +627,8 @@ class BibleMediaItem(MediaManagerItem): 'second_bible': QtCore.QVariant(second_bible), 'second_version': QtCore.QVariant(second_version.value), 'second_copyright': QtCore.QVariant(second_copyright.value), - 'second_permissions': QtCore.QVariant(second_permissions.value), + 'second_permissions': QtCore.QVariant( + second_permissions.value), 'second_text': QtCore.QVariant( self.second_search_results[count].text) } @@ -702,8 +704,8 @@ class BibleMediaItem(MediaManagerItem): if footer not in raw_footer: raw_footer.append(footer) if second_bible: - footer = u'%s (%s %s %s)' % (book, second_version, second_copyright, - second_permissions) + footer = u'%s (%s %s %s)' % (book, second_version, + second_copyright, second_permissions) if footer not in raw_footer: raw_footer.append(footer) bible_text = u'%s %s\n\n%s %s' % (verse_text, text, verse_text, @@ -807,8 +809,8 @@ class BibleMediaItem(MediaManagerItem): def checkTitle(self, item, old_item): """ This methode 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. + 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. ``item`` The item we are dealing with at the moment. From 435338caadea07affb8595d210b65e4eea886e40 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 16 Nov 2010 19:33:37 +0100 Subject: [PATCH 14/19] more generic parameters for __init__ --- openlp/plugins/bibles/lib/mediaitem.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 342d79c9e..9ce463231 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -54,12 +54,12 @@ class BibleMediaItem(MediaManagerItem): """ log.info(u'Bible Media Item loaded') - def __init__(self, parent, icon, title): + def __init__(self, parent, plugin, icon): self.PluginNameShort = u'Bible' self.pluginNameVisible = translate('BiblesPlugin.MediaItem', 'Bible') self.IconPath = u'songs/song' self.ListViewWithDnD_class = BibleListView - MediaManagerItem.__init__(self, parent, icon, title) + MediaManagerItem.__init__(self, parent, plugin, icon) # Place to store the search results for both bibles. self.search_results = {} self.second_search_results = {} @@ -552,6 +552,10 @@ class BibleMediaItem(MediaManagerItem): self.AdvancedSearchButton.setEnabled(True) def onQuickSearchButton(self): + """ + Does a quick search and saves the search results. Quick search can + either be "Verse Search" or "Text Search". + """ log.debug(u'Quick Search Button pressed') self.QuickSearchButton.setEnabled(False) bible = unicode(self.QuickVersionComboBox.currentText()) From f6c30b7106fda87984fe74b6e969f9da5cb40155 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 19 Nov 2010 22:34:15 +0100 Subject: [PATCH 15/19] removed == 1 --- openlp/plugins/bibles/lib/mediaitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 9ce463231..a94ea581a 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -365,7 +365,7 @@ class BibleMediaItem(MediaManagerItem): self.import_wizard = BibleImportForm(self, self.parent.manager, self.parent) # If the import was not canceled then reload. - if self.import_wizard.exec_() == 1: + if self.import_wizard.exec_(): self.reloadBibles() def loadBibles(self): From 28390e965da29dd530b06cea48bf1cbccfed1903 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 29 Nov 2010 20:02:58 +0100 Subject: [PATCH 16/19] enable search button --- openlp/plugins/bibles/lib/mediaitem.py | 39 +++++++++++++++----------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index a94ea581a..e9c5d1bdb 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -359,6 +359,7 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'No Book Found'), translate('BiblesPlugin.MediaItem', 'No matching book could be found in this Bible.')) + self.AdvancedSearchButton.setEnabled(True) def onImportClick(self): if not hasattr(self, u'import_wizard'): @@ -619,23 +620,27 @@ class BibleMediaItem(MediaManagerItem): second_permissions = u'' for count, verse in enumerate(self.search_results): if second_bible: - vdict = { - 'book': QtCore.QVariant(verse.book.name), - 'chapter': QtCore.QVariant(verse.chapter), - 'verse': QtCore.QVariant(verse.verse), - 'bible': QtCore.QVariant(bible), - 'version': QtCore.QVariant(version.value), - 'copyright': QtCore.QVariant(copyright.value), - 'permissions': QtCore.QVariant(permissions.value), - 'text': QtCore.QVariant(verse.text), - 'second_bible': QtCore.QVariant(second_bible), - 'second_version': QtCore.QVariant(second_version.value), - 'second_copyright': QtCore.QVariant(second_copyright.value), - 'second_permissions': QtCore.QVariant( - second_permissions.value), - 'second_text': QtCore.QVariant( - self.second_search_results[count].text) - } + try: + vdict = { + 'book': QtCore.QVariant(verse.book.name), + 'chapter': QtCore.QVariant(verse.chapter), + 'verse': QtCore.QVariant(verse.verse), + 'bible': QtCore.QVariant(bible), + 'version': QtCore.QVariant(version.value), + 'copyright': QtCore.QVariant(copyright.value), + 'permissions': QtCore.QVariant(permissions.value), + 'text': QtCore.QVariant(verse.text), + 'second_bible': QtCore.QVariant(second_bible), + 'second_version': QtCore.QVariant(second_version.value), + 'second_copyright': QtCore.QVariant( + second_copyright.value), + 'second_permissions': QtCore.QVariant( + second_permissions.value), + 'second_text': QtCore.QVariant( + self.second_search_results[count].text) + } + except IndexError: + break bible_text = u' %s %d:%d (%s, %s)' % (verse.book.name, verse.chapter, verse.verse, version.value, second_version.value) From cd6948f61335cf5c05b25fe111b0cbd1e9a0af27 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 1 Dec 2010 19:37:54 +0100 Subject: [PATCH 17/19] added an autoCompleter for bible books for 'Verse Search' --- openlp/plugins/bibles/lib/mediaitem.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index e9c5d1bdb..6ea18dfe2 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -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())) From b88436c6413b91a0b230d3257b5a46beb0168b4f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 2 Dec 2010 18:36:35 +0100 Subject: [PATCH 18/19] autocompleter should be 'CaseInsensitive' --- openlp/plugins/bibles/lib/mediaitem.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index a3b95d3f3..3044e431a 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -241,9 +241,9 @@ class BibleMediaItem(MediaManagerItem): 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.SIGNAL(u'activated(int)'), self.updateAutoCompleter) QtCore.QObject.connect(self.QuickVersionComboBox, - QtCore.SIGNAL(u'activated(int)'), self.autoCompletion) + QtCore.SIGNAL(u'activated(int)'), self.updateAutoCompleter) # Buttons QtCore.QObject.connect(self.AdvancedSearchButton, QtCore.SIGNAL(u'pressed()'), self.onAdvancedSearchButton) @@ -336,6 +336,7 @@ class BibleMediaItem(MediaManagerItem): log.debug(u'bible manager initialise') self.parent.manager.media = self self.loadBibles() + self.updateAutoCompleter() self.configUpdated() log.debug(u'bible manager initialise complete') @@ -402,6 +403,15 @@ class BibleMediaItem(MediaManagerItem): self.loadBibles() def initialiseBible(self, bible): + """ + This initialises the given bible, which means that its book names and + their chapter numbers is added to the combo boxes on the + 'Advanced Search' Tab. This is not of any importance of the + 'Quick Search' Tab. + + ``bible`` + The bible to initialise (unicode). + """ log.debug(u'initialiseBible %s', bible) book_data = self.parent.manager.get_books(bible) self.AdvancedBookComboBox.clear() @@ -432,11 +442,11 @@ class BibleMediaItem(MediaManagerItem): self.adjustComboBox(1, verse_count, self.AdvancedFromVerse) self.adjustComboBox(1, verse_count, self.AdvancedToVerse) - def autoCompletion(self): + def updateAutoCompleter(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. + This updates the bible book completion list for the search field. The + completion depends on the bible. It is only updated when we are doing a + verse search, otherwise the auto completion list is removed. """ books = [] # We have to do a 'Verse Search'. @@ -445,7 +455,9 @@ class BibleMediaItem(MediaManagerItem): 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)) + completer = QtGui.QCompleter(books) + completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) + self.QuickSearchEdit.setCompleter(completer) def onAdvancedVersionComboBox(self): self.initialiseBible( From 245465ab112e875a82f9b862c471909882a77ced Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 3 Dec 2010 20:53:56 +0100 Subject: [PATCH 19/19] improved completor performance --- openlp/plugins/bibles/lib/mediaitem.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 3044e431a..949035c0b 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -451,10 +451,12 @@ class BibleMediaItem(MediaManagerItem): books = [] # We have to do a 'Verse Search'. if self.QuickSearchComboBox.currentIndex() == 0: + bibles = self.parent.manager.get_bibles() bible = unicode(self.QuickVersionComboBox.currentText()) if bible: - book_data = self.parent.manager.get_books(bible) - books = [book[u'name'] for book in book_data] + book_data = bibles[bible].get_books() + books = [book.name for book in book_data] + books.sort() completer = QtGui.QCompleter(books) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) self.QuickSearchEdit.setCompleter(completer)