From 2255f05505be785a9c3bba5a5dc984f861add7e5 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Fri, 4 Mar 2016 05:33:57 +0200 Subject: [PATCH 01/69] Starting work on combined Bible quick search, added combined search type. (Copy from reference) --- openlp/plugins/bibles/lib/manager.py | 50 +++++++++++++++----------- openlp/plugins/bibles/lib/mediaitem.py | 12 ++++++- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 8cecbe0af..34662ef83 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -237,6 +237,26 @@ class BibleManager(RegistryProperties): log.debug('BibleManager.get_verse_count_by_book_ref_id("%s", "%s", "%s")', bible, book_ref_id, chapter) return self.db_cache[bible].get_verse_count(book_ref_id, chapter) + def get_language_selection(self, bible): + """ + Returns the language selection of a bible. + + :param bible: Unicode. The Bible to get the language selection from. + """ + log.debug('BibleManager.get_language_selection("%s")', bible) + language_selection = self.get_meta_data(bible, 'book_name_language') + if not language_selection or language_selection.value == "None" or language_selection.value == "-1": + # If None is returned, it's not the singleton object but a + # BibleMeta object with the value "None" + language_selection = Settings().value(self.settings_section + '/book name language') + else: + language_selection = language_selection.value + try: + language_selection = int(language_selection) + except (ValueError, TypeError): + language_selection = LanguageSelection.Application + return language_selection + def get_verses(self, bible, verse_text, book_ref_id=False, show_error=True): """ Parses a scripture reference, fetches the verses from the Bible @@ -296,26 +316,6 @@ class BibleManager(RegistryProperties): ) return None - def get_language_selection(self, bible): - """ - Returns the language selection of a bible. - - :param bible: Unicode. The Bible to get the language selection from. - """ - log.debug('BibleManager.get_language_selection("%s")', bible) - language_selection = self.get_meta_data(bible, 'book_name_language') - if not language_selection or language_selection.value == "None" or language_selection.value == "-1": - # If None is returned, it's not the singleton object but a - # BibleMeta object with the value "None" - language_selection = Settings().value(self.settings_section + '/book name language') - else: - language_selection = language_selection.value - try: - language_selection = int(language_selection) - except (ValueError, TypeError): - language_selection = LanguageSelection.Application - return language_selection - def verse_search(self, bible, second_bible, text): """ Does a verse search for the given bible and text. @@ -344,7 +344,15 @@ class BibleManager(RegistryProperties): translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.') ) return None - if text: + + if not len(text) == 0 and len(text) < 3: + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'Keyword is too short'), + translate('BiblesPlugin.BibleManager', 'The keyword you have entered is shorter ' + 'than 3 characters long.\nPlease try again with ' + 'a longer keyword.') + ) + elif text: return self.db_cache[bible].verse_search(text) else: self.main_window.information_message( diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 94937e61b..683337644 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -45,6 +45,7 @@ class BibleSearch(object): """ Reference = 1 Text = 2 + Quick = 3 class BibleMediaItem(MediaManagerItem): @@ -309,6 +310,9 @@ class BibleMediaItem(MediaManagerItem): self.plugin.manager.media = self self.load_bibles() self.quick_search_edit.set_search_types([ + (BibleSearch.Quick, ':/bibles/bibles_search_reference.png', + translate('BiblesPlugin.MediaItem', 'Quick search'), + translate('BiblesPlugin.MediaItem', 'Search Text or Scripture Reference...')), (BibleSearch.Reference, ':/bibles/bibles_search_reference.png', translate('BiblesPlugin.MediaItem', 'Scripture Reference'), translate('BiblesPlugin.MediaItem', 'Search Scripture Reference...')), @@ -659,7 +663,13 @@ class BibleMediaItem(MediaManagerItem): bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() text = self.quick_search_edit.text() - if self.quick_search_edit.current_search_type() == BibleSearch.Reference: + if self.quick_search_edit.current_search_type() == BibleSearch.Quick: + # We are doing a 'Reference Search'. + self.search_results = self.plugin.manager.get_verses(bible, text) + if second_bible and self.search_results: + self.second_search_results = \ + self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) + elif self.quick_search_edit.current_search_type() == BibleSearch.Reference: # We are doing a 'Reference Search'. self.search_results = self.plugin.manager.get_verses(bible, text) if second_bible and self.search_results: From b1223927a011766788ed6807a20690fdfcba85f7 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sun, 6 Mar 2016 22:35:05 +0200 Subject: [PATCH 02/69] - Combined search is now working, own "combined" function for scripture reference search. - Book name prediction as typing is not yet working - Icon does not appear correctly (If used) Now using Reference icon, even thou combined icon was added. - Renamed to "Combined search" --- openlp/plugins/bibles/lib/manager.py | 57 ++++++++++++++--------- openlp/plugins/bibles/lib/mediaitem.py | 62 +++++++++++++++++++------- resources/images/openlp-2.qrc | 1 + 3 files changed, 85 insertions(+), 35 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 34662ef83..090bb4c79 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -237,26 +237,6 @@ class BibleManager(RegistryProperties): log.debug('BibleManager.get_verse_count_by_book_ref_id("%s", "%s", "%s")', bible, book_ref_id, chapter) return self.db_cache[bible].get_verse_count(book_ref_id, chapter) - def get_language_selection(self, bible): - """ - Returns the language selection of a bible. - - :param bible: Unicode. The Bible to get the language selection from. - """ - log.debug('BibleManager.get_language_selection("%s")', bible) - language_selection = self.get_meta_data(bible, 'book_name_language') - if not language_selection or language_selection.value == "None" or language_selection.value == "-1": - # If None is returned, it's not the singleton object but a - # BibleMeta object with the value "None" - language_selection = Settings().value(self.settings_section + '/book name language') - else: - language_selection = language_selection.value - try: - language_selection = int(language_selection) - except (ValueError, TypeError): - language_selection = LanguageSelection.Application - return language_selection - def get_verses(self, bible, verse_text, book_ref_id=False, show_error=True): """ Parses a scripture reference, fetches the verses from the Bible @@ -316,6 +296,26 @@ class BibleManager(RegistryProperties): ) return None + def get_language_selection(self, bible): + """ + Returns the language selection of a bible. + + :param bible: Unicode. The Bible to get the language selection from. + """ + log.debug('BibleManager.get_language_selection("%s")', bible) + language_selection = self.get_meta_data(bible, 'book_name_language') + if not language_selection or language_selection.value == "None" or language_selection.value == "-1": + # If None is returned, it's not the singleton object but a + # BibleMeta object with the value "None" + language_selection = Settings().value(self.settings_section + '/book name language') + else: + language_selection = language_selection.value + try: + language_selection = int(language_selection) + except (ValueError, TypeError): + language_selection = LanguageSelection.Application + return language_selection + def verse_search(self, bible, second_bible, text): """ Does a verse search for the given bible and text. @@ -363,6 +363,23 @@ class BibleManager(RegistryProperties): ) return None + def get_verses_combined(self, bible, verse_text, book_ref_id=False, show_error=False): + log.debug('BibleManager.get_verses("%s", "%s")', bible, verse_text) + if not bible: + if show_error: + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'No Bibles Available'), + translate('BiblesPlugin.BibleManager', 'There are no Bibles currently installed. Please use the ' + 'Import Wizard to install one or more Bibles.') + ) + return None + language_selection = self.get_language_selection(bible) + ref_list = parse_reference(verse_text, self.db_cache[bible], language_selection, book_ref_id) + if ref_list: + return self.db_cache[bible].get_verses(ref_list, show_error) + else: + return None + def save_meta_data(self, bible, version, copyright, permissions, book_name_language=None): """ Saves the bibles meta data. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 683337644..a2ea681d7 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -45,7 +45,7 @@ class BibleSearch(object): """ Reference = 1 Text = 2 - Quick = 3 + Combined = 3 class BibleMediaItem(MediaManagerItem): @@ -310,8 +310,8 @@ class BibleMediaItem(MediaManagerItem): self.plugin.manager.media = self self.load_bibles() self.quick_search_edit.set_search_types([ - (BibleSearch.Quick, ':/bibles/bibles_search_reference.png', - translate('BiblesPlugin.MediaItem', 'Quick search'), + (BibleSearch.Combined, ':/bibles/bibles_search_reference.png', + translate('BiblesPlugin.MediaItem', 'Text or Scripture Reference'), translate('BiblesPlugin.MediaItem', 'Search Text or Scripture Reference...')), (BibleSearch.Reference, ':/bibles/bibles_search_reference.png', translate('BiblesPlugin.MediaItem', 'Scripture Reference'), @@ -663,20 +663,14 @@ class BibleMediaItem(MediaManagerItem): bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() text = self.quick_search_edit.text() - if self.quick_search_edit.current_search_type() == BibleSearch.Quick: + if self.quick_search_edit.current_search_type() == BibleSearch.Reference: # We are doing a 'Reference Search'. self.search_results = self.plugin.manager.get_verses(bible, text) if second_bible and self.search_results: self.second_search_results = \ self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) - elif self.quick_search_edit.current_search_type() == BibleSearch.Reference: - # We are doing a 'Reference Search'. - self.search_results = self.plugin.manager.get_verses(bible, text) - if second_bible and self.search_results: - self.second_search_results = \ - self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) - else: - # We are doing a 'Text Search'. + elif self.quick_search_edit.current_search_type() == BibleSearch.Text: + # We are doing a 'Text Search'. self.application.set_busy_cursor() bibles = self.plugin.manager.get_bibles() self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) @@ -695,15 +689,53 @@ class BibleMediaItem(MediaManagerItem): continue new_search_results.append(verse) text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse)) - if passage_not_found: - QtWidgets.QMessageBox.information( + if passage_not_found(): + # This function appears to be broken / Does nothing? + QtGui.QMessageBox.information( self, translate('BiblesPlugin.MediaItem', 'Information'), translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' 'that are in the main Bible. Only verses found in both Bibles will be shown. %d ' 'verses have not been included in the results.') % count, - QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok)) + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) self.search_results = new_search_results self.second_search_results = bibles[second_bible].get_verses(text) + elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: + # Combined search, starting with reference search + self.search_results = self.plugin.manager.get_verses_combined(bible, text) + if second_bible and self.search_results: + self.second_search_results = \ + self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) + # Text search starts here if no reference was found + if not self.search_results: + self.application.set_busy_cursor() + bibles = self.plugin.manager.get_bibles() + self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) + if second_bible and self.search_results: + text = [] + new_search_results = [] + count = 0 + passage_not_found = False + for verse in self.search_results: + db_book = bibles[second_bible].get_book_by_book_ref_id(verse.book.book_reference_id) + if not db_book: + log.debug('Passage "%s %d:%d" not found in Second Bible' % + (verse.book.name, verse.chapter, verse.verse)) + passage_not_found = True + count += 1 + continue + new_search_results.append(verse) + text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse)) + if passage_not_found(): + # This function appears to be broken / Does nothing? + QtGui.QMessageBox.information( + self, translate('BiblesPlugin.MediaItem', 'Information'), + translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' + 'that are in the main Bible. Only verses found in both Bibles will be shown. %d ' + 'verses have not been included in the results.') % count, + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + self.search_results = new_search_results + self.second_search_results = bibles[second_bible].get_verses(text) + # Finalizing the search if not self.quickLockButton.isChecked(): self.list_view.clear() if self.list_view.count() != 0 and self.search_results: diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index 82c6234aa..d47e5a1ca 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -27,6 +27,7 @@ image_new_group.png + bibles_search_combined.png bibles_search_text.png bibles_search_reference.png bibles_upgrade_alert.png From 0ac56e5a1941fcdef6da781441a2c7025f31142f Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sun, 6 Mar 2016 23:45:51 +0200 Subject: [PATCH 03/69] - It works! - Added text prediction for book names - New script for reference_combined - Also on previous: Added mininium search lengt of 3 characters for text to prevent short keywords from crashing OLP. - Added new icon to code but still using reference icon since it requires packing in order to work. To DO: a) New icon, pack it | How? b) Added stupid error message if nothing is found, make it less stupid. c) Add example verses to "Reference not found" error. ( and Use this as base for b) d) Possibly work on text prediction for Text based search but probably leave it for an another branch. --- openlp/plugins/bibles/lib/manager.py | 4 ++-- openlp/plugins/bibles/lib/mediaitem.py | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 090bb4c79..dec0011e4 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -369,8 +369,8 @@ class BibleManager(RegistryProperties): if show_error: self.main_window.information_message( translate('BiblesPlugin.BibleManager', 'No Bibles Available'), - translate('BiblesPlugin.BibleManager', 'There are no Bibles currently installed. Please use the ' - 'Import Wizard to install one or more Bibles.') + translate('BiblesPlugin.BibleManager', 'There are no Bibles currently installed. Please use the' + ' Import Wizard to install one or more Bibles.') ) return None language_selection = self.get_language_selection(bible) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index a2ea681d7..166966579 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -435,8 +435,8 @@ class BibleMediaItem(MediaManagerItem): # Save the current bible to the configuration. Settings().setValue(self.settings_section + '/quick bible', self.quickVersionComboBox.currentText()) books = [] - # We have to do a 'Reference Search'. - if self.quick_search_edit.current_search_type() == BibleSearch.Reference: + # We have to do a 'Reference Search' (Or as part of Combined Search). + if self.quick_search_edit.current_search_type() == BibleSearch.Reference or BibleSearch.Combined: bibles = self.plugin.manager.get_bibles() bible = self.quickVersionComboBox.currentText() if bible: @@ -670,7 +670,7 @@ class BibleMediaItem(MediaManagerItem): self.second_search_results = \ self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) elif self.quick_search_edit.current_search_type() == BibleSearch.Text: - # We are doing a 'Text Search'. + # We are doing a 'Text Search'. self.application.set_busy_cursor() bibles = self.plugin.manager.get_bibles() self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) @@ -700,7 +700,7 @@ class BibleMediaItem(MediaManagerItem): self.search_results = new_search_results self.second_search_results = bibles[second_bible].get_verses(text) elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: - # Combined search, starting with reference search + # Combined search, starting with reference search (combined) self.search_results = self.plugin.manager.get_verses_combined(bible, text) if second_bible and self.search_results: self.second_search_results = \ @@ -735,6 +735,13 @@ class BibleMediaItem(MediaManagerItem): QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) self.search_results = new_search_results self.second_search_results = bibles[second_bible].get_verses(text) + # If no Text or Reference is found, message is given. + if not self.search_results: + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'Scripture Reference Errorhhh'), + translate('BiblesPlugin.BibleManager', 'You did not enter a search ' + 'different keywords by a space to search for all of your ' + 'them by a comma to search for one of them.')) # Finalizing the search if not self.quickLockButton.isChecked(): self.list_view.clear() From 3c70500c23aef9b02735559946ff6181fb885b5d Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 7 Mar 2016 08:03:41 +0200 Subject: [PATCH 04/69] Fixes in this commit: - Fix for some dual triggering errors. - Searches with only spaces now trigger error since they make OLP unresponsive and may crash - Removed old "Empty" search message, integrated it to the new one. - Added some comments - Remodelled/Added nice error messages + needed code to support it - Fixed the issue where Bible book name prediction comes for pure Text search. - Fixed "No passage found" in 2nd bible by using self.main_window.information_message To DO: - If web bible is enabled combined text search triggers double error, fix it. - Pack the new icon - Double check spelling etc... - Write tests --- openlp/plugins/bibles/lib/manager.py | 34 ++++++----- openlp/plugins/bibles/lib/mediaitem.py | 79 +++++++++++++++++++------- 2 files changed, 74 insertions(+), 39 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index dec0011e4..1f10ee322 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -282,14 +282,17 @@ class BibleManager(RegistryProperties): 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 or consult the manual:\n\n' - 'Book Chapter\n' - 'Book Chapter%(range)sChapter\n' - 'Book Chapter%(verse)sVerse%(range)sVerse\n' + 'Book Chapter | John 3:16\n' + 'Book Chapter%(range)sChapter | John 3%(range)s4\n' + 'Book Chapter%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17\n' 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sVerse' - '%(range)sVerse\n' + '%(range)sVerse | John 3%(verse)s16-17%(list)s20%(range)s22\n' 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sChapter' - '%(verse)sVerse%(range)sVerse\n' - 'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse', + '%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17%' + '(list)s5%(verse)s7%(range)s9\n' + 'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse' + ' | John 3%(verse)s16%(range)s4%(verse)s2\n\n' + 'Book names may be shortened from full names but must not contain any additional dots.', 'Please pay attention to the appended "s" of the wildcards ' 'and refrain from translating the words inside the names in the brackets.') % reference_separators @@ -344,23 +347,18 @@ class BibleManager(RegistryProperties): translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.') ) return None - - if not len(text) == 0 and len(text) < 3: + if len(text) < 3 or str.isspace(text): self.main_window.information_message( translate('BiblesPlugin.BibleManager', 'Keyword is too short'), - translate('BiblesPlugin.BibleManager', 'The keyword you have entered is shorter ' - 'than 3 characters long.\nPlease try again with ' - 'a longer keyword.') - ) + translate('BiblesPlugin.BibleManager', 'The keyword you have entered is empty or shorter ' + 'than 3 characters long. Please try again with ' + 'a longer keyword.\n \nYou can separate different keywords by ' + ' a space to search for all of your keywords and you can ' + 'separate them by a comma to search for one of them.')) + return None elif text: return self.db_cache[bible].verse_search(text) else: - self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), - translate('BiblesPlugin.BibleManager', 'You did not enter a search keyword.\nYou can separate ' - 'different keywords by a space to search for all of your keywords and you can separate ' - 'them by a comma to search for one of them.') - ) return None def get_verses_combined(self, bible, verse_text, book_ref_id=False, show_error=False): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 166966579..1a7a172f6 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -436,7 +436,7 @@ class BibleMediaItem(MediaManagerItem): Settings().setValue(self.settings_section + '/quick bible', self.quickVersionComboBox.currentText()) books = [] # We have to do a 'Reference Search' (Or as part of Combined Search). - if self.quick_search_edit.current_search_type() == BibleSearch.Reference or BibleSearch.Combined: + if self.quick_search_edit.current_search_type() is not BibleSearch.Text: bibles = self.plugin.manager.get_bibles() bible = self.quickVersionComboBox.currentText() if bible: @@ -689,24 +689,42 @@ class BibleMediaItem(MediaManagerItem): continue new_search_results.append(verse) text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse)) - if passage_not_found(): - # This function appears to be broken / Does nothing? - QtGui.QMessageBox.information( - self, translate('BiblesPlugin.MediaItem', 'Information'), + if passage_not_found: + self.main_window.information_message( + translate('BiblesPlugin.MediaItem', 'Information'), translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' 'that are in the main Bible. Only verses found in both Bibles will be shown. %d ' - 'verses have not been included in the results.') % count, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + 'verses have not been included in the results.') % count) self.search_results = new_search_results self.second_search_results = bibles[second_bible].get_verses(text) + # Combined search, starting with reference search (combined) elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: - # Combined search, starting with reference search (combined) self.search_results = self.plugin.manager.get_verses_combined(bible, text) if second_bible and self.search_results: self.second_search_results = \ self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) - # Text search starts here if no reference was found - if not self.search_results: + # If keyword is shorter than 3, message is given and search is finalized. + if len(text) < 3 or str.isspace(text): + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'Search is Empty or too Short'), + translate('BiblesPlugin.BibleManager', 'The Search you have entered is empty or shorter ' + 'than 3 characters long. Please try again with ' + 'a longer keyword.\n \nYou can separate different keywords ' + 'by a space to search for all of your keywords and you can ' + 'separate them by a comma to search for one of them.')) + if not self.quickLockButton.isChecked(): + self.list_view.clear() + if self.list_view.count() != 0 and self.search_results: + self.__check_second_bible(bible, second_bible) + elif self.search_results: + self.display_results(bible, second_bible) + self.quickSearchButton.setEnabled(True) + self.check_search_result() + self.application.set_normal_cursor() + # Text search starts here if no reference was found and keyword is longer than 2. + # This is required in order to avoid duplicate error messages for short keywords. + # If only spaces are searched OLP becomes unresponsive and may crash eventually. "isspace" prevents this. + if not self.search_results and len(text) > 2 and not str.isspace(text): self.application.set_busy_cursor() bibles = self.plugin.manager.get_bibles() self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) @@ -725,23 +743,42 @@ class BibleMediaItem(MediaManagerItem): continue new_search_results.append(verse) text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse)) - if passage_not_found(): - # This function appears to be broken / Does nothing? - QtGui.QMessageBox.information( - self, translate('BiblesPlugin.MediaItem', 'Information'), + if passage_not_found: + self.main_window.information_message( + translate('BiblesPlugin.MediaItem', 'Information'), translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' 'that are in the main Bible. Only verses found in both Bibles will be shown. %d ' - 'verses have not been included in the results.') % count, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + 'verses have not been included in the results.') % count) self.search_results = new_search_results self.second_search_results = bibles[second_bible].get_verses(text) # If no Text or Reference is found, message is given. if not self.search_results: - self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'Scripture Reference Errorhhh'), - translate('BiblesPlugin.BibleManager', 'You did not enter a search ' - 'different keywords by a space to search for all of your ' - 'them by a comma to search for one of them.')) + reference_separators = { + 'verse': get_reference_separator('sep_v_display'), + 'range': get_reference_separator('sep_r_display'), + 'list': get_reference_separator('sep_l_display')} + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'Nothing found'), + translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find ' + 'anything with your search.

' + 'If you tried to search with Scripture Reference, please make sure that your ' + 'reference follows one of the following patterns:

' + 'Book Chapter | John 3:16
' + 'Book Chapter%(range)sChapter | John 3%(range)s4
' + 'Book Chapter%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17
' + 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sVerse' + '%(range)sVerse | John 3%(verse)s16-17%(list)s20%(range)s22
' + 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sChapter' + '%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17%' + '(list)s5%(verse)s7%(range)s9
' + 'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse' + ' | John 3%(verse)s16%(range)s4%(verse)s2

' + 'Book names may be shortened from full names but' + ' must not contain any additional dots.', + 'Please pay attention to the appended "s" of the wildcards ' + 'and refrain from translating the words inside the names in the brackets.') + % reference_separators + ) # Finalizing the search if not self.quickLockButton.isChecked(): self.list_view.clear() From 9b9c33123e48c809491a866a8461ee3e8bd5a818 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 7 Mar 2016 20:27:37 +0200 Subject: [PATCH 05/69] In this commit: - Fixed (packed) the new icon - Improved some error messages To do - Write tests Possible other changes/features that may be added later. - Ignore '.' in Reference search for smoother searching experience - Block spaces + single character combos since they kind of break the search. - Listing search results when typing for Text search --- openlp/plugins/bibles/lib/manager.py | 29 +++++++++++++------------- openlp/plugins/bibles/lib/mediaitem.py | 15 ++++++------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 1f10ee322..a44c4e395 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -279,21 +279,21 @@ class BibleManager(RegistryProperties): 'list': get_reference_separator('sep_l_display')} self.main_window.information_message( translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), - 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 or consult the manual:\n\n' - 'Book Chapter | John 3:16\n' - 'Book Chapter%(range)sChapter | John 3%(range)s4\n' - 'Book Chapter%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17\n' + translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find anything ' + 'with your search.

' + 'Please make sure that your reference follows one of the following patterns:

' + 'Book Chapter | John 3:16
' + 'Book Chapter%(range)sChapter | John 3%(range)s4
' + 'Book Chapter%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17
' 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sVerse' - '%(range)sVerse | John 3%(verse)s16-17%(list)s20%(range)s22\n' + '%(range)sVerse | John 3%(verse)s16-17%(list)s20%(range)s22
' 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sChapter' '%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17%' - '(list)s5%(verse)s7%(range)s9\n' + '(list)s5%(verse)s7%(range)s9
' 'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse' - ' | John 3%(verse)s16%(range)s4%(verse)s2\n\n' - 'Book names may be shortened from full names but must not contain any additional dots.', - 'Please pay attention to the appended "s" of the wildcards ' + ' | John 3%(verse)s16%(range)s4%(verse)s2

' + 'Book names may be shortened from full names
but must not contain any additional dots.' + , 'Please pay attention to the appended "s" of the wildcards ' 'and refrain from translating the words inside the names in the brackets.') % reference_separators ) @@ -344,7 +344,8 @@ class BibleManager(RegistryProperties): if web_bible or second_web_bible: self.main_window.information_message( translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'), - translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.') + translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.\n' + 'Please use the Scripture Reference Search instead.') ) return None if len(text) < 3 or str.isspace(text): @@ -352,8 +353,8 @@ class BibleManager(RegistryProperties): translate('BiblesPlugin.BibleManager', 'Keyword is too short'), translate('BiblesPlugin.BibleManager', 'The keyword you have entered is empty or shorter ' 'than 3 characters long. Please try again with ' - 'a longer keyword.\n \nYou can separate different keywords by ' - ' a space to search for all of your keywords and you can ' + 'a longer keyword.\n\nYou can separate different keywords by ' + 'a space to search for all of your keywords and you can ' 'separate them by a comma to search for one of them.')) return None elif text: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 1a7a172f6..1a987430e 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -310,7 +310,7 @@ class BibleMediaItem(MediaManagerItem): self.plugin.manager.media = self self.load_bibles() self.quick_search_edit.set_search_types([ - (BibleSearch.Combined, ':/bibles/bibles_search_reference.png', + (BibleSearch.Combined, ':/bibles/bibles_search_combined.png', translate('BiblesPlugin.MediaItem', 'Text or Scripture Reference'), translate('BiblesPlugin.MediaItem', 'Search Text or Scripture Reference...')), (BibleSearch.Reference, ':/bibles/bibles_search_reference.png', @@ -704,12 +704,13 @@ class BibleMediaItem(MediaManagerItem): self.second_search_results = \ self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) # If keyword is shorter than 3, message is given and search is finalized. + # This needs to be here in order to avoid deadlock/duplicate errors. if len(text) < 3 or str.isspace(text): self.main_window.information_message( translate('BiblesPlugin.BibleManager', 'Search is Empty or too Short'), translate('BiblesPlugin.BibleManager', 'The Search you have entered is empty or shorter ' 'than 3 characters long. Please try again with ' - 'a longer keyword.\n \nYou can separate different keywords ' + 'a longer keyword.\n\nYou can separate different keywords ' 'by a space to search for all of your keywords and you can ' 'separate them by a comma to search for one of them.')) if not self.quickLockButton.isChecked(): @@ -761,8 +762,8 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.BibleManager', 'Nothing found'), translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find ' 'anything with your search.

' - 'If you tried to search with Scripture Reference, please make sure that your ' - 'reference follows one of the following patterns:

' + 'If you tried to search with Scripture Reference, please make sure that ' + 'your reference follows one of the following patterns:

' 'Book Chapter | John 3:16
' 'Book Chapter%(range)sChapter | John 3%(range)s4
' 'Book Chapter%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17
' @@ -771,9 +772,9 @@ class BibleMediaItem(MediaManagerItem): 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sChapter' '%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17%' '(list)s5%(verse)s7%(range)s9
' - 'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse' - ' | John 3%(verse)s16%(range)s4%(verse)s2

' - 'Book names may be shortened from full names but' + 'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse ' + '| John 3%(verse)s16%(range)s4%(verse)s2

' + 'Book names may be shortened from full names
but' ' must not contain any additional dots.', 'Please pay attention to the appended "s" of the wildcards ' 'and refrain from translating the words inside the names in the brackets.') From 07c519084abc1bd731d8a3718815bf446d60907e Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Tue, 8 Mar 2016 02:34:31 +0200 Subject: [PATCH 06/69] - Moved empty/short search messages and parts of scripture error to uistrings.py - Improved some Error messages - Improved some comments --- openlp/core/common/uistrings.py | 24 ++++++++++++++++++++ openlp/plugins/bibles/lib/manager.py | 28 +++++------------------ openlp/plugins/bibles/lib/mediaitem.py | 31 +++++--------------------- 3 files changed, 35 insertions(+), 48 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 3f221ab08..2766b3117 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -151,3 +151,27 @@ class UiStrings(object): self.Version = translate('OpenLP.Ui', 'Version') self.View = translate('OpenLP.Ui', 'View') self.ViewMode = translate('OpenLP.Ui', 'View Mode') + self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short') + self.BibleScriptureError = translate('OpenLP.Ui', '

Book Chapter | John 3:16
' + 'Book Chapter%(range)sChapter | John 3%(range)s4
' + 'Book Chapter%(verse)sVerse%(range)sVerse | John 3%(verse)' + 's16%(range)s17
Book Chapter%(verse)sVerse%(range)sVerse%' + '(list)sVerse%(range)sVerse | John 3%(verse)s16-17%(list)s20%' + '(range)s22
Book Chapter%(verse)sVerse%(range)sVerse%' + '(list)sChapter%(verse)sVerse%(range)sVerse | John 3%(verse)' + 's16%(range)s17%(list)s5%(verse)s7%(range)s9
Book Chapter%' + '(verse)sVerse%(range)sChapter%(verse)sVerse | John 3%(verse)' + 's16%(range)s4%(verse)s2

Book names may be shortened ' + 'from full names
but must not contain any ' + 'additional dots.', 'Please pay attention to the appended' + '"s" of the wildcards and refrain from ' + 'translating the words inside the names' + ' in the brackets.') + self.BibleShortSearch = translate('OpenLP.Ui', 'The keyword you have entered is empty or shorter ' + 'than 3 characters long.\nPlease try again with ' + 'a longer keyword.\n\nYou can separate different keywords by ' + 'a space to search for all of your keywords and you can ' + 'separate them by a comma to search for one of them.') + + + diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index a44c4e395..c726c6032 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -23,7 +23,7 @@ import logging import os -from openlp.core.common import RegistryProperties, AppLocation, Settings, translate +from openlp.core.common import RegistryProperties, AppLocation, Settings, UiStrings, translate from openlp.core.utils import delete_file from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta @@ -281,22 +281,8 @@ class BibleManager(RegistryProperties): translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find anything ' 'with your search.

' - 'Please make sure that your reference follows one of the following patterns:

' - 'Book Chapter | John 3:16
' - 'Book Chapter%(range)sChapter | John 3%(range)s4
' - 'Book Chapter%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17
' - 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sVerse' - '%(range)sVerse | John 3%(verse)s16-17%(list)s20%(range)s22
' - 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sChapter' - '%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17%' - '(list)s5%(verse)s7%(range)s9
' - 'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse' - ' | John 3%(verse)s16%(range)s4%(verse)s2

' - 'Book names may be shortened from full names
but must not contain any additional dots.' - , 'Please pay attention to the appended "s" of the wildcards ' - 'and refrain from translating the words inside the names in the brackets.') - % reference_separators - ) + 'Please make sure that your reference follows one of these patterns:%s' + % UiStrings().BibleScriptureError % reference_separators)) return None def get_language_selection(self, bible): @@ -350,12 +336,8 @@ class BibleManager(RegistryProperties): return None if len(text) < 3 or str.isspace(text): self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'Keyword is too short'), - translate('BiblesPlugin.BibleManager', 'The keyword you have entered is empty or shorter ' - 'than 3 characters long. Please try again with ' - 'a longer keyword.\n\nYou can separate different keywords by ' - 'a space to search for all of your keywords and you can ' - 'separate them by a comma to search for one of them.')) + ('%s' % UiStrings().BibleShortSearchTitle), + ('%s' % UiStrings().BibleShortSearch)) return None elif text: return self.db_cache[bible].verse_search(text) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 1a987430e..5895bb1d5 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -654,8 +654,8 @@ class BibleMediaItem(MediaManagerItem): def on_quick_search_button(self): """ - Does a quick search and saves the search results. Quick search can either be "Reference Search" or - "Text Search". + Does a quick search and saves the search results. Quick search can be: + "Reference Search" or "Text Search" or Combined search. """ log.debug('Quick Search Button clicked') self.quickSearchButton.setEnabled(False) @@ -707,12 +707,8 @@ class BibleMediaItem(MediaManagerItem): # This needs to be here in order to avoid deadlock/duplicate errors. if len(text) < 3 or str.isspace(text): self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'Search is Empty or too Short'), - translate('BiblesPlugin.BibleManager', 'The Search you have entered is empty or shorter ' - 'than 3 characters long. Please try again with ' - 'a longer keyword.\n\nYou can separate different keywords ' - 'by a space to search for all of your keywords and you can ' - 'separate them by a comma to search for one of them.')) + ('%s' % UiStrings().BibleShortSearchTitle), + ('%s' % UiStrings().BibleShortSearch)) if not self.quickLockButton.isChecked(): self.list_view.clear() if self.list_view.count() != 0 and self.search_results: @@ -763,23 +759,8 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find ' 'anything with your search.

' 'If you tried to search with Scripture Reference, please make sure that ' - 'your reference follows one of the following patterns:

' - 'Book Chapter | John 3:16
' - 'Book Chapter%(range)sChapter | John 3%(range)s4
' - 'Book Chapter%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17
' - 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sVerse' - '%(range)sVerse | John 3%(verse)s16-17%(list)s20%(range)s22
' - 'Book Chapter%(verse)sVerse%(range)sVerse%(list)sChapter' - '%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17%' - '(list)s5%(verse)s7%(range)s9
' - 'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse ' - '| John 3%(verse)s16%(range)s4%(verse)s2

' - 'Book names may be shortened from full names
but' - ' must not contain any additional dots.', - 'Please pay attention to the appended "s" of the wildcards ' - 'and refrain from translating the words inside the names in the brackets.') - % reference_separators - ) + 'your reference follows one of these patterns:%s' + % UiStrings().BibleScriptureError % reference_separators)) # Finalizing the search if not self.quickLockButton.isChecked(): self.list_view.clear() From 432177fd2d10dac2772f82a4b1ec59a0fba9c8d8 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Tue, 8 Mar 2016 03:34:42 +0200 Subject: [PATCH 07/69] In this commit: - Added: self.application.set_normal_cursor() to "Web bible" and "no search results" for combined. To do: - Write tests Optional fixes that are not yet done/may not be done. - Ignore '.' in Reference search for smoother searching experience + Remove mention about it in error and add ending to uistrings.py - Block spaces + single character combos since they kind of break the search. - Listing search results when typing for Text search --- openlp/core/common/uistrings.py | 9 +++------ openlp/plugins/bibles/lib/manager.py | 5 ++++- openlp/plugins/bibles/lib/mediaitem.py | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 2766b3117..8e98fd009 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -161,12 +161,9 @@ class UiStrings(object): '(list)sChapter%(verse)sVerse%(range)sVerse | John 3%(verse)' 's16%(range)s17%(list)s5%(verse)s7%(range)s9
Book Chapter%' '(verse)sVerse%(range)sChapter%(verse)sVerse | John 3%(verse)' - 's16%(range)s4%(verse)s2

Book names may be shortened ' - 'from full names
but must not contain any ' - 'additional dots.', 'Please pay attention to the appended' - '"s" of the wildcards and refrain from ' - 'translating the words inside the names' - ' in the brackets.') + 's16%(range)s4%(verse)s2

', + 'Please pay attention to the appended "s" of the wildcards and refrain ' + 'from translating the words inside the names in the brackets.') self.BibleShortSearch = translate('OpenLP.Ui', 'The keyword you have entered is empty or shorter ' 'than 3 characters long.\nPlease try again with ' 'a longer keyword.\n\nYou can separate different keywords by ' diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index c726c6032..b74bc6fab 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -281,7 +281,9 @@ class BibleManager(RegistryProperties): translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find anything ' 'with your search.

' - 'Please make sure that your reference follows one of these patterns:%s' + 'Please make sure that your reference follows one of these patterns:%sBook names may be ' + 'shortened from full names
but must not contain any ' + 'additional dots.' % UiStrings().BibleScriptureError % reference_separators)) return None @@ -328,6 +330,7 @@ class BibleManager(RegistryProperties): if second_bible: second_web_bible = self.db_cache[second_bible].get_object(BibleMeta, 'download_source') if web_bible or second_web_bible: + self.application.set_normal_cursor() self.main_window.information_message( translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'), translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.\n' diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 5895bb1d5..d5fea2968 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -750,6 +750,7 @@ class BibleMediaItem(MediaManagerItem): self.second_search_results = bibles[second_bible].get_verses(text) # If no Text or Reference is found, message is given. if not self.search_results: + self.application.set_normal_cursor() reference_separators = { 'verse': get_reference_separator('sep_v_display'), 'range': get_reference_separator('sep_r_display'), @@ -759,7 +760,9 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find ' 'anything with your search.

' 'If you tried to search with Scripture Reference, please make sure that ' - 'your reference follows one of these patterns:%s' + 'your reference follows one of these patterns:%sBook names may be shortened ' + 'from full names
but must not contain any ' + 'additional dots.' % UiStrings().BibleScriptureError % reference_separators)) # Finalizing the search if not self.quickLockButton.isChecked(): From 6de4a5c9233f72255a13ce807c916f8c2c59144c Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Wed, 9 Mar 2016 00:46:47 +0200 Subject: [PATCH 08/69] In this commit: - Replace '. ' with ' ' in Reference search, so for an example Gen. 1 works - Modified related error messages To do: - Write tests Optional fixes that are not yet done/may not be done. - Block spaces + single character combos since they kind of break the search. - Listing search results when typing for Text search --- openlp/core/common/uistrings.py | 5 +++-- openlp/plugins/bibles/lib/manager.py | 6 ++---- openlp/plugins/bibles/lib/mediaitem.py | 11 ++++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 8e98fd009..5514b0ffe 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -161,8 +161,9 @@ class UiStrings(object): '(list)sChapter%(verse)sVerse%(range)sVerse | John 3%(verse)' 's16%(range)s17%(list)s5%(verse)s7%(range)s9
Book Chapter%' '(verse)sVerse%(range)sChapter%(verse)sVerse | John 3%(verse)' - 's16%(range)s4%(verse)s2

', - 'Please pay attention to the appended "s" of the wildcards and refrain ' + 's16%(range)s4%(verse)s2

Book names may be shortened ' + 'from full names, for an example: Joh 3 = John 3' + , 'Please pay attention to the appended "s" of the wildcards and refrain ' 'from translating the words inside the names in the brackets.') self.BibleShortSearch = translate('OpenLP.Ui', 'The keyword you have entered is empty or shorter ' 'than 3 characters long.\nPlease try again with ' diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index b74bc6fab..009f7e65d 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -280,10 +280,8 @@ class BibleManager(RegistryProperties): self.main_window.information_message( translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find anything ' - 'with your search.

' - 'Please make sure that your reference follows one of these patterns:%sBook names may be ' - 'shortened from full names
but must not contain any ' - 'additional dots.' + 'with your search.

' + 'Please make sure that your reference follows one of these patterns:%s' % UiStrings().BibleScriptureError % reference_separators)) return None diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index d5fea2968..e761b991d 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -662,7 +662,10 @@ class BibleMediaItem(MediaManagerItem): self.application.process_events() bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() - text = self.quick_search_edit.text() + # Get input from field and replace '. ' with '' + text_direct = self.quick_search_edit.text() + text = text_direct.replace('. ', ' ') + # This will check if field has any '.' and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1 if self.quick_search_edit.current_search_type() == BibleSearch.Reference: # We are doing a 'Reference Search'. self.search_results = self.plugin.manager.get_verses(bible, text) @@ -759,10 +762,8 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.BibleManager', 'Nothing found'), translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find ' 'anything with your search.

' - 'If you tried to search with Scripture Reference, please make sure that ' - 'your reference follows one of these patterns:%sBook names may be shortened ' - 'from full names
but must not contain any ' - 'additional dots.' + 'If you tried to search with Scripture Reference, please make
sure that ' + 'your reference follows one of these patterns:%s' % UiStrings().BibleScriptureError % reference_separators)) # Finalizing the search if not self.quickLockButton.isChecked(): From d61ded487e1ec8c0e87fafed86bcd3250560b612 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Wed, 9 Mar 2016 02:25:07 +0200 Subject: [PATCH 09/69] In this Merge: - Min. search lenght no longer counts spaces. - Bolded part of "Empty or too short" error message - Modified some comments To do: - Write tests Optional fixes that are not yet done/may not be done. - Listing search results when typing for Text search --- openlp/core/common/uistrings.py | 10 +++++----- openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 5514b0ffe..27b5e8b42 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -165,11 +165,11 @@ class UiStrings(object): 'from full names, for an example: Joh 3 = John 3' , 'Please pay attention to the appended "s" of the wildcards and refrain ' 'from translating the words inside the names in the brackets.') - self.BibleShortSearch = translate('OpenLP.Ui', 'The keyword you have entered is empty or shorter ' - 'than 3 characters long.\nPlease try again with ' - 'a longer keyword.\n\nYou can separate different keywords by ' - 'a space to search for all of your keywords and you can ' - 'separate them by a comma to search for one of them.') + self.BibleShortSearch = translate('OpenLP.Ui', 'The search you have entered is empty or shorter ' + 'than 3 characters long.
Please try again with ' + 'a longer search.


You can separate different ' + 'keywords by a space to search for all of your keywords and you ' + 'can separate them by a comma to search for one of them.') diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 009f7e65d..68410bd0b 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -335,7 +335,7 @@ class BibleManager(RegistryProperties): 'Please use the Scripture Reference Search instead.') ) return None - if len(text) < 3 or str.isspace(text): + if len(text) - text.count(' ') < 3: self.main_window.information_message( ('%s' % UiStrings().BibleShortSearchTitle), ('%s' % UiStrings().BibleShortSearch)) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index e761b991d..cd097fb47 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -706,9 +706,9 @@ class BibleMediaItem(MediaManagerItem): if second_bible and self.search_results: self.second_search_results = \ self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) - # If keyword is shorter than 3, message is given and search is finalized. + # If keyword is shorter than 3 (not including spaces), message is given and search is finalized. # This needs to be here in order to avoid deadlock/duplicate errors. - if len(text) < 3 or str.isspace(text): + if len(text) - text.count(' ') < 3: self.main_window.information_message( ('%s' % UiStrings().BibleShortSearchTitle), ('%s' % UiStrings().BibleShortSearch)) @@ -723,8 +723,7 @@ class BibleMediaItem(MediaManagerItem): self.application.set_normal_cursor() # Text search starts here if no reference was found and keyword is longer than 2. # This is required in order to avoid duplicate error messages for short keywords. - # If only spaces are searched OLP becomes unresponsive and may crash eventually. "isspace" prevents this. - if not self.search_results and len(text) > 2 and not str.isspace(text): + if not self.search_results and len(text) - text.count(' ') > 2: self.application.set_busy_cursor() bibles = self.plugin.manager.get_bibles() self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) From a78565568f5d9a6faf1be8a59c82b1e79bc5ef58 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Tue, 15 Mar 2016 12:30:37 +0200 Subject: [PATCH 10/69] Pep8 fixes To do: Test(s) --- openlp/core/common/uistrings.py | 7 ++---- openlp/plugins/bibles/lib/mediaitem.py | 31 +++++++++++++++++--------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 27b5e8b42..6ef071a6f 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -162,14 +162,11 @@ class UiStrings(object): 's16%(range)s17%(list)s5%(verse)s7%(range)s9
Book Chapter%' '(verse)sVerse%(range)sChapter%(verse)sVerse | John 3%(verse)' 's16%(range)s4%(verse)s2

Book names may be shortened ' - 'from full names, for an example: Joh 3 = John 3' - , 'Please pay attention to the appended "s" of the wildcards and refrain ' + 'from full names, for an example: Joh 3 = John 3', + 'Please pay attention to the appended "s" of the wildcards and refrain ' 'from translating the words inside the names in the brackets.') self.BibleShortSearch = translate('OpenLP.Ui', 'The search you have entered is empty or shorter ' 'than 3 characters long.
Please try again with ' 'a longer search.


You can separate different ' 'keywords by a space to search for all of your keywords and you ' 'can separate them by a comma to search for one of them.') - - - diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index cd097fb47..65bdb994e 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -427,7 +427,7 @@ class BibleMediaItem(MediaManagerItem): def update_auto_completer(self): """ 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 reference search, otherwise the auto completion list is removed. + only updated when we are doing reference or combined search, in text search the completion list is removed. """ log.debug('update_auto_completer') # Save the current search type to the configuration. @@ -754,16 +754,25 @@ class BibleMediaItem(MediaManagerItem): if not self.search_results: self.application.set_normal_cursor() reference_separators = { - 'verse': get_reference_separator('sep_v_display'), - 'range': get_reference_separator('sep_r_display'), - 'list': get_reference_separator('sep_l_display')} - self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'Nothing found'), - translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find ' - 'anything with your search.

' - 'If you tried to search with Scripture Reference, please make
sure that ' - 'your reference follows one of these patterns:%s' - % UiStrings().BibleScriptureError % reference_separators)) + 'verse': get_reference_separator('sep_v_display'), + 'range': get_reference_separator('sep_r_display'), + 'list': get_reference_separator('sep_l_display')} + self.main_window.information_message(translate('BiblesPlugin.BibleManager', 'Nothing found'), + translate('BiblesPlugin.BibleManager', 'OpenLP ' + 'couldn’t find ' + 'anything with your' + ' search.' + '

' + 'If you tried to ' + 'search with ' + 'Scripture ' + 'Reference, please ' + 'make
sure that ' + 'your reference ' + 'follows one of ' + 'these patterns:%s' + % UiStrings().BibleScriptureError % + reference_separators)) # Finalizing the search if not self.quickLockButton.isChecked(): self.list_view.clear() From 1d67072dfd62ac06f45f3519733a7a2dca380bc1 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 4 Apr 2016 02:55:10 +0300 Subject: [PATCH 12/69] In this merge: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactored the code for combined search. - Added: def on_quick_reference_search(self): and moved definition of reference search there. - Added: def on_quick_text_search(self): and moved definition of text search there. - Removed some un-needed code duplicates (Double finalizing, 3rd normalizing of mouse cursor) - Searching scripture ref with shorter than 3 char search is now possible (G1 = Genesis 1) Also removed “Search” from “Search Text or Reference…” since it does not fit the box properly. --- openlp/plugins/bibles/lib/mediaitem.py | 137 +++++++++++-------------- 1 file changed, 59 insertions(+), 78 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 65bdb994e..7a88de564 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -312,7 +312,7 @@ class BibleMediaItem(MediaManagerItem): self.quick_search_edit.set_search_types([ (BibleSearch.Combined, ':/bibles/bibles_search_combined.png', translate('BiblesPlugin.MediaItem', 'Text or Scripture Reference'), - translate('BiblesPlugin.MediaItem', 'Search Text or Scripture Reference...')), + translate('BiblesPlugin.MediaItem', 'Text or Scripture Reference...')), (BibleSearch.Reference, ':/bibles/bibles_search_reference.png', translate('BiblesPlugin.MediaItem', 'Scripture Reference'), translate('BiblesPlugin.MediaItem', 'Search Scripture Reference...')), @@ -652,6 +652,53 @@ class BibleMediaItem(MediaManagerItem): self.check_search_result() self.application.set_normal_cursor() + def on_quick_reference_search(self): + # We are doing a 'Reference Search'. + bible = self.quickVersionComboBox.currentText() + second_bible = self.quickSecondComboBox.currentText() + # Get input from field and replace '. ' with '' + text_direct = self.quick_search_edit.text() + text = text_direct.replace('. ', ' ') + if self.quick_search_edit.current_search_type() == BibleSearch.Reference: + self.search_results = self.plugin.manager.get_verses(bible, text) + else: + self.search_results = self.plugin.manager.get_verses_combined(bible, text) + if second_bible and self.search_results: + self.second_search_results = \ + self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) + + def on_quick_text_search(self): + # We are doing a 'Text Search'. + bible = self.quickVersionComboBox.currentText() + second_bible = self.quickSecondComboBox.currentText() + text = self.quick_search_edit.text() + self.application.set_busy_cursor() + bibles = self.plugin.manager.get_bibles() + self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) + if second_bible and self.search_results: + text = [] + new_search_results = [] + count = 0 + passage_not_found = False + for verse in self.search_results: + db_book = bibles[second_bible].get_book_by_book_ref_id(verse.book.book_reference_id) + if not db_book: + log.debug('Passage "%s %d:%d" not found in Second Bible' % + (verse.book.name, verse.chapter, verse.verse)) + passage_not_found = True + count += 1 + continue + new_search_results.append(verse) + text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse)) + if passage_not_found: + self.main_window.information_message( + translate('BiblesPlugin.MediaItem', 'Information'), + translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' + 'that are in the main Bible. Only verses found in both Bibles will be shown. %d ' + 'verses have not been included in the results.') % count) + self.search_results = new_search_results + self.second_search_results = bibles[second_bible].get_verses(text) + def on_quick_search_button(self): """ Does a quick search and saves the search results. Quick search can be: @@ -662,94 +709,28 @@ class BibleMediaItem(MediaManagerItem): self.application.process_events() bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() - # Get input from field and replace '. ' with '' - text_direct = self.quick_search_edit.text() - text = text_direct.replace('. ', ' ') + text = self.quick_search_edit.text() # This will check if field has any '.' and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1 if self.quick_search_edit.current_search_type() == BibleSearch.Reference: - # We are doing a 'Reference Search'. - self.search_results = self.plugin.manager.get_verses(bible, text) - if second_bible and self.search_results: - self.second_search_results = \ - self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) + # We are doing a 'Reference Search'. (Get script from def on_quick_reference_search) + self.on_quick_reference_search() elif self.quick_search_edit.current_search_type() == BibleSearch.Text: - # We are doing a 'Text Search'. - self.application.set_busy_cursor() - bibles = self.plugin.manager.get_bibles() - self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) - if second_bible and self.search_results: - text = [] - new_search_results = [] - count = 0 - passage_not_found = False - for verse in self.search_results: - db_book = bibles[second_bible].get_book_by_book_ref_id(verse.book.book_reference_id) - if not db_book: - log.debug('Passage "%s %d:%d" not found in Second Bible' % - (verse.book.name, verse.chapter, verse.verse)) - passage_not_found = True - count += 1 - continue - new_search_results.append(verse) - text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse)) - if passage_not_found: - self.main_window.information_message( - translate('BiblesPlugin.MediaItem', 'Information'), - translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' - 'that are in the main Bible. Only verses found in both Bibles will be shown. %d ' - 'verses have not been included in the results.') % count) - self.search_results = new_search_results - self.second_search_results = bibles[second_bible].get_verses(text) - # Combined search, starting with reference search (combined) + # We are doing a 'Text Search'. (Get script from def on_quick_text_search) + self.on_quick_text_search() + # Combined search, starting with reference search. elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: - self.search_results = self.plugin.manager.get_verses_combined(bible, text) - if second_bible and self.search_results: - self.second_search_results = \ - self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) + self.on_quick_reference_search() # If keyword is shorter than 3 (not including spaces), message is given and search is finalized. - # This needs to be here in order to avoid deadlock/duplicate errors. - if len(text) - text.count(' ') < 3: + # It's actually to find verses with less than 3 chars (Eg. G1 = Genesis 1) thus this error is not shown if + # any results are found. This check needs to be here in order to avoid duplicate errors. + if not self.search_results and len(text) - text.count(' ') < 3: self.main_window.information_message( ('%s' % UiStrings().BibleShortSearchTitle), ('%s' % UiStrings().BibleShortSearch)) - if not self.quickLockButton.isChecked(): - self.list_view.clear() - if self.list_view.count() != 0 and self.search_results: - self.__check_second_bible(bible, second_bible) - elif self.search_results: - self.display_results(bible, second_bible) - self.quickSearchButton.setEnabled(True) - self.check_search_result() - self.application.set_normal_cursor() # Text search starts here if no reference was found and keyword is longer than 2. # This is required in order to avoid duplicate error messages for short keywords. if not self.search_results and len(text) - text.count(' ') > 2: - self.application.set_busy_cursor() - bibles = self.plugin.manager.get_bibles() - self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) - if second_bible and self.search_results: - text = [] - new_search_results = [] - count = 0 - passage_not_found = False - for verse in self.search_results: - db_book = bibles[second_bible].get_book_by_book_ref_id(verse.book.book_reference_id) - if not db_book: - log.debug('Passage "%s %d:%d" not found in Second Bible' % - (verse.book.name, verse.chapter, verse.verse)) - passage_not_found = True - count += 1 - continue - new_search_results.append(verse) - text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse)) - if passage_not_found: - self.main_window.information_message( - translate('BiblesPlugin.MediaItem', 'Information'), - translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' - 'that are in the main Bible. Only verses found in both Bibles will be shown. %d ' - 'verses have not been included in the results.') % count) - self.search_results = new_search_results - self.second_search_results = bibles[second_bible].get_verses(text) + self.on_quick_text_search() # If no Text or Reference is found, message is given. if not self.search_results: self.application.set_normal_cursor() From edcf0379eef681d3558dd874b2c860ae8976fe67 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 4 Apr 2016 03:43:29 +0300 Subject: [PATCH 13/69] Noticed one line was longer than 120, splitted it. --- openlp/plugins/bibles/lib/mediaitem.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 7a88de564..a28e8cd1a 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -694,8 +694,9 @@ class BibleMediaItem(MediaManagerItem): self.main_window.information_message( translate('BiblesPlugin.MediaItem', 'Information'), translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' - 'that are in the main Bible. Only verses found in both Bibles will be shown. %d ' - 'verses have not been included in the results.') % count) + 'that are in the main Bible. Only verses found in both Bibles ' + 'will be shown. %d verses have not been included ' + 'in the results.') % count) self.search_results = new_search_results self.second_search_results = bibles[second_bible].get_verses(text) From e94bf8acd9b714eecf33d8ca861516fe407b0d1e Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 4 Apr 2016 04:11:42 +0300 Subject: [PATCH 14/69] - Noticed I had left an old comment to a wrong place. (Moved it to def on_quick_reference_search) --- 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 a28e8cd1a..48e3a1001 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -657,6 +657,7 @@ class BibleMediaItem(MediaManagerItem): bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() # Get input from field and replace '. ' with '' + # This will check if field has any '.' and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1 text_direct = self.quick_search_edit.text() text = text_direct.replace('. ', ' ') if self.quick_search_edit.current_search_type() == BibleSearch.Reference: @@ -711,7 +712,6 @@ class BibleMediaItem(MediaManagerItem): bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() text = self.quick_search_edit.text() - # This will check if field has any '.' and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1 if self.quick_search_edit.current_search_type() == BibleSearch.Reference: # We are doing a 'Reference Search'. (Get script from def on_quick_reference_search) self.on_quick_reference_search() From 54f720e5a26939df8824e8ebb18fe9e7f646f3d1 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Wed, 6 Apr 2016 07:09:35 +0300 Subject: [PATCH 15/69] In this merge: Splitted scripture reference error into small pieces, built error from them. This still needs to be moved away from uistrings.py --- openlp/core/common/uistrings.py | 35 ++++++++++++++++---------- openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 3 ++- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index fcaf04f2b..96cfb90a8 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -152,21 +152,30 @@ class UiStrings(object): self.View = translate('OpenLP.Ui', 'View') self.ViewMode = translate('OpenLP.Ui', 'View Mode') self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short') - self.BibleScriptureError = translate('OpenLP.Ui', '

Book Chapter | John 3:16
' - 'Book Chapter%(range)sChapter | John 3%(range)s4
' - 'Book Chapter%(verse)sVerse%(range)sVerse | John 3%(verse)' - 's16%(range)s17
Book Chapter%(verse)sVerse%(range)sVerse%' - '(list)sVerse%(range)sVerse | John 3%(verse)s16-17%(list)s20%' - '(range)s22
Book Chapter%(verse)sVerse%(range)sVerse%' - '(list)sChapter%(verse)sVerse%(range)sVerse | John 3%(verse)' - 's16%(range)s17%(list)s5%(verse)s7%(range)s9
Book Chapter%' - '(verse)sVerse%(range)sChapter%(verse)sVerse | John 3%(verse)' - 's16%(range)s4%(verse)s2

Book names may be shortened ' - 'from full names, for an example: Joh 3 = John 3', - 'Please pay attention to the appended "s" of the wildcards and refrain ' - 'from translating the words inside the names in the brackets.') self.BibleShortSearch = translate('OpenLP.Ui', 'The search you have entered is empty or shorter ' 'than 3 characters long.
Please try again with ' 'a longer search.


You can separate different ' 'keywords by a space to search for all of your keywords and you ' 'can separate them by a comma to search for one of them.') + import itertools + #b = book, c = chapter, ve = verse + bc = translate('OpenLP.Ui', 'Book Chapter') + cha = translate('OpenLP.Ui', 'Chapter') + ver = translate('OpenLP.Ui', 'Verse') + interval = ' | ' + psalm = translate('OpenLP.Ui', 'Psalm') + may_shorten = translate('OpenLP.Ui', 'Book names may be shortened from full names, for an example Ps 23 = ' + 'Psalm 23') + + bible_items = [bc, interval, psalm, ' 23
', + bc, '%(range)s', cha, interval, psalm, ' 23%(range)s24
', + bc, '%(verse)s', ver, '%(range)s', ver, interval, psalm, ' 23%(verse)s1%(range)s2
', + bc, '%(verse)s', ver, '%(range)s', ver, '%(list)s', ver, '%(range)s', ver, interval, psalm, + ' 23%(verse)s1%(range)s2%(list)s5%(range)s6
', + bc, '%(verse)s', ver, '%(range)s', ver, '%(list)s', cha, '%(verse)s', ver, '%(range)s', ver, + interval, psalm, ' 23%(verse)s1%(range)s2%(list)s24%(verse)s1%(range)s3
', + bc, '%(verse)s', ver, '%(range)s', cha, '%(verse)s', ver, interval, psalm, + ' 23%(verse)s1%(range)s24%(verse)s1

', may_shorten] + itertools.chain.from_iterable(itertools.repeat(x, 1) if isinstance(x, str) else x for x in bible_items) + bible_scripture_error_all = ''.join(str(e) for e in bible_items) + self.BibleScriptureError = bible_scripture_error_all diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 68410bd0b..3b884ba69 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -281,7 +281,7 @@ class BibleManager(RegistryProperties): translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find anything ' 'with your search.

' - 'Please make sure that your reference follows one of these patterns:
%s' + 'Please make sure that your reference follows one of these patterns:

%s' % UiStrings().BibleScriptureError % reference_separators)) return None diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 48e3a1001..fc970bdbf 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -752,7 +752,8 @@ class BibleMediaItem(MediaManagerItem): 'make
sure that ' 'your reference ' 'follows one of ' - 'these patterns:%s' + 'these patterns:' + '

%s' % UiStrings().BibleScriptureError % reference_separators)) # Finalizing the search From 34231003ce292b9e64102636a286439aa1c03193 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 9 Apr 2016 17:43:02 +0300 Subject: [PATCH 16/69] Noticed "No bibles available" was defined 3 times > Moved it to uistrings. Added "Must have bibles" condition for other error messages in combined search. To do: Add a setting for controlling visibility of the no results error, it may be of annoyance. Tests... --- openlp/core/common/uistrings.py | 28 +++++++++++++++++--------- openlp/plugins/bibles/lib/manager.py | 25 +++++++++-------------- openlp/plugins/bibles/lib/mediaitem.py | 7 +++++-- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 96cfb90a8..85a3fc1fc 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -23,6 +23,7 @@ The :mod:`uistrings` module provides standard strings for OpenLP. """ import logging +import itertools from openlp.core.common import translate @@ -151,23 +152,28 @@ class UiStrings(object): self.Version = translate('OpenLP.Ui', 'Version') self.View = translate('OpenLP.Ui', 'View') self.ViewMode = translate('OpenLP.Ui', 'View Mode') + # Translations used in both, bibles\lib\mediaitem.py and bibles\lib\manager.py self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short') self.BibleShortSearch = translate('OpenLP.Ui', 'The search you have entered is empty or shorter ' 'than 3 characters long.
Please try again with ' 'a longer search.


You can separate different ' 'keywords by a space to search for all of your keywords and you ' 'can separate them by a comma to search for one of them.') - import itertools - #b = book, c = chapter, ve = verse - bc = translate('OpenLP.Ui', 'Book Chapter') - cha = translate('OpenLP.Ui', 'Chapter') - ver = translate('OpenLP.Ui', 'Verse') + self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available') + self.BibleNoBibles = translate('OpenLP.Ui', 'There are no Bibles currently installed.

' + 'Please use the Import Wizard to install one or more Bibles.') + # Scripture reference error combined from small translation stings by using itertools. + book_chapter = translate('OpenLP.Ui', 'Book Chapter') + bc = book_chapter + chapter = translate('OpenLP.Ui', 'Chapter') + cha = chapter + verse = translate('OpenLP.Ui', 'Verse') + ver = verse interval = ' | ' psalm = translate('OpenLP.Ui', 'Psalm') may_shorten = translate('OpenLP.Ui', 'Book names may be shortened from full names, for an example Ps 23 = ' 'Psalm 23') - - bible_items = [bc, interval, psalm, ' 23
', + bible_scripture_items = [bc, interval, psalm, ' 23
', bc, '%(range)s', cha, interval, psalm, ' 23%(range)s24
', bc, '%(verse)s', ver, '%(range)s', ver, interval, psalm, ' 23%(verse)s1%(range)s2
', bc, '%(verse)s', ver, '%(range)s', ver, '%(list)s', ver, '%(range)s', ver, interval, psalm, @@ -176,6 +182,8 @@ class UiStrings(object): interval, psalm, ' 23%(verse)s1%(range)s2%(list)s24%(verse)s1%(range)s3
', bc, '%(verse)s', ver, '%(range)s', cha, '%(verse)s', ver, interval, psalm, ' 23%(verse)s1%(range)s24%(verse)s1

', may_shorten] - itertools.chain.from_iterable(itertools.repeat(x, 1) if isinstance(x, str) else x for x in bible_items) - bible_scripture_error_all = ''.join(str(e) for e in bible_items) - self.BibleScriptureError = bible_scripture_error_all + itertools.chain.from_iterable(itertools.repeat(strings, 1) if isinstance(strings, str) else strings for strings + in bible_scripture_items) + bible_scripture_error_joined = ''.join(str(joined) for joined in bible_scripture_items) + # This is the actual + self.BibleScriptureError = bible_scripture_error_joined diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 3b884ba69..500a5c57d 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -262,10 +262,8 @@ class BibleManager(RegistryProperties): if not bible: if show_error: self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'No Bibles Available'), - translate('BiblesPlugin.BibleManager', 'There are no Bibles currently installed. Please use the ' - 'Import Wizard to install one or more Bibles.') - ) + ('%s' % UiStrings().BibleNoBiblesTitle), + ('%s' % UiStrings().BibleNoBibles)) return None language_selection = self.get_language_selection(bible) ref_list = parse_reference(verse_text, self.db_cache[bible], language_selection, book_ref_id) @@ -316,11 +314,8 @@ class BibleManager(RegistryProperties): log.debug('BibleManager.verse_search("%s", "%s")', bible, text) if not bible: self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'No Bibles Available'), - translate('BiblesPlugin.BibleManager', - 'There are no Bibles currently installed. Please use the Import Wizard to install one or ' - 'more Bibles.') - ) + ('%s' % UiStrings().BibleNoBiblesTitle), + ('%s' % UiStrings().BibleNoBibles)) return None # Check if the bible or second_bible is a web bible. web_bible = self.db_cache[bible].get_object(BibleMeta, 'download_source') @@ -345,15 +340,15 @@ class BibleManager(RegistryProperties): else: return None - def get_verses_combined(self, bible, verse_text, book_ref_id=False, show_error=False): + def get_verses_combined(self, bible, verse_text, book_ref_id=False, show_error=True): log.debug('BibleManager.get_verses("%s", "%s")', bible, verse_text) if not bible: if show_error: - self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'No Bibles Available'), - translate('BiblesPlugin.BibleManager', 'There are no Bibles currently installed. Please use the' - ' Import Wizard to install one or more Bibles.') - ) + if not bible: + self.main_window.information_message( + ('%s' % UiStrings().BibleNoBiblesTitle), + ('%s' % UiStrings().BibleNoBibles)) + return None return None language_selection = self.get_language_selection(bible) ref_list = parse_reference(verse_text, self.db_cache[bible], language_selection, book_ref_id) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index fc970bdbf..e30b0ec40 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -660,8 +660,10 @@ class BibleMediaItem(MediaManagerItem): # This will check if field has any '.' and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1 text_direct = self.quick_search_edit.text() text = text_direct.replace('. ', ' ') + # If we are doing "Reference" search, use the search from manager.py if self.quick_search_edit.current_search_type() == BibleSearch.Reference: self.search_results = self.plugin.manager.get_verses(bible, text) + # If we are doing "Combined Reference" search, use the get_verses_combined from manager.py (No error included) else: self.search_results = self.plugin.manager.get_verses_combined(bible, text) if second_bible and self.search_results: @@ -724,13 +726,14 @@ class BibleMediaItem(MediaManagerItem): # If keyword is shorter than 3 (not including spaces), message is given and search is finalized. # It's actually to find verses with less than 3 chars (Eg. G1 = Genesis 1) thus this error is not shown if # any results are found. This check needs to be here in order to avoid duplicate errors. - if not self.search_results and len(text) - text.count(' ') < 3: + # if no Bibles are installed, this message is not shown - "No bibles" message is whon instead. (and bible) + if not self.search_results and len(text) - text.count(' ') < 3 and bible: self.main_window.information_message( ('%s' % UiStrings().BibleShortSearchTitle), ('%s' % UiStrings().BibleShortSearch)) # Text search starts here if no reference was found and keyword is longer than 2. # This is required in order to avoid duplicate error messages for short keywords. - if not self.search_results and len(text) - text.count(' ') > 2: + if not self.search_results and len(text) - text.count(' ') > 2 and bible: self.on_quick_text_search() # If no Text or Reference is found, message is given. if not self.search_results: From eca11970f883835999ac1ddd9e1c3f7e8f054f4f Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 9 Apr 2016 22:29:44 +0300 Subject: [PATCH 17/69] Added "Search Settings" > "Don't show error fofr no results in combined quick search" checkbox for controlling whetever no results message is shown or not. --- openlp/plugins/bibles/bibleplugin.py | 3 ++- openlp/plugins/bibles/lib/biblestab.py | 34 +++++++++++++++++++++++++- openlp/plugins/bibles/lib/mediaitem.py | 3 ++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index ccc61ba56..eb35e298e 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -59,7 +59,8 @@ __default_settings__ = { 'bibles/range separator': '', 'bibles/list separator': '', 'bibles/end separator': '', - 'bibles/last directory import': '' + 'bibles/last directory import': '', + 'bibles/hide combined quick error': False } diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 5438d07f2..8d96a59db 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -128,6 +128,22 @@ class BiblesTab(SettingsTab): self.language_selection_layout.addWidget(self.language_selection_label) self.language_selection_layout.addWidget(self.language_selection_combo_box) self.right_layout.addWidget(self.language_selection_group_box) + # a + self.bible_search_settings_group_box = QtWidgets.QGroupBox(self.right_column) + self.bible_search_settings_group_box.setObjectName('bible_search_settings_group_box') + self.right_layout.addWidget(self.bible_search_settings_group_box) + + self.hide_combined_quick_error_check_box = QtWidgets.QCheckBox(self.bible_search_settings_group_box) + self.hide_combined_quick_error_check_box.setObjectName('hide_combined_quick_error_check_box') + self.right_layout.addWidget(self.hide_combined_quick_error_check_box) + + + #self.is_verse_number_visible_check_box = QtWidgets.QCheckBox(self.verse_display_group_box) + #self.is_verse_number_visible_check_box.setObjectName('is_verse_number_visible_check_box') + #self.verse_display_layout.addRow(self.is_verse_number_visible_check_box) + + + # b self.left_layout.addStretch() self.right_layout.addStretch() # Signals and slots @@ -151,6 +167,8 @@ class BiblesTab(SettingsTab): self.end_separator_line_edit.editingFinished.connect(self.on_end_separator_line_edit_finished) Registry().register_function('theme_update_list', self.update_theme_list) self.language_selection_combo_box.activated.connect(self.on_language_selection_combo_box_changed) + self.hide_combined_quick_error_check_box.stateChanged.connect\ + (self.on_hide_combined_quick_error_check_box_changed) def retranslateUi(self): self.verse_display_group_box.setTitle(translate('BiblesPlugin.BiblesTab', 'Verse Display')) @@ -194,7 +212,10 @@ class BiblesTab(SettingsTab): LanguageSelection.Application, translate('BiblesPlugin.BiblesTab', 'Application Language')) self.language_selection_combo_box.setItemText( LanguageSelection.English, translate('BiblesPlugin.BiblesTab', 'English')) - + self.bible_search_settings_group_box.setTitle(translate('BiblesPlugin.BiblesTab', 'Search Settings')) + self.hide_combined_quick_error_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Don\'t show error ' + 'for no results in ' + 'combined quick search')) def on_bible_theme_combo_box_changed(self): self.bible_theme = self.bible_theme_combo_box.currentText() @@ -302,6 +323,13 @@ class BiblesTab(SettingsTab): self.end_separator_line_edit.setText(get_reference_separator('sep_e_default')) self.end_separator_line_edit.setPalette(self.get_grey_text_palette(True)) + def on_hide_combined_quick_error_check_box_changed(self, check_state): + """ + Event handler for the 'hide_combined_quick_error' check box + """ + self.hide_combined_quick_error = (check_state == QtCore.Qt.Checked) + #self.check_hide_combined_quick_error() + def load(self): settings = Settings() settings.beginGroup(self.settings_section) @@ -355,6 +383,9 @@ class BiblesTab(SettingsTab): self.end_separator_check_box.setChecked(True) self.language_selection = settings.value('book name language') self.language_selection_combo_box.setCurrentIndex(self.language_selection) + self.hide_combined_quick_error = settings.value('hide combined quick error') + self.hide_combined_quick_error_check_box.setChecked(self.hide_combined_quick_error) + #self.check_hide_combined_quick_error() settings.endGroup() def save(self): @@ -386,6 +417,7 @@ class BiblesTab(SettingsTab): if self.language_selection != settings.value('book name language'): settings.setValue('book name language', self.language_selection) self.settings_form.register_post_process('bibles_load_list') + settings.setValue('hide combined quick error', self.hide_combined_quick_error) settings.endGroup() if self.tab_visited: self.settings_form.register_post_process('bibles_config_updated') diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index e30b0ec40..456568624 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -736,7 +736,8 @@ class BibleMediaItem(MediaManagerItem): if not self.search_results and len(text) - text.count(' ') > 2 and bible: self.on_quick_text_search() # If no Text or Reference is found, message is given. - if not self.search_results: + if not self.search_results and not \ + Settings().value(self.settings_section + '/hide combined quick error'): self.application.set_normal_cursor() reference_separators = { 'verse': get_reference_separator('sep_v_display'), From 074ed7e3b9b313fac2ddb576948b8d3c653b042d Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 9 Apr 2016 22:53:32 +0300 Subject: [PATCH 18/69] - Fixed layout for the new setting, cleanup for biblestab.py from process. --- openlp/plugins/bibles/lib/biblestab.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 8d96a59db..6ca411ec7 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -128,22 +128,14 @@ class BiblesTab(SettingsTab): self.language_selection_layout.addWidget(self.language_selection_label) self.language_selection_layout.addWidget(self.language_selection_combo_box) self.right_layout.addWidget(self.language_selection_group_box) - # a self.bible_search_settings_group_box = QtWidgets.QGroupBox(self.right_column) self.bible_search_settings_group_box.setObjectName('bible_search_settings_group_box') self.right_layout.addWidget(self.bible_search_settings_group_box) - self.hide_combined_quick_error_check_box = QtWidgets.QCheckBox(self.bible_search_settings_group_box) self.hide_combined_quick_error_check_box.setObjectName('hide_combined_quick_error_check_box') - self.right_layout.addWidget(self.hide_combined_quick_error_check_box) - - - #self.is_verse_number_visible_check_box = QtWidgets.QCheckBox(self.verse_display_group_box) - #self.is_verse_number_visible_check_box.setObjectName('is_verse_number_visible_check_box') - #self.verse_display_layout.addRow(self.is_verse_number_visible_check_box) - - - # b + self.search_settings_layout = QtWidgets.QFormLayout(self.bible_search_settings_group_box) + self.search_settings_layout.setObjectName('search_settings_layout') + self.search_settings_layout.addRow(self.hide_combined_quick_error_check_box) self.left_layout.addStretch() self.right_layout.addStretch() # Signals and slots @@ -216,6 +208,7 @@ class BiblesTab(SettingsTab): self.hide_combined_quick_error_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Don\'t show error ' 'for no results in ' 'combined quick search')) + def on_bible_theme_combo_box_changed(self): self.bible_theme = self.bible_theme_combo_box.currentText() @@ -328,7 +321,6 @@ class BiblesTab(SettingsTab): Event handler for the 'hide_combined_quick_error' check box """ self.hide_combined_quick_error = (check_state == QtCore.Qt.Checked) - #self.check_hide_combined_quick_error() def load(self): settings = Settings() @@ -385,7 +377,6 @@ class BiblesTab(SettingsTab): self.language_selection_combo_box.setCurrentIndex(self.language_selection) self.hide_combined_quick_error = settings.value('hide combined quick error') self.hide_combined_quick_error_check_box.setChecked(self.hide_combined_quick_error) - #self.check_hide_combined_quick_error() settings.endGroup() def save(self): From c0311ed8c9e8a621e398841c7aad563739629b5a Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sun, 10 Apr 2016 00:08:49 +0300 Subject: [PATCH 19/69] Noticed the identification for scripture reference error got messed at some point, fixed it. Also renamed "Interval" to "gap" to make constructing the message less painful. --- openlp/core/common/uistrings.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 85a3fc1fc..c84c3c600 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -169,21 +169,21 @@ class UiStrings(object): cha = chapter verse = translate('OpenLP.Ui', 'Verse') ver = verse - interval = ' | ' + gap = ' | ' psalm = translate('OpenLP.Ui', 'Psalm') may_shorten = translate('OpenLP.Ui', 'Book names may be shortened from full names, for an example Ps 23 = ' 'Psalm 23') - bible_scripture_items = [bc, interval, psalm, ' 23
', - bc, '%(range)s', cha, interval, psalm, ' 23%(range)s24
', - bc, '%(verse)s', ver, '%(range)s', ver, interval, psalm, ' 23%(verse)s1%(range)s2
', - bc, '%(verse)s', ver, '%(range)s', ver, '%(list)s', ver, '%(range)s', ver, interval, psalm, - ' 23%(verse)s1%(range)s2%(list)s5%(range)s6
', - bc, '%(verse)s', ver, '%(range)s', ver, '%(list)s', cha, '%(verse)s', ver, '%(range)s', ver, - interval, psalm, ' 23%(verse)s1%(range)s2%(list)s24%(verse)s1%(range)s3
', - bc, '%(verse)s', ver, '%(range)s', cha, '%(verse)s', ver, interval, psalm, - ' 23%(verse)s1%(range)s24%(verse)s1

', may_shorten] + bible_scripture_items = [bc, gap, psalm, ' 23
', + bc, '%(range)s', cha, gap, psalm, ' 23%(range)s24
', + bc, '%(verse)s', ver, '%(range)s', ver, gap, psalm, ' 23%(verse)s1%(range)s2
', + bc, '%(verse)s', ver, '%(range)s', ver, '%(list)s', ver, '%(range)s', ver, gap, psalm, + ' 23%(verse)s1%(range)s2%(list)s5%(range)s6
', + bc, '%(verse)s', ver, '%(range)s', ver, '%(list)s', cha, '%(verse)s', ver, '%(range)s', + ver, gap, psalm, ' 23%(verse)s1%(range)s2%(list)s24%(verse)s1%(range)s3
', bc, + '%(verse)s', ver, '%(range)s', cha, '%(verse)s', ver, gap, psalm, + ' 23%(verse)s1%(range)s24%(verse)s1

', may_shorten] itertools.chain.from_iterable(itertools.repeat(strings, 1) if isinstance(strings, str) else strings for strings in bible_scripture_items) bible_scripture_error_joined = ''.join(str(joined) for joined in bible_scripture_items) - # This is the actual + # This is what gets called to other files. self.BibleScriptureError = bible_scripture_error_joined From cb421a8fd7a6b6ef7aedfd73bc9f939aa9d9541a Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sun, 10 Apr 2016 21:50:22 +0300 Subject: [PATCH 20/69] In this commit: - Cleanup of the scripture reference error. (Now using full names, removed one un-needed line) - Added more comments - Removed def get_verses_combined, now triggering the error message on mediaitem based on search mode instead. --- openlp/core/common/uistrings.py | 30 +++++----- openlp/plugins/bibles/lib/manager.py | 37 +++--------- openlp/plugins/bibles/lib/mediaitem.py | 78 ++++++++++++++++---------- 3 files changed, 71 insertions(+), 74 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index c84c3c600..283cd7251 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -164,26 +164,22 @@ class UiStrings(object): 'Please use the Import Wizard to install one or more Bibles.') # Scripture reference error combined from small translation stings by using itertools. book_chapter = translate('OpenLP.Ui', 'Book Chapter') - bc = book_chapter chapter = translate('OpenLP.Ui', 'Chapter') - cha = chapter verse = translate('OpenLP.Ui', 'Verse') - ver = verse gap = ' | ' psalm = translate('OpenLP.Ui', 'Psalm') may_shorten = translate('OpenLP.Ui', 'Book names may be shortened from full names, for an example Ps 23 = ' 'Psalm 23') - bible_scripture_items = [bc, gap, psalm, ' 23
', - bc, '%(range)s', cha, gap, psalm, ' 23%(range)s24
', - bc, '%(verse)s', ver, '%(range)s', ver, gap, psalm, ' 23%(verse)s1%(range)s2
', - bc, '%(verse)s', ver, '%(range)s', ver, '%(list)s', ver, '%(range)s', ver, gap, psalm, - ' 23%(verse)s1%(range)s2%(list)s5%(range)s6
', - bc, '%(verse)s', ver, '%(range)s', ver, '%(list)s', cha, '%(verse)s', ver, '%(range)s', - ver, gap, psalm, ' 23%(verse)s1%(range)s2%(list)s24%(verse)s1%(range)s3
', bc, - '%(verse)s', ver, '%(range)s', cha, '%(verse)s', ver, gap, psalm, - ' 23%(verse)s1%(range)s24%(verse)s1

', may_shorten] - itertools.chain.from_iterable(itertools.repeat(strings, 1) if isinstance(strings, str) else strings for strings - in bible_scripture_items) - bible_scripture_error_joined = ''.join(str(joined) for joined in bible_scripture_items) - # This is what gets called to other files. - self.BibleScriptureError = bible_scripture_error_joined + bible_scripture_items = \ + [book_chapter, gap, psalm, ' 23
', + book_chapter, '%(range)s', chapter, gap, psalm, ' 23%(range)s24
', + book_chapter, '%(verse)s', verse, '%(range)s', verse, gap, psalm, ' 23%(verse)s1%(range)s2
', + book_chapter, '%(verse)s', verse, '%(range)s', verse, '%(list)s', verse, '%(range)s', verse, gap, psalm, + ' 23%(verse)s1%(range)s2%(list)s5%(range)s6
', + book_chapter, '%(verse)s', verse, '%(range)s', verse, '%(list)s', chapter, '%(verse)s', verse, '%(range)s', + verse, gap, psalm, ' 23%(verse)s1%(range)s2%(list)s24%(verse)s1%(range)s3
', + book_chapter, '%(verse)s', verse, '%(range)s', chapter, '%(verse)s', verse, gap, psalm, + ' 23%(verse)s1%(range)s24%(verse)s1

', may_shorten] + itertools.chain.from_iterable(itertools.repeat(strings, 1) if isinstance(strings, str) + else strings for strings in bible_scripture_items) + self.BibleScriptureError = ''.join(str(joined) for joined in bible_scripture_items) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 03e24ee99..83f6b26bd 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -240,6 +240,7 @@ class BibleManager(RegistryProperties): """ Parses a scripture reference, fetches the verses from the Bible specified, and returns a list of ``Verse`` objects. + This function is called in \bibles\lib\mediaitem.py by def on_quick_search_button :param bible: Unicode. The Bible to use. :param verse_text: @@ -258,28 +259,20 @@ class BibleManager(RegistryProperties): :param show_error: """ log.debug('BibleManager.get_verses("%s", "%s")', bible, verse_text) + # If no bibles are installed, message is given. if not bible: if show_error: self.main_window.information_message( ('%s' % UiStrings().BibleNoBiblesTitle), ('%s' % UiStrings().BibleNoBibles)) return None + # Get the language for books. language_selection = self.get_language_selection(bible) ref_list = parse_reference(verse_text, self.db_cache[bible], language_selection, book_ref_id) if ref_list: return self.db_cache[bible].get_verses(ref_list, show_error) + # If nothing is found. Message is given if this is not combined search. (defined in mediaitem.py) else: - if show_error: - reference_separators = { - 'verse': get_reference_separator('sep_v_display'), - 'range': get_reference_separator('sep_r_display'), - 'list': get_reference_separator('sep_l_display')} - self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), - translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find anything ' - 'with your search.

' - 'Please make sure that your reference follows one of these patterns:


%s' - % UiStrings().BibleScriptureError % reference_separators)) return None def get_language_selection(self, bible): @@ -305,12 +298,14 @@ class BibleManager(RegistryProperties): def verse_search(self, bible, second_bible, text): """ Does a verse search for the given bible and text. + This function is called in \bibles\lib\mediaitem.py by def on_quick_search_button. :param bible: The bible to search in (unicode). :param second_bible: The second bible (unicode). We do not search in this bible. :param text: The text to search for (unicode). """ log.debug('BibleManager.verse_search("%s", "%s")', bible, text) + # If no bibles are installed, message is given. if not bible: self.main_window.information_message( ('%s' % UiStrings().BibleNoBiblesTitle), @@ -322,6 +317,7 @@ class BibleManager(RegistryProperties): if second_bible: second_web_bible = self.db_cache[second_bible].get_object(BibleMeta, 'download_source') if web_bible or second_web_bible: + # If either Bible is Web, cursor is reset to normal and message is given. self.application.set_normal_cursor() self.main_window.information_message( translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'), @@ -329,33 +325,18 @@ class BibleManager(RegistryProperties): 'Please use the Scripture Reference Search instead.') ) return None + # Shorter than 3 char searches break OpenLP with very long search times, thus they are blocked. if len(text) - text.count(' ') < 3: self.main_window.information_message( ('%s' % UiStrings().BibleShortSearchTitle), ('%s' % UiStrings().BibleShortSearch)) return None + # Fetch the results from db. If no results are found, return None, no message is given for this. elif text: return self.db_cache[bible].verse_search(text) else: return None - def get_verses_combined(self, bible, verse_text, book_ref_id=False, show_error=True): - log.debug('BibleManager.get_verses("%s", "%s")', bible, verse_text) - if not bible: - if show_error: - if not bible: - self.main_window.information_message( - ('%s' % UiStrings().BibleNoBiblesTitle), - ('%s' % UiStrings().BibleNoBibles)) - return None - return None - language_selection = self.get_language_selection(bible) - ref_list = parse_reference(verse_text, self.db_cache[bible], language_selection, book_ref_id) - if ref_list: - return self.db_cache[bible].get_verses(ref_list, show_error) - else: - return None - def save_meta_data(self, bible, version, copyright, permissions, book_name_language=None): """ Saves the bibles meta data. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 6003a860a..91fd6bfd7 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -654,35 +654,57 @@ class BibleMediaItem(MediaManagerItem): def on_quick_reference_search(self): # We are doing a 'Reference Search'. + # Set Bibles to use the text input from Quick search field. bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() # Get input from field and replace '. ' with '' # This will check if field has any '.' and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1 - text_direct = self.quick_search_edit.text() - text = text_direct.replace('. ', ' ') - # If we are doing "Reference" search, use the search from manager.py + text = self.quick_search_edit.text() + text = text.replace('. ', ' ') + # This is triggered on reference search, use the search from manager.py if self.quick_search_edit.current_search_type() == BibleSearch.Reference: self.search_results = self.plugin.manager.get_verses(bible, text) - # If we are doing "Combined Reference" search, use the get_verses_combined from manager.py (No error included) - else: - self.search_results = self.plugin.manager.get_verses_combined(bible, text) + if not self.search_results: + # if nothing is found, message is given. + # Get reference separators from settings. + reference_separators = { + 'verse': get_reference_separator('sep_v_display'), + 'range': get_reference_separator('sep_r_display'), + 'list': get_reference_separator('sep_l_display')} + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), + translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find anything ' + 'with your search.

' + 'Please make sure that your reference follows one of these patterns:


%s' + % UiStrings().BibleScriptureError % reference_separators)) + elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: + # In Combined Reference search no error is given if no results are found. (This would result in duplicate) + self.search_results = self.plugin.manager.get_verses(bible, text) if second_bible and self.search_results: self.second_search_results = \ self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) def on_quick_text_search(self): # We are doing a 'Text Search'. + # Set Bibles to use the text input from Quick search field. bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() text = self.quick_search_edit.text() + # This changes the curson to "Loading animation" self.application.set_busy_cursor() + # Get Bibles list bibles = self.plugin.manager.get_bibles() + # Add results to "search_results" self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) if second_bible and self.search_results: + # Set up variables, + # new_search_results is needed to make sure 2nd bible contains all verses. (And counting them on error) text = [] new_search_results = [] count = 0 passage_not_found = False + # Search second bible for results of search_results to make sure everythigns there. + # Count all the unfound passages. for verse in self.search_results: db_book = bibles[second_bible].get_book_by_book_ref_id(verse.book.book_reference_id) if not db_book: @@ -694,23 +716,27 @@ class BibleMediaItem(MediaManagerItem): new_search_results.append(verse) text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse)) if passage_not_found: + # This is for the 2nd Bible. self.main_window.information_message( translate('BiblesPlugin.MediaItem', 'Information'), translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' 'that are in the main Bible. Only verses found in both Bibles ' 'will be shown. %d verses have not been included ' 'in the results.') % count) + # Join the searches so only verses that are found on both Bibles are shown. self.search_results = new_search_results self.second_search_results = bibles[second_bible].get_verses(text) def on_quick_search_button(self): """ - Does a quick search and saves the search results. Quick search can be: - "Reference Search" or "Text Search" or Combined search. + This triggers the proper Quick search based on which search type is used. + "Eg. "Reference Search", "Text Search" or "Combined search". """ log.debug('Quick Search Button clicked') + # Disable the button while processing, get text from Quick search field. self.quickSearchButton.setEnabled(False) self.application.process_events() + # These need to be defined here too so the search results can be displayed. bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() text = self.quick_search_edit.text() @@ -720,20 +746,21 @@ class BibleMediaItem(MediaManagerItem): elif self.quick_search_edit.current_search_type() == BibleSearch.Text: # We are doing a 'Text Search'. (Get script from def on_quick_text_search) self.on_quick_text_search() - # Combined search, starting with reference search. elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: + # We are doing a 'Combined search'. Starting with reference search. self.on_quick_reference_search() - # If keyword is shorter than 3 (not including spaces), message is given and search is finalized. - # It's actually to find verses with less than 3 chars (Eg. G1 = Genesis 1) thus this error is not shown if - # any results are found. This check needs to be here in order to avoid duplicate errors. - # if no Bibles are installed, this message is not shown - "No bibles" message is whon instead. (and bible) + # If results are found, search will be finalized. + # This check needs to be here in order to avoid duplicate errors. + # If keyword is shorter than 3 (not including spaces), message is given. It's actually possible to find + # verses with less than 3 chars (Eg. G1 = Genesis 1) thus this error is not shown if any results are found. + # if no Bibles are installed, this message is not shown - "No bibles" message is shown instead. (and bible) if not self.search_results and len(text) - text.count(' ') < 3 and bible: self.main_window.information_message( ('%s' % UiStrings().BibleShortSearchTitle), ('%s' % UiStrings().BibleShortSearch)) - # Text search starts here if no reference was found and keyword is longer than 2. - # This is required in order to avoid duplicate error messages for short keywords. if not self.search_results and len(text) - text.count(' ') > 2 and bible: + # Text search starts here if no reference was found and keyword is longer than 2. + # > 2 check is required in order to avoid duplicate error messages for short keywords. self.on_quick_text_search() # If no Text or Reference is found, message is given. if not self.search_results and not \ @@ -744,23 +771,16 @@ class BibleMediaItem(MediaManagerItem): 'range': get_reference_separator('sep_r_display'), 'list': get_reference_separator('sep_l_display')} self.main_window.information_message(translate('BiblesPlugin.BibleManager', 'Nothing found'), - translate('BiblesPlugin.BibleManager', 'OpenLP ' - 'couldn’t find ' - 'anything with your' - ' search.' - '

' - 'If you tried to ' - 'search with ' - 'Scripture ' - 'Reference, please ' - 'make
sure that ' - 'your reference ' - 'follows one of ' - 'these patterns:' - '

%s' + translate('BiblesPlugin.BibleManager', + 'OpenLP couldn’t find anything with your' + ' search.

If you tried to search' + ' with Scripture Reference, please make
sure' + ' that your reference follows one of these' + ' patterns:

%s' % UiStrings().BibleScriptureError % reference_separators)) # Finalizing the search + # List is cleared if not locked, results are listed, button is set available, cursor is set to normal. if not self.quickLockButton.isChecked(): self.list_view.clear() if self.list_view.count() != 0 and self.search_results: From 0217ecae2b9ab633694f78ffcdedaf5af70fa249 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Thu, 28 Apr 2016 19:28:45 +0300 Subject: [PATCH 21/69] Commit for merging trunk. This also has a broken test. --- openlp/plugins/bibles/lib/mediaitem.py | 30 +++++++++++ .../openlp_plugins/bibles/test_mediaitem.py | 51 +++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 91fd6bfd7..8942643c0 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -684,6 +684,36 @@ class BibleMediaItem(MediaManagerItem): self.second_search_results = \ self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) + def banana(self): + # We are doing a 'Reference Search'. + # Set Bibles to use the text input from Quick search field. + bible = self.quickVersionComboBox.currentText() + second_bible = self.quickSecondComboBox.currentText() + text = self.quick_search_edit.text() + text = text.replace('. ', ' ') + if self.quick_search_edit.current_search_type() == BibleSearch.Reference: + self.search_results = self.plugin.manager.get_verses(bible, text) + if not self.search_results: + # if nothing is found, message is given. + # Get reference separators from settings. + reference_separators = { + 'verse': get_reference_separator('sep_v_display'), + 'range': get_reference_separator('sep_r_display'), + 'list': get_reference_separator('sep_l_display')} + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), + translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find anything ' + 'with your search.

' + 'Please make sure that your reference follows one of these patterns:


%s' + % UiStrings().BibleScriptureError % reference_separators)) + elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: + # In Combined Reference search no error is given if no results are found. (This would result in duplicate) + self.search_results = self.plugin.manager.get_verses(bible, text) + if second_bible and self.search_results: + self.second_search_results = \ + self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) + self.advancedSearchButton.setEnabled(True) + def on_quick_text_search(self): # We are doing a 'Text Search'. # Set Bibles to use the text input from Quick search field. diff --git a/tests/functional/openlp_plugins/bibles/test_mediaitem.py b/tests/functional/openlp_plugins/bibles/test_mediaitem.py index a3ce92f4d..112448d73 100644 --- a/tests/functional/openlp_plugins/bibles/test_mediaitem.py +++ b/tests/functional/openlp_plugins/bibles/test_mediaitem.py @@ -23,6 +23,8 @@ This module contains tests for the lib submodule of the Presentations plugin. """ from unittest import TestCase + +from openlp.core.common import Registry, Settings from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin @@ -41,6 +43,9 @@ class TestMediaItem(TestCase, TestMixin): patch('openlp.plugins.bibles.lib.mediaitem.BibleMediaItem.setup_item'): self.media_item = BibleMediaItem(None, MagicMock()) self.setup_application() + self.mocked_main_window = MagicMock() + Registry.create() + Registry().register('main_window', self.mocked_main_window) def display_results_no_results_test(self): """ @@ -109,3 +114,49 @@ class TestMediaItem(TestCase, TestMixin): mocked_list_view.selectAll.assert_called_once_with() self.assertEqual(self.media_item.search_results, {}) self.assertEqual(self.media_item.second_search_results, {}) + + def on_quick_reference_search_test(self): + """ + BOOM BOOM BANANAS + """ + + # GIVEN: A mocked build_display_results which returns an empty list + self.media_item.quickVersionComboBox = MagicMock() + self.media_item.quickSecondComboBox = MagicMock() + self.media_item.quick_search_edit = MagicMock() + + #mocked_text = self.media_item() + #mocked_text.text.return_value = 'Gen. 1' + #self.media_item.text = mocked_text + #self.media_item.text.return_value = 'Gen. 1' + # self.mocked_main_window.information_message = MagicMock() + + self.media_item.search_results = MagicMock() + self.media_item.advancedSearchButton = MagicMock() + self.media_item.advancedSearchButton.setEnabled = MagicMock() + + # WHEN: Calling display_results with a single bible version + self.media_item.banana() + + # THEN: No items should be added to the list, and select all should have been called. + # self.assertEqual(0, self.mocked_main_window.information_message, 'lama') + # mocked_media_item.assert_called_with(mocked_main_window.information_message) + # self.mocked_text.text.assert_called_with('Gen. 1') + # mocked_process_item.assert_called_once_with(mocked_item, 7) + self.media_item.advancedSearchButton.setEnabled.assert_called_once_with(True) + + + """ + def on_quick_reference_search_test(self): + + Test the display_results method a large number of results (> 100) are returned + + + # GIVEN: A mocked build_display_results which returns a large list of results + media_item = BibleMediaItem(MagicMock) + + # WHEN: Calling display_results + #self.media_item.on_quick_reference_search() + + # THEN: addItem should have been called 100 times, and the lsit items should not be selected. + """ \ No newline at end of file From c9680a40dc8be7bafa5d7e7256cf4866a1bd15cc Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Fri, 29 Apr 2016 01:20:42 +0300 Subject: [PATCH 22/69] Added a setting for automatically resetting the Quick search type to "Combined" on startup. This setting is by default enabled. (I Feel like some users may get confused if their search has changed to Text or Reference) --- openlp/plugins/bibles/bibleplugin.py | 3 ++- openlp/plugins/bibles/lib/biblestab.py | 27 +++++++++++++++++++++----- openlp/plugins/bibles/lib/mediaitem.py | 8 ++++++-- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index eb35e298e..509173d7b 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -41,7 +41,8 @@ __default_settings__ = { 'bibles/db password': '', 'bibles/db hostname': '', 'bibles/db database': '', - 'bibles/last search type': BibleSearch.Reference, + 'bibles/last search type': BibleSearch.Combined, + 'bibles/reset to combined quick search': True, 'bibles/verse layout style': LayoutStyle.VersePerSlide, 'bibles/book name language': LanguageSelection.Bible, 'bibles/display brackets': DisplayStyle.NoBrackets, diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 6ca411ec7..0b465e03f 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -131,10 +131,13 @@ class BiblesTab(SettingsTab): self.bible_search_settings_group_box = QtWidgets.QGroupBox(self.right_column) self.bible_search_settings_group_box.setObjectName('bible_search_settings_group_box') self.right_layout.addWidget(self.bible_search_settings_group_box) - self.hide_combined_quick_error_check_box = QtWidgets.QCheckBox(self.bible_search_settings_group_box) - self.hide_combined_quick_error_check_box.setObjectName('hide_combined_quick_error_check_box') self.search_settings_layout = QtWidgets.QFormLayout(self.bible_search_settings_group_box) self.search_settings_layout.setObjectName('search_settings_layout') + self.reset_to_combined_quick_search_check_box = QtWidgets.QCheckBox(self.bible_search_settings_group_box) + self.reset_to_combined_quick_search_check_box.setObjectName('reset_to_combined_quick_search_check_box') + self.search_settings_layout.addRow(self.reset_to_combined_quick_search_check_box) + self.hide_combined_quick_error_check_box = QtWidgets.QCheckBox(self.bible_search_settings_group_box) + self.hide_combined_quick_error_check_box.setObjectName('hide_combined_quick_error_check_box') self.search_settings_layout.addRow(self.hide_combined_quick_error_check_box) self.left_layout.addStretch() self.right_layout.addStretch() @@ -159,6 +162,8 @@ class BiblesTab(SettingsTab): self.end_separator_line_edit.editingFinished.connect(self.on_end_separator_line_edit_finished) Registry().register_function('theme_update_list', self.update_theme_list) self.language_selection_combo_box.activated.connect(self.on_language_selection_combo_box_changed) + self.reset_to_combined_quick_search_check_box.stateChanged.connect \ + (self.on_reset_to_combined_quick_search_check_box_changed) self.hide_combined_quick_error_check_box.stateChanged.connect\ (self.on_hide_combined_quick_error_check_box_changed) @@ -205,9 +210,12 @@ class BiblesTab(SettingsTab): self.language_selection_combo_box.setItemText( LanguageSelection.English, translate('BiblesPlugin.BiblesTab', 'English')) self.bible_search_settings_group_box.setTitle(translate('BiblesPlugin.BiblesTab', 'Search Settings')) - self.hide_combined_quick_error_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Don\'t show error ' - 'for no results in ' - 'combined quick search')) + self.reset_to_combined_quick_search_check_box.setText(translate('BiblesPlugin.BiblesTab', + 'Reset quick search type to "Combined" ' + 'on startup')) + self.hide_combined_quick_error_check_box.setText(translate('BiblesPlugin.BiblesTab', + 'Don\'t show error for no results in combined ' + 'quick search')) def on_bible_theme_combo_box_changed(self): self.bible_theme = self.bible_theme_combo_box.currentText() @@ -316,6 +324,12 @@ class BiblesTab(SettingsTab): self.end_separator_line_edit.setText(get_reference_separator('sep_e_default')) self.end_separator_line_edit.setPalette(self.get_grey_text_palette(True)) + def on_reset_to_combined_quick_search_check_box_changed(self, check_state): + """ + Event handler for the 'hide_combined_quick_error' check box + """ + self.reset_to_combined_quick_search = (check_state == QtCore.Qt.Checked) + def on_hide_combined_quick_error_check_box_changed(self, check_state): """ Event handler for the 'hide_combined_quick_error' check box @@ -375,6 +389,8 @@ class BiblesTab(SettingsTab): self.end_separator_check_box.setChecked(True) self.language_selection = settings.value('book name language') self.language_selection_combo_box.setCurrentIndex(self.language_selection) + self.reset_to_combined_quick_search = settings.value('reset to combined quick search') + self.reset_to_combined_quick_search_check_box.setChecked(self.reset_to_combined_quick_search) self.hide_combined_quick_error = settings.value('hide combined quick error') self.hide_combined_quick_error_check_box.setChecked(self.hide_combined_quick_error) settings.endGroup() @@ -408,6 +424,7 @@ class BiblesTab(SettingsTab): if self.language_selection != settings.value('book name language'): settings.setValue('book name language', self.language_selection) self.settings_form.register_post_process('bibles_load_list') + settings.setValue('reset to combined quick search', self.reset_to_combined_quick_search) settings.setValue('hide combined quick error', self.hide_combined_quick_error) settings.endGroup() if self.tab_visited: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 39df59b30..cba08d4c9 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -430,8 +430,12 @@ class BibleMediaItem(MediaManagerItem): only updated when we are doing reference or combined search, in text search the completion list is removed. """ log.debug('update_auto_completer') - # Save the current search type to the configuration. - Settings().setValue('%s/last search type' % self.settings_section, self.quick_search_edit.current_search_type()) + # Save the current search type to the configuration. If setting for automatically resetting the search type to + # Combined is enabled, use that otherwise use the currently selected search type. + if Settings().value(self.settings_section + '/reset to combined quick search'): + Settings().setValue('%s/last search type' % self.settings_section, BibleSearch.Combined) + else: + Settings().setValue('%s/last search type' % self.settings_section, self.quick_search_edit.current_search_type()) # Save the current bible to the configuration. Settings().setValue(self.settings_section + '/quick bible', self.quickVersionComboBox.currentText()) books = [] From 433b19ed75f6472e1131dfb3f4a760ad5be2bf2e Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Fri, 29 Apr 2016 01:45:05 +0300 Subject: [PATCH 23/69] Reworked UI messages on new settings, pep8 fixes. --- openlp/plugins/bibles/lib/biblestab.py | 24 ++++++++++++------------ openlp/plugins/bibles/lib/mediaitem.py | 3 ++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 0b465e03f..ef1888627 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -128,15 +128,15 @@ class BiblesTab(SettingsTab): self.language_selection_layout.addWidget(self.language_selection_label) self.language_selection_layout.addWidget(self.language_selection_combo_box) self.right_layout.addWidget(self.language_selection_group_box) - self.bible_search_settings_group_box = QtWidgets.QGroupBox(self.right_column) - self.bible_search_settings_group_box.setObjectName('bible_search_settings_group_box') - self.right_layout.addWidget(self.bible_search_settings_group_box) - self.search_settings_layout = QtWidgets.QFormLayout(self.bible_search_settings_group_box) + self.bible_quick_settings_group_box = QtWidgets.QGroupBox(self.right_column) + self.bible_quick_settings_group_box.setObjectName('bible_quick_settings_group_box') + self.right_layout.addWidget(self.bible_quick_settings_group_box) + self.search_settings_layout = QtWidgets.QFormLayout(self.bible_quick_settings_group_box) self.search_settings_layout.setObjectName('search_settings_layout') - self.reset_to_combined_quick_search_check_box = QtWidgets.QCheckBox(self.bible_search_settings_group_box) + self.reset_to_combined_quick_search_check_box = QtWidgets.QCheckBox(self.bible_quick_settings_group_box) self.reset_to_combined_quick_search_check_box.setObjectName('reset_to_combined_quick_search_check_box') self.search_settings_layout.addRow(self.reset_to_combined_quick_search_check_box) - self.hide_combined_quick_error_check_box = QtWidgets.QCheckBox(self.bible_search_settings_group_box) + self.hide_combined_quick_error_check_box = QtWidgets.QCheckBox(self.bible_quick_settings_group_box) self.hide_combined_quick_error_check_box.setObjectName('hide_combined_quick_error_check_box') self.search_settings_layout.addRow(self.hide_combined_quick_error_check_box) self.left_layout.addStretch() @@ -162,7 +162,7 @@ class BiblesTab(SettingsTab): self.end_separator_line_edit.editingFinished.connect(self.on_end_separator_line_edit_finished) Registry().register_function('theme_update_list', self.update_theme_list) self.language_selection_combo_box.activated.connect(self.on_language_selection_combo_box_changed) - self.reset_to_combined_quick_search_check_box.stateChanged.connect \ + self.reset_to_combined_quick_search_check_box.stateChanged.connect\ (self.on_reset_to_combined_quick_search_check_box_changed) self.hide_combined_quick_error_check_box.stateChanged.connect\ (self.on_hide_combined_quick_error_check_box_changed) @@ -209,13 +209,13 @@ class BiblesTab(SettingsTab): LanguageSelection.Application, translate('BiblesPlugin.BiblesTab', 'Application Language')) self.language_selection_combo_box.setItemText( LanguageSelection.English, translate('BiblesPlugin.BiblesTab', 'English')) - self.bible_search_settings_group_box.setTitle(translate('BiblesPlugin.BiblesTab', 'Search Settings')) + self.bible_quick_settings_group_box.setTitle(translate('BiblesPlugin.BiblesTab', 'Quick Search Settings')) self.reset_to_combined_quick_search_check_box.setText(translate('BiblesPlugin.BiblesTab', - 'Reset quick search type to "Combined" ' - 'on startup')) + 'Reset search type to "Text or Scripture' + ' Reference" on startup')) self.hide_combined_quick_error_check_box.setText(translate('BiblesPlugin.BiblesTab', - 'Don\'t show error for no results in combined ' - 'quick search')) + 'Don\'t show error if nothing is found in "Text or ' + 'Scripture Reference"')) def on_bible_theme_combo_box_changed(self): self.bible_theme = self.bible_theme_combo_box.currentText() diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index cba08d4c9..f94b58720 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -435,7 +435,8 @@ class BibleMediaItem(MediaManagerItem): if Settings().value(self.settings_section + '/reset to combined quick search'): Settings().setValue('%s/last search type' % self.settings_section, BibleSearch.Combined) else: - Settings().setValue('%s/last search type' % self.settings_section, self.quick_search_edit.current_search_type()) + Settings().setValue('%s/last search type' % self.settings_section, + self.quick_search_edit.current_search_type()) # Save the current bible to the configuration. Settings().setValue(self.settings_section + '/quick bible', self.quickVersionComboBox.currentText()) books = [] From 8345d1bb1e79064d336271a962787899100981c7 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Fri, 29 Apr 2016 02:35:32 +0300 Subject: [PATCH 24/69] Code cleanup, (Removed def banana) --- openlp/plugins/bibles/lib/mediaitem.py | 30 -------------------------- 1 file changed, 30 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index f94b58720..bdfc4deb4 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -689,36 +689,6 @@ class BibleMediaItem(MediaManagerItem): self.second_search_results = \ self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) - def banana(self): - # We are doing a 'Reference Search'. - # Set Bibles to use the text input from Quick search field. - bible = self.quickVersionComboBox.currentText() - second_bible = self.quickSecondComboBox.currentText() - text = self.quick_search_edit.text() - text = text.replace('. ', ' ') - if self.quick_search_edit.current_search_type() == BibleSearch.Reference: - self.search_results = self.plugin.manager.get_verses(bible, text) - if not self.search_results: - # if nothing is found, message is given. - # Get reference separators from settings. - reference_separators = { - 'verse': get_reference_separator('sep_v_display'), - 'range': get_reference_separator('sep_r_display'), - 'list': get_reference_separator('sep_l_display')} - self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), - translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find anything ' - 'with your search.

' - 'Please make sure that your reference follows one of these patterns:


%s' - % UiStrings().BibleScriptureError % reference_separators)) - elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: - # In Combined Reference search no error is given if no results are found. (This would result in duplicate) - self.search_results = self.plugin.manager.get_verses(bible, text) - if second_bible and self.search_results: - self.second_search_results = \ - self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) - self.advancedSearchButton.setEnabled(True) - def on_quick_text_search(self): # We are doing a 'Text Search'. # Set Bibles to use the text input from Quick search field. From 10c41185838dbdb00d476ab312c9bf32ae4cb873 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 30 Apr 2016 02:58:07 +0300 Subject: [PATCH 25/69] Added a test for checking that all the general required stuff is called on quick search. --- openlp/plugins/bibles/lib/mediaitem.py | 4 +- .../openlp_plugins/bibles/test_mediaitem.py | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index bdfc4deb4..7ab311b66 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -311,8 +311,8 @@ class BibleMediaItem(MediaManagerItem): self.load_bibles() self.quick_search_edit.set_search_types([ (BibleSearch.Combined, ':/bibles/bibles_search_combined.png', - translate('BiblesPlugin.MediaItem', 'Text or Scripture Reference'), - translate('BiblesPlugin.MediaItem', 'Text or Scripture Reference...')), + translate('BiblesPlugin.MediaItem', 'Text or Reference'), + translate('BiblesPlugin.MediaItem', 'Text or Reference...')), (BibleSearch.Reference, ':/bibles/bibles_search_reference.png', translate('BiblesPlugin.MediaItem', 'Scripture Reference'), translate('BiblesPlugin.MediaItem', 'Search Scripture Reference...')), diff --git a/tests/functional/openlp_plugins/bibles/test_mediaitem.py b/tests/functional/openlp_plugins/bibles/test_mediaitem.py index c585ac35a..5b78c2d74 100644 --- a/tests/functional/openlp_plugins/bibles/test_mediaitem.py +++ b/tests/functional/openlp_plugins/bibles/test_mediaitem.py @@ -24,6 +24,7 @@ This module contains tests for the lib submodule of the Presentations plugin. """ from unittest import TestCase + from openlp.core.common import Registry, Settings from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem from tests.functional import MagicMock, patch @@ -114,3 +115,40 @@ class TestMediaItem(TestCase, TestMixin): mocked_list_view.selectAll.assert_called_once_with() self.assertEqual(self.media_item.search_results, {}) self.assertEqual(self.media_item.second_search_results, {}) + + def on_quick_search_button_general_test(self): + """ + Test that general things, which should be called on all Quick searches are called. + """ + + # GIVEN: self.application as self.app, all the required functions + Registry.create() + Registry().register('application', self.app) + self.media_item.quickSearchButton = MagicMock() + self.app.process_events = MagicMock() + self.media_item.quickVersionComboBox = MagicMock() + self.media_item.quickVersionComboBox.currentText = MagicMock() + self.media_item.quickSecondComboBox = MagicMock() + self.media_item.quickSecondComboBox.currentText = MagicMock() + self.media_item.quick_search_edit = MagicMock() + self.media_item.quick_search_edit.text = MagicMock() + self.media_item.quickLockButton = MagicMock() + self.media_item.list_view = MagicMock() + self.media_item.search_results = MagicMock() + self.media_item.display_results = MagicMock() + self.media_item.check_search_result = MagicMock() + self.app.set_normal_cursor = MagicMock() + + # WHEN: on_quick_search_button is called + self.media_item.on_quick_search_button() + + # THEN: Search should had been started and finalized properly + self.assertEqual(1, self.app.process_events.call_count, 'Normal cursor should had been called once') + self.assertEqual(1, self.media_item.quickVersionComboBox.currentText.call_count, 'Should had been called once') + self.assertEqual(1, self.media_item.quickSecondComboBox.currentText.call_count, 'Should had been called once') + self.assertEqual(1, self.media_item.quick_search_edit.text.call_count, 'Text edit Should had been called once') + self.assertEqual(1, self.media_item.quickLockButton.isChecked.call_count, 'Lock Should had been called once') + self.assertEqual(1, self.media_item.display_results.call_count, 'Display results Should had been called once') + self.assertEqual(2, self.media_item.quickSearchButton.setEnabled.call_count, 'Disable and Enable the button') + self.assertEqual(1, self.media_item.check_search_result.call_count, 'Check results Should had been called once') + self.assertEqual(1, self.app.set_normal_cursor.call_count, 'Normal cursor should had been called once') From 09a084be185883e53edbba299fe150ff76bda088 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 30 Apr 2016 03:07:36 +0300 Subject: [PATCH 26/69] - Removed un-needed import that was added earlier - Pep8 fixes --- openlp/core/common/uistrings.py | 2 +- tests/functional/openlp_plugins/bibles/test_mediaitem.py | 3 +-- tests/functional/openlp_plugins/songs/test_openlpimporter.py | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 307daf170..ed8364cee 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -153,7 +153,7 @@ class UiStrings(object): self.Version = translate('OpenLP.Ui', 'Version') self.View = translate('OpenLP.Ui', 'View') self.ViewMode = translate('OpenLP.Ui', 'View Mode') - # Translations used in both, bibles\lib\mediaitem.py and bibles\lib\manager.py + # Translations that are used in bibles\lib\mediaitem.py and bibles\lib\manager.py self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short') self.BibleShortSearch = translate('OpenLP.Ui', 'The search you have entered is empty or shorter ' 'than 3 characters long.
Please try again with ' diff --git a/tests/functional/openlp_plugins/bibles/test_mediaitem.py b/tests/functional/openlp_plugins/bibles/test_mediaitem.py index 5b78c2d74..8c3b6d24f 100644 --- a/tests/functional/openlp_plugins/bibles/test_mediaitem.py +++ b/tests/functional/openlp_plugins/bibles/test_mediaitem.py @@ -24,8 +24,7 @@ This module contains tests for the lib submodule of the Presentations plugin. """ from unittest import TestCase - -from openlp.core.common import Registry, Settings +from openlp.core.common import Registry from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_plugins/songs/test_openlpimporter.py b/tests/functional/openlp_plugins/songs/test_openlpimporter.py index 113db16e0..b78d5c43b 100644 --- a/tests/functional/openlp_plugins/songs/test_openlpimporter.py +++ b/tests/functional/openlp_plugins/songs/test_openlpimporter.py @@ -73,4 +73,3 @@ class TestOpenLPImport(TestCase): self.assertIsNone(importer.do_import(), 'do_import should return None when import_source is not a list') self.assertEqual(mocked_import_wizard.progress_bar.setMaximum.called, False, 'setMaximum on import_wizard.progress_bar should not have been called') - From 4e3ce9d596b3a406a3704a8e5c45e1b7863d6bbf Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 30 Apr 2016 03:14:08 +0300 Subject: [PATCH 27/69] New line is now after ( in biblestab, hopefully this fixes pep8. --- openlp/plugins/bibles/lib/biblestab.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index ef1888627..840adc3f2 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -162,10 +162,10 @@ class BiblesTab(SettingsTab): self.end_separator_line_edit.editingFinished.connect(self.on_end_separator_line_edit_finished) Registry().register_function('theme_update_list', self.update_theme_list) self.language_selection_combo_box.activated.connect(self.on_language_selection_combo_box_changed) - self.reset_to_combined_quick_search_check_box.stateChanged.connect\ - (self.on_reset_to_combined_quick_search_check_box_changed) - self.hide_combined_quick_error_check_box.stateChanged.connect\ - (self.on_hide_combined_quick_error_check_box_changed) + self.reset_to_combined_quick_search_check_box.stateChanged.connect( + self.on_reset_to_combined_quick_search_check_box_changed) + self.hide_combined_quick_error_check_box.stateChanged.connect( + self.on_hide_combined_quick_error_check_box_changed) def retranslateUi(self): self.verse_display_group_box.setTitle(translate('BiblesPlugin.BiblesTab', 'Verse Display')) From 69b374f27bff82683c3633bca5201a469e17518e Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 2 May 2016 07:16:15 +0300 Subject: [PATCH 28/69] - Added "Search while typing" feature for Bible Quick search. - Added a Setting for controlling this ^^ behaviour - Refactored some code to avoid duplicate error messages --- openlp/plugins/bibles/bibleplugin.py | 4 +- openlp/plugins/bibles/lib/biblestab.py | 16 ++++ openlp/plugins/bibles/lib/manager.py | 19 +++-- openlp/plugins/bibles/lib/mediaitem.py | 105 +++++++++++++++++++++---- 4 files changed, 121 insertions(+), 23 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 509173d7b..0a69068f8 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -61,7 +61,9 @@ __default_settings__ = { 'bibles/list separator': '', 'bibles/end separator': '', 'bibles/last directory import': '', - 'bibles/hide combined quick error': False + 'bibles/hide combined quick error': False, + 'bibles/is search while typing enabled': True, + 'bibles/hide web bible error if searching while typing': True } diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 840adc3f2..177192605 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -139,6 +139,9 @@ class BiblesTab(SettingsTab): self.hide_combined_quick_error_check_box = QtWidgets.QCheckBox(self.bible_quick_settings_group_box) self.hide_combined_quick_error_check_box.setObjectName('hide_combined_quick_error_check_box') self.search_settings_layout.addRow(self.hide_combined_quick_error_check_box) + self.bible_search_while_typing_check_box = QtWidgets.QCheckBox(self.bible_quick_settings_group_box) + self.bible_search_while_typing_check_box.setObjectName('bible_search_while_typing_check_box') + self.search_settings_layout.addRow(self.bible_search_while_typing_check_box) self.left_layout.addStretch() self.right_layout.addStretch() # Signals and slots @@ -166,6 +169,8 @@ class BiblesTab(SettingsTab): self.on_reset_to_combined_quick_search_check_box_changed) self.hide_combined_quick_error_check_box.stateChanged.connect( self.on_hide_combined_quick_error_check_box_changed) + self.bible_search_while_typing_check_box.stateChanged.connect( + self.on_bible_search_while_typing_check_box_changed) def retranslateUi(self): self.verse_display_group_box.setTitle(translate('BiblesPlugin.BiblesTab', 'Verse Display')) @@ -216,6 +221,8 @@ class BiblesTab(SettingsTab): self.hide_combined_quick_error_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Don\'t show error if nothing is found in "Text or ' 'Scripture Reference"')) + self.bible_search_while_typing_check_box.setText(translate('BiblesPlugin.BiblesTab', + 'Search automatically while typing')) def on_bible_theme_combo_box_changed(self): self.bible_theme = self.bible_theme_combo_box.currentText() @@ -336,6 +343,12 @@ class BiblesTab(SettingsTab): """ self.hide_combined_quick_error = (check_state == QtCore.Qt.Checked) + def on_bible_search_while_typing_check_box_changed(self, check_state): + """ + Event handler for the 'hide_combined_quick_error' check box + """ + self.bible_search_while_typing = (check_state == QtCore.Qt.Checked) + def load(self): settings = Settings() settings.beginGroup(self.settings_section) @@ -393,6 +406,8 @@ class BiblesTab(SettingsTab): self.reset_to_combined_quick_search_check_box.setChecked(self.reset_to_combined_quick_search) self.hide_combined_quick_error = settings.value('hide combined quick error') self.hide_combined_quick_error_check_box.setChecked(self.hide_combined_quick_error) + self.bible_search_while_typing = settings.value('is search while typing enabled') + self.bible_search_while_typing_check_box.setChecked(self.hide_combined_quick_error) settings.endGroup() def save(self): @@ -426,6 +441,7 @@ class BiblesTab(SettingsTab): self.settings_form.register_post_process('bibles_load_list') settings.setValue('reset to combined quick search', self.reset_to_combined_quick_search) settings.setValue('hide combined quick error', self.hide_combined_quick_error) + settings.setValue('is search while typing enabled', self.bible_search_while_typing) settings.endGroup() if self.tab_visited: self.settings_form.register_post_process('bibles_config_updated') diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index b0a429737..b7408f180 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -326,17 +326,20 @@ class BibleManager(RegistryProperties): if web_bible or second_web_bible: # If either Bible is Web, cursor is reset to normal and message is given. self.application.set_normal_cursor() - self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'), - translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.\n' - 'Please use the Scripture Reference Search instead.') - ) + # If we are performing "Search while typing", do not show this error. + # Web Bible checking method is currently bound to this file, so it can't be properly moved to mediaitem.py + # Without making some changes to the stucture. (= self.db_cache[bible].get_object(BibleMeta,...) + if not Settings().value('bibles/hide web bible error if searching while typing'): + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'), + translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.\n' + 'Please use the Scripture Reference Search instead.\n\n' + 'This means that the currently used Bible or Second Bible\n' + 'is installed as Web Bible and may not be used.') + ) return None # Shorter than 3 char searches break OpenLP with very long search times, thus they are blocked. if len(text) - text.count(' ') < 3: - self.main_window.information_message( - ('%s' % UiStrings().BibleShortSearchTitle), - ('%s' % UiStrings().BibleShortSearch)) return None # Fetch the results from db. If no results are found, return None, no message is given for this. elif text: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 7ab311b66..7a055635d 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -35,6 +35,8 @@ from openlp.plugins.bibles.forms.editbibleform import EditBibleForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, VerseReferenceList, get_reference_separator, \ LanguageSelection, BibleStrings from openlp.plugins.bibles.lib.db import BiblesResourcesDB +import re + log = logging.getLogger(__name__) @@ -251,6 +253,8 @@ class BibleMediaItem(MediaManagerItem): # Other stuff self.quick_search_edit.returnPressed.connect(self.on_quick_search_button) self.search_tab_bar.currentChanged.connect(self.on_search_tab_bar_current_changed) + # Cherry + self.quick_search_edit.textChanged.connect(self.on_search_text_edit_changed) def on_focus(self): if self.quickTab.isVisible(): @@ -669,19 +673,6 @@ class BibleMediaItem(MediaManagerItem): # This is triggered on reference search, use the search from manager.py if self.quick_search_edit.current_search_type() == BibleSearch.Reference: self.search_results = self.plugin.manager.get_verses(bible, text) - if not self.search_results: - # if nothing is found, message is given. - # Get reference separators from settings. - reference_separators = { - 'verse': get_reference_separator('sep_v_display'), - 'range': get_reference_separator('sep_r_display'), - 'list': get_reference_separator('sep_l_display')} - self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), - translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find anything ' - 'with your search.

' - 'Please make sure that your reference follows one of these patterns:


%s' - % UiStrings().BibleScriptureError % reference_separators)) elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: # In Combined Reference search no error is given if no results are found. (This would result in duplicate) self.search_results = self.plugin.manager.get_verses(bible, text) @@ -738,6 +729,8 @@ class BibleMediaItem(MediaManagerItem): "Eg. "Reference Search", "Text Search" or "Combined search". """ log.debug('Quick Search Button clicked') + # If we are performing "Search while typing", this setting is set to True, here it's reset to "False" + Settings().setValue('bibles/hide web bible error if searching while typing', False) # Disable the button while processing, get text from Quick search field. self.quickSearchButton.setEnabled(False) self.application.process_events() @@ -748,9 +741,27 @@ class BibleMediaItem(MediaManagerItem): if self.quick_search_edit.current_search_type() == BibleSearch.Reference: # We are doing a 'Reference Search'. (Get script from def on_quick_reference_search) self.on_quick_reference_search() + # if nothing is found, message is given. + # Get reference separators from settings. + if not self.search_results: + reference_separators = { + 'verse': get_reference_separator('sep_v_display'), + 'range': get_reference_separator('sep_r_display'), + 'list': get_reference_separator('sep_l_display')} + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), + translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find anything ' + 'with your search.

' + 'Please make sure that your reference follows ' + 'one of these patterns:


%s' + % UiStrings().BibleScriptureError % reference_separators)) elif self.quick_search_edit.current_search_type() == BibleSearch.Text: # We are doing a 'Text Search'. (Get script from def on_quick_text_search) self.on_quick_text_search() + if not self.search_results and len(text) - text.count(' ') < 3 and bible: + self.main_window.information_message( + ('%s' % UiStrings().BibleShortSearchTitle), + ('%s' % UiStrings().BibleShortSearch)) elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: # We are doing a 'Combined search'. Starting with reference search. self.on_quick_reference_search() @@ -767,10 +778,12 @@ class BibleMediaItem(MediaManagerItem): # Text search starts here if no reference was found and keyword is longer than 2. # > 2 check is required in order to avoid duplicate error messages for short keywords. self.on_quick_text_search() - # If no Text or Reference is found, message is given. + # If no Text or Reference is found, message is given, unless a setting for not showing it is enabled. if not self.search_results and not \ Settings().value(self.settings_section + '/hide combined quick error'): self.application.set_normal_cursor() + # Reference separators need to be defined both, in here and on reference search, + # error won't work if they are left out from one. reference_separators = { 'verse': get_reference_separator('sep_v_display'), 'range': get_reference_separator('sep_r_display'), @@ -796,6 +809,37 @@ class BibleMediaItem(MediaManagerItem): self.check_search_result() self.application.set_normal_cursor() + def on_quick_search_search_as_type_text(self): + """ + This function is called when "Search as you type" is enabled for Bibles. + It is basically the same thing as "on_quick_search_search" but all the error messages are removed. + """ + log.debug('Quick Search Button clicked') + #self.application.process_events() + # These need to be defined here too so the search results can be displayed. + bible = self.quickVersionComboBox.currentText() + second_bible = self.quickSecondComboBox.currentText() + if self.quick_search_edit.current_search_type() == BibleSearch.Reference: + # We are doing a 'Reference Search'. (Get script from def on_quick_reference_search) + self.on_quick_reference_search() + elif self.quick_search_edit.current_search_type() == BibleSearch.Text: + # We are doing a 'Text Search'. (Get script from def on_quick_text_search) + self.on_quick_text_search() + elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: + self.on_quick_reference_search() + if not self.search_results: + self.on_quick_text_search() + # Finalizing the search + # List is cleared if not locked, results are listed, button is set available, cursor is set to normal. + if not self.quickLockButton.isChecked(): + self.list_view.clear() + if self.list_view.count() != 0 and self.search_results: + self.__check_second_bible(bible, second_bible) + elif self.search_results: + self.display_results(bible, second_bible) + self.check_search_result() + self.application.set_normal_cursor() + def display_results(self, bible, second_bible=''): """ Displays the search results in the media manager. All data needed for further action is saved for/in each row. @@ -807,6 +851,39 @@ class BibleMediaItem(MediaManagerItem): self.search_results = {} self.second_search_results = {} + def on_search_text_edit_changed(self): + """ + If search as type enabled invoke the search on each key press. If the Lyrics are being searched do not start + till 7 characters have been entered. + """ + text = self.quick_search_edit.text() + # If web bible is used, don't show the error while searching and typing. + # This would result in seeing the same message multiple times. + # This message is located in lib\manager.py, so the setting is required. + Settings().setValue('bibles/hide web bible error if searching while typing', True) + search_length = 1 + if self.quick_search_edit.current_search_type() == BibleSearch.Combined: + search_length = 4 + if self.quick_search_edit.current_search_type() == BibleSearch.Reference: + search_length = 3 + elif self.quick_search_edit.current_search_type() == BibleSearch.Text: + search_length = 5 + # Regex for finding space + any non whitemark character. (Prevents search from starting on 1 word searches) + space_and_any = re.compile(' \S') + # Turn this into a format that may be used in if statement. + count_space_any = space_and_any.findall(text) + # Start searching if this behaviour is not disabled in settings and conditions are met. + if len(text) > search_length and len(count_space_any) != 0\ + and Settings().value('bibles/is search while typing enabled'): + # Start search if no chars are entered or deleted for 1.3 seconds + # Use the self.on_quick_search_search_as_type_text, this does not contain any error messages. + # This method may be a bit buggy sometimes and starts shorter than required searches due to the delay. + QtCore.QTimer().singleShot(1300, self.on_quick_search_search_as_type_text) + # If text lenght is less than 4 and results are not locked, it's still possible to search short references. + if not self.quickLockButton.isChecked() and len(text) < 4\ + and Settings().value('bibles/is search while typing enabled'): + self.list_view.clear() + def build_display_results(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. From a77ce8bff5dd888b8d4789d28b94c749a852d3ac Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 2 May 2016 07:26:08 +0300 Subject: [PATCH 29/69] - Fixed the setting. (Was directed to another setting on one connection) - Pep8 --- openlp/plugins/bibles/lib/biblestab.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 177192605..dddcfda90 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -407,7 +407,7 @@ class BiblesTab(SettingsTab): self.hide_combined_quick_error = settings.value('hide combined quick error') self.hide_combined_quick_error_check_box.setChecked(self.hide_combined_quick_error) self.bible_search_while_typing = settings.value('is search while typing enabled') - self.bible_search_while_typing_check_box.setChecked(self.hide_combined_quick_error) + self.bible_search_while_typing_check_box.setChecked(self.bible_search_while_typing) settings.endGroup() def save(self): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 7a055635d..69480a5c5 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -813,24 +813,19 @@ class BibleMediaItem(MediaManagerItem): """ This function is called when "Search as you type" is enabled for Bibles. It is basically the same thing as "on_quick_search_search" but all the error messages are removed. + For commented version, please visit def on_quick_search_button. """ log.debug('Quick Search Button clicked') - #self.application.process_events() - # These need to be defined here too so the search results can be displayed. bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() if self.quick_search_edit.current_search_type() == BibleSearch.Reference: - # We are doing a 'Reference Search'. (Get script from def on_quick_reference_search) self.on_quick_reference_search() elif self.quick_search_edit.current_search_type() == BibleSearch.Text: - # We are doing a 'Text Search'. (Get script from def on_quick_text_search) self.on_quick_text_search() elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: self.on_quick_reference_search() if not self.search_results: self.on_quick_text_search() - # Finalizing the search - # List is cleared if not locked, results are listed, button is set available, cursor is set to normal. if not self.quickLockButton.isChecked(): self.list_view.clear() if self.list_view.count() != 0 and self.search_results: @@ -873,16 +868,15 @@ class BibleMediaItem(MediaManagerItem): # Turn this into a format that may be used in if statement. count_space_any = space_and_any.findall(text) # Start searching if this behaviour is not disabled in settings and conditions are met. - if len(text) > search_length and len(count_space_any) != 0\ - and Settings().value('bibles/is search while typing enabled'): - # Start search if no chars are entered or deleted for 1.3 seconds - # Use the self.on_quick_search_search_as_type_text, this does not contain any error messages. - # This method may be a bit buggy sometimes and starts shorter than required searches due to the delay. - QtCore.QTimer().singleShot(1300, self.on_quick_search_search_as_type_text) - # If text lenght is less than 4 and results are not locked, it's still possible to search short references. - if not self.quickLockButton.isChecked() and len(text) < 4\ - and Settings().value('bibles/is search while typing enabled'): - self.list_view.clear() + if Settings().value('bibles/is search while typing enabled'): + if len(text) > search_length and len(count_space_any) != 0: + # Start search if no chars are entered or deleted for 1.3 seconds + # Use the self.on_quick_search_search_as_type_text, this does not contain any error messages. + # This method may be a bit buggy sometimes and starts shorter than required searches due to the delay. + QtCore.QTimer().singleShot(1300, self.on_quick_search_search_as_type_text) + # If text length is less than 4 and results are not locked, it's still possible to search short references. + if not self.quickLockButton.isChecked() and len(text) < 4: + self.list_view.clear() def build_display_results(self, bible, second_bible, search_results): """ From bb6555349b06bb9a1e99f43e007f464019ae14ca Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 2 May 2016 07:31:01 +0300 Subject: [PATCH 30/69] Improved one comment. --- openlp/plugins/bibles/lib/mediaitem.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 69480a5c5..cf1e7f841 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -848,8 +848,7 @@ class BibleMediaItem(MediaManagerItem): def on_search_text_edit_changed(self): """ - If search as type enabled invoke the search on each key press. If the Lyrics are being searched do not start - till 7 characters have been entered. + If search automatically while typing is enabled, perform the search and list results when conditions are met. """ text = self.quick_search_edit.text() # If web bible is used, don't show the error while searching and typing. From 7f4cd5f4c0edb6d7647ea2737517b1706dd0816b Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 2 May 2016 07:36:05 +0300 Subject: [PATCH 31/69] Removed # Cherry comment which I made earlier to locate some code. --- openlp/plugins/bibles/lib/mediaitem.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index cf1e7f841..10dfaf447 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -253,7 +253,6 @@ class BibleMediaItem(MediaManagerItem): # Other stuff self.quick_search_edit.returnPressed.connect(self.on_quick_search_button) self.search_tab_bar.currentChanged.connect(self.on_search_tab_bar_current_changed) - # Cherry self.quick_search_edit.textChanged.connect(self.on_search_text_edit_changed) def on_focus(self): From 8865b47afd4c8e3d9e22ad6d13a5dee0ed1aa001 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 2 May 2016 07:56:56 +0300 Subject: [PATCH 32/69] Improved the UI message for the new setting. --- openlp/plugins/bibles/lib/biblestab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index dddcfda90..5032d3e4f 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -222,7 +222,7 @@ class BiblesTab(SettingsTab): 'Don\'t show error if nothing is found in "Text or ' 'Scripture Reference"')) self.bible_search_while_typing_check_box.setText(translate('BiblesPlugin.BiblesTab', - 'Search automatically while typing')) + 'Search automatically when writing is stopped')) def on_bible_theme_combo_box_changed(self): self.bible_theme = self.bible_theme_combo_box.currentText() From 8e20bfa19c3f2c57329f7d46888da31d273bcc37 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 2 May 2016 08:32:16 +0300 Subject: [PATCH 33/69] - Renamed one new function to better describe the action - Removed 3rd empty line after imports --- openlp/plugins/bibles/lib/mediaitem.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 10dfaf447..0aa4d4732 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -37,7 +37,6 @@ from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, VerseReferenceL from openlp.plugins.bibles.lib.db import BiblesResourcesDB import re - log = logging.getLogger(__name__) @@ -808,7 +807,7 @@ class BibleMediaItem(MediaManagerItem): self.check_search_result() self.application.set_normal_cursor() - def on_quick_search_search_as_type_text(self): + def on_quick_search_while_typing(self): """ This function is called when "Search as you type" is enabled for Bibles. It is basically the same thing as "on_quick_search_search" but all the error messages are removed. @@ -869,9 +868,9 @@ class BibleMediaItem(MediaManagerItem): if Settings().value('bibles/is search while typing enabled'): if len(text) > search_length and len(count_space_any) != 0: # Start search if no chars are entered or deleted for 1.3 seconds - # Use the self.on_quick_search_search_as_type_text, this does not contain any error messages. + # Use the self.on_quick_search_while_typing, this does not contain any error messages. # This method may be a bit buggy sometimes and starts shorter than required searches due to the delay. - QtCore.QTimer().singleShot(1300, self.on_quick_search_search_as_type_text) + QtCore.QTimer().singleShot(1300, self.on_quick_search_while_typing) # If text length is less than 4 and results are not locked, it's still possible to search short references. if not self.quickLockButton.isChecked() and len(text) < 4: self.list_view.clear() From f5e7e932d1b9db67546f368c2a761a4843187bee Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 2 May 2016 09:54:15 +0300 Subject: [PATCH 34/69] Improved a bunch of comments. --- openlp/core/common/uistrings.py | 2 - openlp/plugins/bibles/lib/manager.py | 6 +-- openlp/plugins/bibles/lib/mediaitem.py | 54 ++++++++++++++------------ 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index ed8364cee..0b4f9b8e0 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -153,7 +153,6 @@ class UiStrings(object): self.Version = translate('OpenLP.Ui', 'Version') self.View = translate('OpenLP.Ui', 'View') self.ViewMode = translate('OpenLP.Ui', 'View Mode') - # Translations that are used in bibles\lib\mediaitem.py and bibles\lib\manager.py self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short') self.BibleShortSearch = translate('OpenLP.Ui', 'The search you have entered is empty or shorter ' 'than 3 characters long.
Please try again with ' @@ -163,7 +162,6 @@ class UiStrings(object): self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available') self.BibleNoBibles = translate('OpenLP.Ui', 'There are no Bibles currently installed.

' 'Please use the Import Wizard to install one or more Bibles.') - # Scripture reference error combined from small translation stings by using itertools. book_chapter = translate('OpenLP.Ui', 'Book Chapter') chapter = translate('OpenLP.Ui', 'Chapter') verse = translate('OpenLP.Ui', 'Verse') diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index b7408f180..ec7015061 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -247,7 +247,6 @@ class BibleManager(RegistryProperties): """ Parses a scripture reference, fetches the verses from the Bible specified, and returns a list of ``Verse`` objects. - This function is called in \bibles\lib\mediaitem.py by def on_quick_search_button :param bible: Unicode. The Bible to use. :param verse_text: @@ -305,7 +304,6 @@ class BibleManager(RegistryProperties): def verse_search(self, bible, second_bible, text): """ Does a verse search for the given bible and text. - This function is called in \bibles\lib\mediaitem.py by def on_quick_search_button. :param bible: The bible to search in (unicode). :param second_bible: The second bible (unicode). We do not search in this bible. @@ -327,15 +325,13 @@ class BibleManager(RegistryProperties): # If either Bible is Web, cursor is reset to normal and message is given. self.application.set_normal_cursor() # If we are performing "Search while typing", do not show this error. - # Web Bible checking method is currently bound to this file, so it can't be properly moved to mediaitem.py - # Without making some changes to the stucture. (= self.db_cache[bible].get_object(BibleMeta,...) if not Settings().value('bibles/hide web bible error if searching while typing'): self.main_window.information_message( translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'), translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.\n' 'Please use the Scripture Reference Search instead.\n\n' 'This means that the currently used Bible or Second Bible\n' - 'is installed as Web Bible and may not be used.') + 'is installed as Web Bible') ) return None # Shorter than 3 char searches break OpenLP with very long search times, thus they are blocked. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 0aa4d4732..d58c2b4f0 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -660,7 +660,10 @@ class BibleMediaItem(MediaManagerItem): self.application.set_normal_cursor() def on_quick_reference_search(self): - # We are doing a 'Reference Search'. + """ + We are doing a 'Reference Search'. + This search is called on def on_quick_search_button by Quick Reference and Combined Searches. + """ # Set Bibles to use the text input from Quick search field. bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() @@ -669,29 +672,27 @@ class BibleMediaItem(MediaManagerItem): text = self.quick_search_edit.text() text = text.replace('. ', ' ') # This is triggered on reference search, use the search from manager.py - if self.quick_search_edit.current_search_type() == BibleSearch.Reference: - self.search_results = self.plugin.manager.get_verses(bible, text) - elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: - # In Combined Reference search no error is given if no results are found. (This would result in duplicate) + if self.quick_search_edit.current_search_type() != BibleSearch.Text: self.search_results = self.plugin.manager.get_verses(bible, text) if second_bible and self.search_results: self.second_search_results = \ self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id) def on_quick_text_search(self): - # We are doing a 'Text Search'. + """ + We are doing a 'Text Search'. + This search is called on def on_quick_search_button by Quick Text and Combined Searches. + """ # Set Bibles to use the text input from Quick search field. bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() text = self.quick_search_edit.text() - # This changes the curson to "Loading animation" self.application.set_busy_cursor() # Get Bibles list bibles = self.plugin.manager.get_bibles() # Add results to "search_results" self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) if second_bible and self.search_results: - # Set up variables, # new_search_results is needed to make sure 2nd bible contains all verses. (And counting them on error) text = [] new_search_results = [] @@ -729,17 +730,14 @@ class BibleMediaItem(MediaManagerItem): log.debug('Quick Search Button clicked') # If we are performing "Search while typing", this setting is set to True, here it's reset to "False" Settings().setValue('bibles/hide web bible error if searching while typing', False) - # Disable the button while processing, get text from Quick search field. self.quickSearchButton.setEnabled(False) self.application.process_events() - # These need to be defined here too so the search results can be displayed. bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() text = self.quick_search_edit.text() if self.quick_search_edit.current_search_type() == BibleSearch.Reference: # We are doing a 'Reference Search'. (Get script from def on_quick_reference_search) self.on_quick_reference_search() - # if nothing is found, message is given. # Get reference separators from settings. if not self.search_results: reference_separators = { @@ -776,7 +774,6 @@ class BibleMediaItem(MediaManagerItem): # Text search starts here if no reference was found and keyword is longer than 2. # > 2 check is required in order to avoid duplicate error messages for short keywords. self.on_quick_text_search() - # If no Text or Reference is found, message is given, unless a setting for not showing it is enabled. if not self.search_results and not \ Settings().value(self.settings_section + '/hide combined quick error'): self.application.set_normal_cursor() @@ -847,19 +844,23 @@ class BibleMediaItem(MediaManagerItem): def on_search_text_edit_changed(self): """ If search automatically while typing is enabled, perform the search and list results when conditions are met. + search_length = Amount of characters in quick search field. If amount of characters is greater than the defined + minimun, search is performed when typing is stopped for 1.2 seconds. """ text = self.quick_search_edit.text() - # If web bible is used, don't show the error while searching and typing. - # This would result in seeing the same message multiple times. - # This message is located in lib\manager.py, so the setting is required. + """ + If web bible is used, don't show the error while searching and typing. + This would result in seeing the same message multiple times. + This message is located in lib\manager.py, so the setting is required. + """ Settings().setValue('bibles/hide web bible error if searching while typing', True) search_length = 1 - if self.quick_search_edit.current_search_type() == BibleSearch.Combined: - search_length = 4 if self.quick_search_edit.current_search_type() == BibleSearch.Reference: - search_length = 3 + search_length = 2 elif self.quick_search_edit.current_search_type() == BibleSearch.Text: - search_length = 5 + search_length = 4 + elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: + search_length = 4 # Regex for finding space + any non whitemark character. (Prevents search from starting on 1 word searches) space_and_any = re.compile(' \S') # Turn this into a format that may be used in if statement. @@ -867,11 +868,16 @@ class BibleMediaItem(MediaManagerItem): # Start searching if this behaviour is not disabled in settings and conditions are met. if Settings().value('bibles/is search while typing enabled'): if len(text) > search_length and len(count_space_any) != 0: - # Start search if no chars are entered or deleted for 1.3 seconds - # Use the self.on_quick_search_while_typing, this does not contain any error messages. - # This method may be a bit buggy sometimes and starts shorter than required searches due to the delay. - QtCore.QTimer().singleShot(1300, self.on_quick_search_while_typing) - # If text length is less than 4 and results are not locked, it's still possible to search short references. + """ + Start search if no chars are entered or deleted for 1.2 s (Long enough to press an another key) + QtCore.QTimer().singleShot resets the timer every time a character is added or removed. + If no Timer is set, Text search will break the search by sending repeative search Quaries on all chars + Use the self.on_quick_search_while_typing, this does not contain any error messages. + This method may be a bit buggy sometimes and starts shorter than required searches due to the delay. + """ + QtCore.QTimer().singleShot(1200, self.on_quick_search_while_typing) + # If text length is less than 4 and results are not locked, clear the results. + # It's still possible to search short references in reference search eg. ps 3. if not self.quickLockButton.isChecked() and len(text) < 4: self.list_view.clear() From 7721b853af5f19314bcd0fa5037a358415fb6dc2 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 2 May 2016 11:06:05 +0300 Subject: [PATCH 35/69] Changed the requested python2 stuff into python 3 stuff. --- openlp/plugins/bibles/lib/mediaitem.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index d58c2b4f0..ba01b2af8 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -703,8 +703,9 @@ class BibleMediaItem(MediaManagerItem): for verse in self.search_results: db_book = bibles[second_bible].get_book_by_book_ref_id(verse.book.book_reference_id) if not db_book: - log.debug('Passage "%s %d:%d" not found in Second Bible' % - (verse.book.name, verse.chapter, verse.verse)) + log.debug('Passage ("{versebookname}","{versechapter}","{verseverse}") not found in Second Bible' + .format(versebookname=verse.book.name, versechapter='verse.chapter', + verseverse=verse.verse)) passage_not_found = True count += 1 continue @@ -715,9 +716,9 @@ class BibleMediaItem(MediaManagerItem): self.main_window.information_message( translate('BiblesPlugin.MediaItem', 'Information'), translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' - 'that are in the main Bible. Only verses found in both Bibles ' - 'will be shown. %d verses have not been included ' - 'in the results.') % count) + 'that are in the main Bible.\nOnly verses found in both Bibles' + ' will be shown.\n\n {count} verses have not been included ' + 'in the results.').format(count=count)) # Join the searches so only verses that are found on both Bibles are shown. self.search_results = new_search_results self.second_search_results = bibles[second_bible].get_verses(text) From 006a90aca7198bb76e02ee720039a73e858421a1 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 2 May 2016 11:09:44 +0300 Subject: [PATCH 36/69] Added . to the end of web bibles sentence. is installed as Web Bible. --- openlp/plugins/bibles/lib/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index ec7015061..b051978ae 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -331,7 +331,7 @@ class BibleManager(RegistryProperties): translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.\n' 'Please use the Scripture Reference Search instead.\n\n' 'This means that the currently used Bible or Second Bible\n' - 'is installed as Web Bible') + 'is installed as Web Bible.') ) return None # Shorter than 3 char searches break OpenLP with very long search times, thus they are blocked. From ba4cd29b4c368f01093a5c8e9822ff39260c7d32 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Wed, 11 May 2016 18:35:35 +0300 Subject: [PATCH 37/69] - Improved the timer method, resulting in much smoother searches. --- openlp/plugins/bibles/lib/biblestab.py | 4 +- openlp/plugins/bibles/lib/mediaitem.py | 52 +++++++++++++------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 5032d3e4f..c087335ae 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -222,7 +222,9 @@ class BiblesTab(SettingsTab): 'Don\'t show error if nothing is found in "Text or ' 'Scripture Reference"')) self.bible_search_while_typing_check_box.setText(translate('BiblesPlugin.BiblesTab', - 'Search automatically when writing is stopped')) + 'Search automatically while typing (Text search must' + ' contain a\nminimum of {count} characters and a ' + 'space for performance reasons)').format(count='8')) def on_bible_theme_combo_box_changed(self): self.bible_theme = self.bible_theme_combo_box.currentText() diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index ba01b2af8..6bbfb7873 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -761,7 +761,9 @@ class BibleMediaItem(MediaManagerItem): ('%s' % UiStrings().BibleShortSearch)) elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: # We are doing a 'Combined search'. Starting with reference search. - self.on_quick_reference_search() + # Perform only if text contains any numbers + if (char.isdigit() for char in text): + self.on_quick_reference_search() # If results are found, search will be finalized. # This check needs to be here in order to avoid duplicate errors. # If keyword is shorter than 3 (not including spaces), message is given. It's actually possible to find @@ -811,16 +813,20 @@ class BibleMediaItem(MediaManagerItem): It is basically the same thing as "on_quick_search_search" but all the error messages are removed. For commented version, please visit def on_quick_search_button. """ - log.debug('Quick Search Button clicked') bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() - if self.quick_search_edit.current_search_type() == BibleSearch.Reference: + text = self.quick_search_edit.text() + if self.quick_search_edit.current_search_type() == BibleSearch.Combined: + # If text has no numbers, auto search limit is min 8 characters for performance reasons. + # If you change this value, also change it in biblestab.py (Count) in enabling search while typing. + if (char.isdigit() for char in text) and len(text) > 1: + self.on_quick_reference_search() + if not self.search_results and len(text) > 7: + self.on_quick_text_search() + elif self.quick_search_edit.current_search_type() == BibleSearch.Reference: self.on_quick_reference_search() elif self.quick_search_edit.current_search_type() == BibleSearch.Text: - self.on_quick_text_search() - elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: - self.on_quick_reference_search() - if not self.search_results: + if len(text) > 7: self.on_quick_text_search() if not self.quickLockButton.isChecked(): self.list_view.clear() @@ -845,8 +851,6 @@ class BibleMediaItem(MediaManagerItem): def on_search_text_edit_changed(self): """ If search automatically while typing is enabled, perform the search and list results when conditions are met. - search_length = Amount of characters in quick search field. If amount of characters is greater than the defined - minimun, search is performed when typing is stopped for 1.2 seconds. """ text = self.quick_search_edit.text() """ @@ -855,32 +859,30 @@ class BibleMediaItem(MediaManagerItem): This message is located in lib\manager.py, so the setting is required. """ Settings().setValue('bibles/hide web bible error if searching while typing', True) - search_length = 1 - if self.quick_search_edit.current_search_type() == BibleSearch.Reference: - search_length = 2 - elif self.quick_search_edit.current_search_type() == BibleSearch.Text: - search_length = 4 - elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: - search_length = 4 # Regex for finding space + any non whitemark character. (Prevents search from starting on 1 word searches) space_and_any = re.compile(' \S') # Turn this into a format that may be used in if statement. count_space_any = space_and_any.findall(text) # Start searching if this behaviour is not disabled in settings and conditions are met. if Settings().value('bibles/is search while typing enabled'): - if len(text) > search_length and len(count_space_any) != 0: + # If text length is less than the mininum and results are not locked, clear the results. + if len(count_space_any) == 0: + if not self.quickLockButton.isChecked(): + self.list_view.clear() + else: """ - Start search if no chars are entered or deleted for 1.2 s (Long enough to press an another key) - QtCore.QTimer().singleShot resets the timer every time a character is added or removed. + Start search if no chars are entered or deleted for 0.2 s If no Timer is set, Text search will break the search by sending repeative search Quaries on all chars Use the self.on_quick_search_while_typing, this does not contain any error messages. - This method may be a bit buggy sometimes and starts shorter than required searches due to the delay. """ - QtCore.QTimer().singleShot(1200, self.on_quick_search_while_typing) - # If text length is less than 4 and results are not locked, clear the results. - # It's still possible to search short references in reference search eg. ps 3. - if not self.quickLockButton.isChecked() and len(text) < 4: - self.list_view.clear() + self.search_timer = () + if self.search_timer: + self.search_timer.stop() + self.search_timer.deleteLater() + self.search_timer = QtCore.QTimer() + self.search_timer.timeout.connect(self.on_quick_search_while_typing) + self.search_timer.setSingleShot(True) + self.search_timer.start(200) def build_display_results(self, bible, second_bible, search_results): """ From acde9cad5ece985b7d9a44922cd181af7b6b5478 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sun, 15 May 2016 18:04:15 +0300 Subject: [PATCH 38/69] - Fixed the dot chechk method. (No longer removes dot after numbers, eg. 1.) --- openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index b051978ae..4b81c1493 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -24,7 +24,7 @@ import logging import os from openlp.core.common import RegistryProperties, AppLocation, Settings, translate, delete_file, UiStrings -from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection +from openlp.plugins.bibles.lib import parse_reference, LanguageSelection from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta from .csvbible import CSVBible from .http import HTTPBible diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 6bbfb7873..99e16bafa 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -667,10 +667,10 @@ class BibleMediaItem(MediaManagerItem): # Set Bibles to use the text input from Quick search field. bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() - # Get input from field and replace '. ' with '' - # This will check if field has any '.' and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1 + # Get input from field and replace 'A-Z + . ' with '' + # This will check if field has any '.' after A-Z and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1 text = self.quick_search_edit.text() - text = text.replace('. ', ' ') + text = re.sub('\D[.]\s', ' ', text) # This is triggered on reference search, use the search from manager.py if self.quick_search_edit.current_search_type() != BibleSearch.Text: self.search_results = self.plugin.manager.get_verses(bible, text) From f0cc51270463f12789f046c33de2c616606722fa Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sun, 15 May 2016 22:52:22 +0300 Subject: [PATCH 39/69] - Fixed Settings().Value to .value --- 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 4b81c1493..ad6ae6ca4 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -330,7 +330,7 @@ class BibleManager(RegistryProperties): translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'), translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.\n' 'Please use the Scripture Reference Search instead.\n\n' - 'This means that the currently used Bible or Second Bible\n' + 'This means that the currently used Bible\nor Second Bible ' 'is installed as Web Bible.') ) return None diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 0287614ed..34d0d43c3 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -732,7 +732,7 @@ class BibleMediaItem(MediaManagerItem): """ log.debug('Quick Search Button clicked') # If we are performing "Search while typing", this setting is set to True, here it's reset to "False" - if Settings().Value('bibles/hide web bible error if searching while typing'): + if Settings().value('bibles/hide web bible error if searching while typing'): Settings().setValue('bibles/hide web bible error if searching while typing', False) self.quickSearchButton.setEnabled(False) self.application.process_events() From c4318c6a22a5a91eff71882722ac2d3b40cf3857 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sun, 15 May 2016 23:37:49 +0300 Subject: [PATCH 40/69] - Fixed the test --- openlp/plugins/bibles/lib/mediaitem.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 34d0d43c3..f0cb3fe34 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -667,10 +667,12 @@ class BibleMediaItem(MediaManagerItem): # Set Bibles to use the text input from Quick search field. bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() - # Get input from field and replace 'A-Z + . ' with '' - # This will check if field has any '.' after A-Z and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1 - # If Book name has '.' after number. eg. 1. Genesis, the search fails without the dot, and vice versa. - # A better solution would be to make '.' optional in the search results. Current solution was easier to code. + """ + Get input from field and replace 'A-Z + . ' with '' + This will check if field has any '.' after A-Z and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1 + If Book name has '.' after number. eg. 1. Genesis, the search fails without the dot, and vice versa. + A better solution would be to make '.' optional in the search results. Current solution was easier to code. + """ text = self.quick_search_edit.text() text = re.sub('\D[.]\s', ' ', text) # This is triggered on reference search, use the search from manager.py @@ -732,8 +734,7 @@ class BibleMediaItem(MediaManagerItem): """ log.debug('Quick Search Button clicked') # If we are performing "Search while typing", this setting is set to True, here it's reset to "False" - if Settings().value('bibles/hide web bible error if searching while typing'): - Settings().setValue('bibles/hide web bible error if searching while typing', False) + Settings().setValue('bibles/hide web bible error if searching while typing', False) self.quickSearchButton.setEnabled(False) self.application.process_events() bible = self.quickVersionComboBox.currentText() From 45798e67f035373126966e8bbeb1c547059c4318 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sun, 15 May 2016 23:41:58 +0300 Subject: [PATCH 41/69] Removed 2nd blank line from end of the uistrings. --- openlp/core/common/uistrings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index fc6a0ba5c..5859c87a5 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -183,4 +183,3 @@ class UiStrings(object): itertools.chain.from_iterable(itertools.repeat(strings, 1) if isinstance(strings, str) else strings for strings in bible_scripture_items) self.BibleScriptureError = ''.join(str(joined) for joined in bible_scripture_items) - From 0a0a87078b516edccbcaf318710cad7cd26e096f Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 21 May 2016 01:02:40 +0300 Subject: [PATCH 42/69] - Removed the unrequired %s complications from "No Bibles installed" --- openlp/plugins/bibles/lib/manager.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index ad6ae6ca4..11a6e48b3 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -269,8 +269,8 @@ class BibleManager(RegistryProperties): if not bible: if show_error: self.main_window.information_message( - ('%s' % UiStrings().BibleNoBiblesTitle), - ('%s' % UiStrings().BibleNoBibles)) + UiStrings().BibleNoBiblesTitle, + UiStrings().BibleNoBibles) return None # Get the language for books. language_selection = self.get_language_selection(bible) @@ -313,8 +313,8 @@ class BibleManager(RegistryProperties): # If no bibles are installed, message is given. if not bible: self.main_window.information_message( - ('%s' % UiStrings().BibleNoBiblesTitle), - ('%s' % UiStrings().BibleNoBibles)) + UiStrings().BibleNoBiblesTitle, + UiStrings().BibleNoBibles) return None # Check if the bible or second_bible is a web bible. web_bible = self.db_cache[bible].get_object(BibleMeta, 'download_source') From cabca18de59738f2347e09975f7419cfe8f90feb Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 21 May 2016 01:10:10 +0300 Subject: [PATCH 43/69] - Removed unrequired % s complications from short search messsage. --- 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 f0cb3fe34..53780f873 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -669,7 +669,7 @@ class BibleMediaItem(MediaManagerItem): second_bible = self.quickSecondComboBox.currentText() """ Get input from field and replace 'A-Z + . ' with '' - This will check if field has any '.' after A-Z and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1 + This will check if field has any '.' after A-Z and removes them. Eg. Gen. 1 = Ge 1 = Genesis 1 If Book name has '.' after number. eg. 1. Genesis, the search fails without the dot, and vice versa. A better solution would be to make '.' optional in the search results. Current solution was easier to code. """ @@ -761,8 +761,8 @@ class BibleMediaItem(MediaManagerItem): self.on_quick_text_search() if not self.search_results and len(text) - text.count(' ') < 3 and bible: self.main_window.information_message( - ('%s' % UiStrings().BibleShortSearchTitle), - ('%s' % UiStrings().BibleShortSearch)) + UiStrings().BibleShortSearchTitle, + UiStrings().BibleShortSearch) elif self.quick_search_edit.current_search_type() == BibleSearch.Combined: # We are doing a 'Combined search'. Starting with reference search. # Perform only if text contains any numbers @@ -775,8 +775,8 @@ class BibleMediaItem(MediaManagerItem): # if no Bibles are installed, this message is not shown - "No bibles" message is shown instead. (and bible) if not self.search_results and len(text) - text.count(' ') < 3 and bible: self.main_window.information_message( - ('%s' % UiStrings().BibleShortSearchTitle), - ('%s' % UiStrings().BibleShortSearch)) + UiStrings().BibleShortSearchTitle, + UiStrings().BibleShortSearch) if not self.search_results and len(text) - text.count(' ') > 2 and bible: # Text search starts here if no reference was found and keyword is longer than 2. # > 2 check is required in order to avoid duplicate error messages for short keywords. From 4f5abd290fde266cef54cc6433ff91452cff31ba Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sun, 5 Jun 2016 14:03:28 +0300 Subject: [PATCH 44/69] - Created "def verse_search_while_typing" / This does not trigger web bibles error message and is used during search while typing. - Removed the new/old setting created for the old solution --- openlp/plugins/bibles/bibleplugin.py | 3 +- openlp/plugins/bibles/lib/manager.py | 52 ++++++++++++++++++++----- openlp/plugins/bibles/lib/mediaitem.py | 53 ++++++++++++++++++++++++-- 3 files changed, 93 insertions(+), 15 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 0a69068f8..3d27effe4 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -62,8 +62,7 @@ __default_settings__ = { 'bibles/end separator': '', 'bibles/last directory import': '', 'bibles/hide combined quick error': False, - 'bibles/is search while typing enabled': True, - 'bibles/hide web bible error if searching while typing': True + 'bibles/is search while typing enabled': True } diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 11a6e48b3..facbb167b 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -324,15 +324,15 @@ class BibleManager(RegistryProperties): if web_bible or second_web_bible: # If either Bible is Web, cursor is reset to normal and message is given. self.application.set_normal_cursor() - # If we are performing "Search while typing", do not show this error. - if not Settings().value('bibles/hide web bible error if searching while typing'): - self.main_window.information_message( - translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'), - translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.\n' - 'Please use the Scripture Reference Search instead.\n\n' - 'This means that the currently used Bible\nor Second Bible ' - 'is installed as Web Bible.') - ) + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used in Text Search'), + translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.\n' + 'Please use the Scripture Reference Search instead.\n\n' + 'This means that the currently used Bible\nor Second Bible ' + 'is installed as Web Bible.\n\n' + 'If you were trying to perform a Reference search\nin Combined ' + 'Search, your reference is invalid.') + ) return None # Shorter than 3 char searches break OpenLP with very long search times, thus they are blocked. if len(text) - text.count(' ') < 3: @@ -343,6 +343,40 @@ class BibleManager(RegistryProperties): else: return None + def verse_search_while_typing(self, bible, second_bible, text): + """ + Does a verse search for the given bible and text. + This is used during "Search while typing" + It's the same thing as the normal text search, but it does not show the web Bible error. + (It would result in the error popping every time a char is entered or removed) + It also does not have a minimum text len, this is set in mediaitem.py + + :param bible: The bible to search in (unicode). + :param second_bible: The second bible (unicode). We do not search in this bible. + :param text: The text to search for (unicode). + """ + log.debug('BibleManager.verse_search("%s", "%s")', bible, text) + # If no bibles are installed, message is given. + if not bible: + self.main_window.information_message( + UiStrings().BibleNoBiblesTitle, + UiStrings().BibleNoBibles) + return None + # Check if the bible or second_bible is a web bible. + web_bible = self.db_cache[bible].get_object(BibleMeta, 'download_source') + second_web_bible = '' + if second_bible: + second_web_bible = self.db_cache[second_bible].get_object(BibleMeta, 'download_source') + if web_bible or second_web_bible: + # If either Bible is Web, cursor is reset to normal and search ends w/o any message. + self.application.set_normal_cursor() + return None + # Fetch the results from db. If no results are found, return None, no message is given for this. + elif text: + return self.db_cache[bible].verse_search(text) + else: + return None + def save_meta_data(self, bible, version, copyright, permissions, book_name_language=None): """ Saves the bibles meta data. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 53780f873..a49753ce7 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -727,6 +727,53 @@ class BibleMediaItem(MediaManagerItem): self.search_results = new_search_results self.second_search_results = bibles[second_bible].get_verses(text) + def on_quick_text_search_while_typing(self): + """ + We are doing a 'Text Search' while typing + Call the verse_search_while_typing from manager.py + It does not show web bible errors while typing. + (It would result in the error popping every time a char is entered or removed) + """ + # Set Bibles to use the text input from Quick search field. + bible = self.quickVersionComboBox.currentText() + second_bible = self.quickSecondComboBox.currentText() + text = self.quick_search_edit.text() + self.application.set_busy_cursor() + # Get Bibles list + bibles = self.plugin.manager.get_bibles() + # Add results to "search_results" + self.search_results = self.plugin.manager.verse_search_while_typing(bible, second_bible, text) + if second_bible and self.search_results: + # new_search_results is needed to make sure 2nd bible contains all verses. (And counting them on error) + text = [] + new_search_results = [] + count = 0 + passage_not_found = False + # Search second bible for results of search_results to make sure everythigns there. + # Count all the unfound passages. + for verse in self.search_results: + db_book = bibles[second_bible].get_book_by_book_ref_id(verse.book.book_reference_id) + if not db_book: + log.debug('Passage ("{versebookname}","{versechapter}","{verseverse}") not found in Second Bible' + .format(versebookname=verse.book.name, versechapter='verse.chapter', + verseverse=verse.verse)) + passage_not_found = True + count += 1 + continue + new_search_results.append(verse) + text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse)) + if passage_not_found: + # This is for the 2nd Bible. + self.main_window.information_message( + translate('BiblesPlugin.MediaItem', 'Information'), + translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' + 'that are in the main Bible.\nOnly verses found in both Bibles' + ' will be shown.\n\n {count} verses have not been included ' + 'in the results.').format(count=count)) + # Join the searches so only verses that are found on both Bibles are shown. + self.search_results = new_search_results + self.second_search_results = bibles[second_bible].get_verses(text) + def on_quick_search_button(self): """ This triggers the proper Quick search based on which search type is used. @@ -734,7 +781,6 @@ class BibleMediaItem(MediaManagerItem): """ log.debug('Quick Search Button clicked') # If we are performing "Search while typing", this setting is set to True, here it's reset to "False" - Settings().setValue('bibles/hide web bible error if searching while typing', False) self.quickSearchButton.setEnabled(False) self.application.process_events() bible = self.quickVersionComboBox.currentText() @@ -827,7 +873,7 @@ class BibleMediaItem(MediaManagerItem): if (char.isdigit() for char in text) and len(text) > 1: self.on_quick_reference_search() if not self.search_results and len(text) > 7: - self.on_quick_text_search() + self.on_quick_text_search_while_typing() elif self.quick_search_edit.current_search_type() == BibleSearch.Reference: self.on_quick_reference_search() elif self.quick_search_edit.current_search_type() == BibleSearch.Text: @@ -857,14 +903,13 @@ class BibleMediaItem(MediaManagerItem): """ If search automatically while typing is enabled, perform the search and list results when conditions are met. """ - text = self.quick_search_edit.text() """ If web bible is used, don't show the error while searching and typing. This would result in seeing the same message multiple times. This message is located in lib\manager.py, so the setting is required. """ if Settings().value('bibles/is search while typing enabled'): - Settings().setValue('bibles/hide web bible error if searching while typing', True) + text = self.quick_search_edit.text() # Regex for finding space + any non whitemark character. (Prevents search from starting on 1 word searches) space_and_any = re.compile(' \S') # Turn this into a format that may be used in if statement. From 8f7f9f980471a2ae80392047feb09c40f62d7097 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sun, 5 Jun 2016 15:32:57 +0300 Subject: [PATCH 45/69] - Removed one old comment related to old setting and old solution --- openlp/plugins/bibles/lib/mediaitem.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 0c4e222e2..8b6e21b7e 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -776,7 +776,6 @@ class BibleMediaItem(MediaManagerItem): "Eg. "Reference Search", "Text Search" or "Combined search". """ log.debug('Quick Search Button clicked') - # If we are performing "Search while typing", this setting is set to True, here it's reset to "False" self.quickSearchButton.setEnabled(False) self.application.process_events() bible = self.quickVersionComboBox.currentText() @@ -814,7 +813,7 @@ class BibleMediaItem(MediaManagerItem): # This check needs to be here in order to avoid duplicate errors. # If keyword is shorter than 3 (not including spaces), message is given. It's actually possible to find # verses with less than 3 chars (Eg. G1 = Genesis 1) thus this error is not shown if any results are found. - # if no Bibles are installed, this message is not shown - "No bibles" message is shown instead. (and bible) + # if no Bibles are installed, this message is not shown - "No bibles" message is shown instead. if not self.search_results and len(text) - text.count(' ') < 3 and bible: self.main_window.information_message( UiStrings().BibleShortSearchTitle, From 4ec7e5e8792e7552386f9be02d354658b8dd2bb7 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 11 Jun 2016 13:10:15 +0300 Subject: [PATCH 46/69] - Added "Search too short for search while typing" message to search results !! Need to rename this from: search_results_banana to something smarter. - Fixed "," breaking OLP if it's the last char in text search. - "," no longer separates keywords in Text search. - Removed mention about separating keywords with "," from the empty search message. - Started working on not duplicating search results on "Lock search results" > THIS DOES NOT WORK YET. --- openlp/core/common/uistrings.py | 6 ++---- openlp/core/lib/mediamanageritem.py | 14 ++++++++++++++ openlp/plugins/bibles/lib/mediaitem.py | 16 ++++++++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 166b4bb2e..f8931bffd 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -158,10 +158,8 @@ class UiStrings(object): self.Video = translate('OpenLP.Ui', 'Video') self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short') self.BibleShortSearch = translate('OpenLP.Ui', 'The search you have entered is empty or shorter ' - 'than 3 characters long.
Please try again with ' - 'a longer search.


You can separate different ' - 'keywords by a space to search for all of your keywords and you ' - 'can separate them by a comma to search for one of them.') + 'than 3 characters long.


Please try again with ' + 'a longer search.') self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available') self.BibleNoBibles = translate('OpenLP.Ui', 'There are no Bibles currently installed.

' 'Please use the Import Wizard to install one or more Bibles.') diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 358c82543..9ec024bbb 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -651,6 +651,20 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): item.setFont(font) self.list_view.addItem(item) + def check_search_result_banana(self): + """ + Checks if the list_view is empty and adds a "No Search Results" item. + """ + if self.list_view.count(): + return + message = translate('OpenLP.MediaManagerItem', 'Search is too short for: "Search while typing."') + item = QtWidgets.QListWidgetItem(message) + item.setFlags(QtCore.Qt.NoItemFlags) + font = QtGui.QFont() + font.setItalic(True) + item.setFont(font) + self.list_view.addItem(item) + def _get_id_of_item_to_generate(self, item, remote_item): """ Utility method to check items being submitted for slide generation. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 8b6e21b7e..758298b53 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -696,6 +696,8 @@ class BibleMediaItem(MediaManagerItem): bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() text = self.quick_search_edit.text() + # If Text search ends with "," OpenLP will crash, prevent this from happening by removing all ","s. + text = re.sub('[,]', '', text) self.application.set_busy_cursor() # Get Bibles list bibles = self.plugin.manager.get_bibles() @@ -742,6 +744,8 @@ class BibleMediaItem(MediaManagerItem): bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() text = self.quick_search_edit.text() + # If Text search ends with "," OpenLP will crash, prevent this from happening by removing all ","s. + text = re.sub('[,]', '', text) self.application.set_busy_cursor() # Get Bibles list bibles = self.plugin.manager.get_bibles() @@ -905,15 +909,18 @@ class BibleMediaItem(MediaManagerItem): """ if Settings().value('bibles/is search while typing enabled'): text = self.quick_search_edit.text() + if len(text) == 0: + self.check_search_result() # Regex for finding space + any non whitemark character. (Prevents search from starting on 1 word searches) space_and_any = re.compile(' \S') # Turn this into a format that may be used in if statement. count_space_any = space_and_any.findall(text) # Start searching if this behaviour is not disabled in settings and conditions are met. # If text does not have 'count_space_any' and results are not locked, clear the results. - if len(count_space_any) == 0: + if len(count_space_any) == 0 and len(text) > 0: if not self.quickLockButton.isChecked(): self.list_view.clear() + self.check_search_result_banana() else: """ Start search if no chars are entered or deleted for 0.2 s @@ -996,7 +1003,12 @@ class BibleMediaItem(MediaManagerItem): version=version) bible_verse = QtWidgets.QListWidgetItem(bible_text) bible_verse.setData(QtCore.Qt.UserRole, data) - items.append(bible_verse) + # 32rfa + if self.quickLockButton.isChecked(): + if count in search_results: + items.append(bible_verse) + else: + items.append(bible_verse) return items def generate_slide_data(self, service_item, item=None, xml_version=False, remote=False, From 65ffd10cdf37c25984e18281e27c64e5980fcd72 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Mon, 13 Jun 2016 01:02:24 +0300 Subject: [PATCH 47/69] - Improved the "Too short search" item functionality. - Improved some comments. --- openlp/core/lib/mediamanageritem.py | 6 +- openlp/plugins/bibles/lib/mediaitem.py | 113 +++++++++++++++---------- 2 files changed, 71 insertions(+), 48 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 9ec024bbb..c7c84f912 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -651,13 +651,13 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): item.setFont(font) self.list_view.addItem(item) - def check_search_result_banana(self): + def check_search_result_search_while_typing_short(self): """ - Checks if the list_view is empty and adds a "No Search Results" item. + This is used in Bible "Search while typing" if the search is shorter than the min required len. """ if self.list_view.count(): return - message = translate('OpenLP.MediaManagerItem', 'Search is too short for: "Search while typing."') + message = translate('OpenLP.MediaManagerItem', 'Search is too short to be used in: "Search while typing"') item = QtWidgets.QListWidgetItem(message) item.setFlags(QtCore.Qt.NoItemFlags) font = QtGui.QFont() diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 758298b53..caac451ec 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -869,7 +869,7 @@ class BibleMediaItem(MediaManagerItem): if self.quick_search_edit.current_search_type() == BibleSearch.Combined: # If text has no numbers, auto search limit is min 8 characters for performance reasons. # If you change this value, also change it in biblestab.py (Count) in enabling search while typing. - if (char.isdigit() for char in text) and len(text) > 1: + if (char.isdigit() for char in text) and len(text) > 2: self.on_quick_reference_search() if not self.search_results and len(text) > 7: self.on_quick_text_search_while_typing() @@ -887,54 +887,82 @@ class BibleMediaItem(MediaManagerItem): self.check_search_result() self.application.set_normal_cursor() - def display_results(self, bible, second_bible=''): - """ - Displays the search results in the media manager. All data needed for further action is saved for/in each row. - """ - items = self.build_display_results(bible, second_bible, self.search_results) - for bible_verse in items: - self.list_view.addItem(bible_verse) - self.list_view.selectAll() - self.search_results = {} - self.second_search_results = {} - def on_search_text_edit_changed(self): """ If search automatically while typing is enabled, perform the search and list results when conditions are met. """ - """ - If web bible is used, don't show the error while searching and typing. - This would result in seeing the same message multiple times. - This message is located in lib\manager.py, so the setting is required. - """ if Settings().value('bibles/is search while typing enabled'): text = self.quick_search_edit.text() - if len(text) == 0: - self.check_search_result() - # Regex for finding space + any non whitemark character. (Prevents search from starting on 1 word searches) - space_and_any = re.compile(' \S') + """ + Use Regex for finding space + number in reference search and space + 2 characters in text search. + These are used to prevent bad search queries from starting. (Long/crashing queries) + """ + space_and_digit_reference = re.compile(' \d') + space_and_two_chars_text = re.compile(' \S\S') # Turn this into a format that may be used in if statement. - count_space_any = space_and_any.findall(text) - # Start searching if this behaviour is not disabled in settings and conditions are met. - # If text does not have 'count_space_any' and results are not locked, clear the results. - if len(count_space_any) == 0 and len(text) > 0: + count_space_digit_reference = space_and_digit_reference.findall(text) + count_spaces_two_chars_text = space_and_two_chars_text.findall(text) + """ + The Limit is required for setting the proper "No items found" message. + "Limit" is also hard coded to on_quick_search_while_typing, it must be there to avoid bad search + performance. Limit 8 = Text search, 3 = Reference search. + """ + limit = 8 + if self.quick_search_edit.current_search_type() == BibleSearch.Combined: + if len(count_space_digit_reference) != 0: + limit = 3 + elif self.quick_search_edit.current_search_type() == BibleSearch.Reference: + limit = 3 + """ + If text is empty, clear the list. + else: Start by checking if the search is suitable for "Search while typing" + """ + if len(text) == 0: if not self.quickLockButton.isChecked(): self.list_view.clear() - self.check_search_result_banana() + self.check_search_result() else: - """ - Start search if no chars are entered or deleted for 0.2 s - If no Timer is set, Text search will break the search by sending repeative search Quaries on all chars - Use the self.on_quick_search_while_typing, this does not contain any error messages. - """ - self.search_timer = () - if self.search_timer: - self.search_timer.stop() - self.search_timer.deleteLater() - self.search_timer = QtCore.QTimer() - self.search_timer.timeout.connect(self.on_quick_search_while_typing) - self.search_timer.setSingleShot(True) - self.search_timer.start(200) + if limit == 3 and (len(text) < limit or len(count_space_digit_reference) == 0): + if not self.quickLockButton.isChecked(): + self.list_view.clear() + self.check_search_result() + elif limit == 8 and (len(text) < limit or len(count_spaces_two_chars_text) == 0): + if not self.quickLockButton.isChecked(): + self.list_view.clear() + self.check_search_result_search_while_typing_short() + else: + """ + Start search if no chars are entered or deleted for 0.2 s + If no Timer is set, Text search will break the search by sending repeative search Quaries on + all chars. Use the self.on_quick_search_while_typing, this does not contain any error messages. + """ + self.search_timer = () + if self.search_timer: + self.search_timer.stop() + self.search_timer.deleteLater() + self.search_timer = QtCore.QTimer() + self.search_timer.timeout.connect(self.on_quick_search_while_typing) + self.search_timer.setSingleShot(True) + self.search_timer.start(200) + + def display_results(self, bible, second_bible=''): + """ + Displays the search results in the media manager. All data needed for further action is saved for/in each row. + """ + + items = self.build_display_results(bible, second_bible, self.search_results) + if not self.quickLockButton.isChecked(): + for bible_verse in items: + self.list_view.addItem(bible_verse) + if self.quickLockButton.isChecked(): + for bible_verse in range(self.list_view.count()): + listItem = self.list_view.item(items) + itemRow = self.list_view.row(listItem) + if itemRow: + self.list_view.takeItem(itemRow) + self.list_view.selectAll() + self.search_results = {} + self.second_search_results = {} def build_display_results(self, bible, second_bible, search_results): """ @@ -1003,12 +1031,7 @@ class BibleMediaItem(MediaManagerItem): version=version) bible_verse = QtWidgets.QListWidgetItem(bible_text) bible_verse.setData(QtCore.Qt.UserRole, data) - # 32rfa - if self.quickLockButton.isChecked(): - if count in search_results: - items.append(bible_verse) - else: - items.append(bible_verse) + items.append(bible_verse) return items def generate_slide_data(self, service_item, item=None, xml_version=False, remote=False, From 5a54b2a6609e5e65a18d514b1dcfaa4a19c642c7 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Tue, 14 Jun 2016 22:54:26 +0300 Subject: [PATCH 48/69] - Improved the "Search too short" message for Quick search. (Reference search just uses "No search results for now") - Reverted the attempt to stop duplicated search results if search results are locked, (This is something that I havn't figured out how to do) --- openlp/plugins/bibles/lib/mediaitem.py | 29 +++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index caac451ec..13fb3f2ee 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -813,11 +813,13 @@ class BibleMediaItem(MediaManagerItem): # Perform only if text contains any numbers if (char.isdigit() for char in text): self.on_quick_reference_search() - # If results are found, search will be finalized. - # This check needs to be here in order to avoid duplicate errors. - # If keyword is shorter than 3 (not including spaces), message is given. It's actually possible to find - # verses with less than 3 chars (Eg. G1 = Genesis 1) thus this error is not shown if any results are found. - # if no Bibles are installed, this message is not shown - "No bibles" message is shown instead. + """ + If results are found, search will be finalized. + This check needs to be here in order to avoid duplicate errors. + If keyword is shorter than 3 (not including spaces), message is given. It's actually possible to find + verses with less than 3 chars (Eg. G1 = Genesis 1) thus this error is not shown if any results are found. + if no Bibles are installed, this message is not shown - "No bibles" message is shown instead. + """ if not self.search_results and len(text) - text.count(' ') < 3 and bible: self.main_window.information_message( UiStrings().BibleShortSearchTitle, @@ -895,12 +897,15 @@ class BibleMediaItem(MediaManagerItem): text = self.quick_search_edit.text() """ Use Regex for finding space + number in reference search and space + 2 characters in text search. + Also search for two characters (Searches require at least two sets of two characters) These are used to prevent bad search queries from starting. (Long/crashing queries) """ space_and_digit_reference = re.compile(' \d') + two_chars_text = re.compile('\S\S') space_and_two_chars_text = re.compile(' \S\S') # Turn this into a format that may be used in if statement. count_space_digit_reference = space_and_digit_reference.findall(text) + count_two_chars_text = two_chars_text.findall(text) count_spaces_two_chars_text = space_and_two_chars_text.findall(text) """ The Limit is required for setting the proper "No items found" message. @@ -926,7 +931,8 @@ class BibleMediaItem(MediaManagerItem): if not self.quickLockButton.isChecked(): self.list_view.clear() self.check_search_result() - elif limit == 8 and (len(text) < limit or len(count_spaces_two_chars_text) == 0): + elif limit == 8 and (len(text) < limit or len(count_spaces_two_chars_text) == 0 + or len(count_two_chars_text) < 2): if not self.quickLockButton.isChecked(): self.list_view.clear() self.check_search_result_search_while_typing_short() @@ -951,15 +957,8 @@ class BibleMediaItem(MediaManagerItem): """ items = self.build_display_results(bible, second_bible, self.search_results) - if not self.quickLockButton.isChecked(): - for bible_verse in items: - self.list_view.addItem(bible_verse) - if self.quickLockButton.isChecked(): - for bible_verse in range(self.list_view.count()): - listItem = self.list_view.item(items) - itemRow = self.list_view.row(listItem) - if itemRow: - self.list_view.takeItem(itemRow) + for bible_verse in items: + self.list_view.addItem(bible_verse) self.list_view.selectAll() self.search_results = {} self.second_search_results = {} From d5b11c13d22fb48954d3adde06c6a6918a3b4bee Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Tue, 14 Jun 2016 23:53:39 +0300 Subject: [PATCH 49/69] - Some code cleanup --- openlp/plugins/bibles/lib/manager.py | 1 + openlp/plugins/bibles/lib/mediaitem.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 850877ed1..1d7cea921 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -368,6 +368,7 @@ class BibleManager(RegistryProperties): second_web_bible = self.db_cache[second_bible].get_object(BibleMeta, 'download_source') if web_bible or second_web_bible: # If either Bible is Web, cursor is reset to normal and search ends w/o any message. + self.check_search_result() self.application.set_normal_cursor() return None # Fetch the results from db. If no results are found, return None, no message is given for this. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 13fb3f2ee..cbeeb2fa2 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -931,8 +931,8 @@ class BibleMediaItem(MediaManagerItem): if not self.quickLockButton.isChecked(): self.list_view.clear() self.check_search_result() - elif limit == 8 and (len(text) < limit or len(count_spaces_two_chars_text) == 0 - or len(count_two_chars_text) < 2): + elif (limit == 8 and (len(text) < limit or len(count_spaces_two_chars_text) == 0 or + len(count_two_chars_text) < 2)): if not self.quickLockButton.isChecked(): self.list_view.clear() self.check_search_result_search_while_typing_short() From 3e926c7480a2943bfd6c180d851dd3bc6447e9e8 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Wed, 15 Jun 2016 00:49:29 +0300 Subject: [PATCH 50/69] - Added "Clear search results" button to Quick & Advanced search. > Added a new icon for this: http://www.1001freedownloads.com/free-clipart/tango-edit-clear ^^CC0 1.0 Universal (CC0 1.0) --- openlp/plugins/bibles/lib/mediaitem.py | 16 ++++++++++++++++ resources/images/openlp-2.qrc | 1 + 2 files changed, 17 insertions(+) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index cbeeb2fa2..34c1dcfc8 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -58,6 +58,7 @@ class BibleMediaItem(MediaManagerItem): log.info('Bible Media Item loaded') def __init__(self, parent, plugin): + self.clear_icon = build_icon(':/bibles/bibles_search_clear.png') self.lock_icon = build_icon(':/bibles/bibles_search_lock.png') self.unlock_icon = build_icon(':/bibles/bibles_search_unlock.png') MediaManagerItem.__init__(self, parent, plugin) @@ -159,10 +160,15 @@ class BibleMediaItem(MediaManagerItem): search_button_layout = QtWidgets.QHBoxLayout() search_button_layout.setObjectName(prefix + 'search_button_layout') search_button_layout.addStretch() + clear_button = QtWidgets.QPushButton(tab) + clear_button.setFixedSize(22, 22) + clear_button.setIcon(self.clear_icon) + clear_button.setObjectName(prefix + 'ClearButton') lock_button = QtWidgets.QToolButton(tab) lock_button.setIcon(self.unlock_icon) lock_button.setCheckable(True) lock_button.setObjectName(prefix + 'LockButton') + search_button_layout.addWidget(clear_button) search_button_layout.addWidget(lock_button) search_button = QtWidgets.QPushButton(tab) search_button.setObjectName(prefix + 'SearchButton') @@ -178,6 +184,7 @@ class BibleMediaItem(MediaManagerItem): setattr(self, prefix + 'SecondComboBox', second_combo_box) setattr(self, prefix + 'StyleLabel', style_label) setattr(self, prefix + 'StyleComboBox', style_combo_box) + setattr(self, prefix + 'ClearButton', clear_button) setattr(self, prefix + 'LockButton', lock_button) setattr(self, prefix + 'SearchButtonLayout', search_button_layout) setattr(self, prefix + 'SearchButton', search_button) @@ -247,6 +254,8 @@ class BibleMediaItem(MediaManagerItem): self.quickStyleComboBox.activated.connect(self.on_quick_style_combo_box_changed) self.advancedStyleComboBox.activated.connect(self.on_advanced_style_combo_box_changed) # Buttons + self.advancedClearButton.clicked.connect(self.on_clear_button) + self.quickClearButton.clicked.connect(self.on_clear_button) self.advancedSearchButton.clicked.connect(self.on_advanced_search_button) self.quickSearchButton.clicked.connect(self.on_quick_search_button) # Other stuff @@ -289,6 +298,7 @@ class BibleMediaItem(MediaManagerItem): self.quickStyleComboBox.setItemText(LayoutStyle.VersePerSlide, UiStrings().VersePerSlide) self.quickStyleComboBox.setItemText(LayoutStyle.VersePerLine, UiStrings().VersePerLine) self.quickStyleComboBox.setItemText(LayoutStyle.Continuous, UiStrings().Continuous) + self.quickClearButton.setToolTip(translate('BiblesPlugin.MediaItem', 'Clear the search results.')) self.quickLockButton.setToolTip(translate('BiblesPlugin.MediaItem', 'Toggle to keep or clear the previous results.')) self.quickSearchButton.setText(UiStrings().Search) @@ -303,6 +313,7 @@ class BibleMediaItem(MediaManagerItem): self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerSlide, UiStrings().VersePerSlide) self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerLine, UiStrings().VersePerLine) self.advancedStyleComboBox.setItemText(LayoutStyle.Continuous, UiStrings().Continuous) + self.advancedClearButton.setToolTip(translate('BiblesPlugin.MediaItem', 'Clear the search results.')) self.advancedLockButton.setToolTip(translate('BiblesPlugin.MediaItem', 'Toggle to keep or clear the previous results.')) self.advancedSearchButton.setText(UiStrings().Search) @@ -537,6 +548,11 @@ class BibleMediaItem(MediaManagerItem): self.advancedTab.setVisible(True) self.advanced_book_combo_box.setFocus() + def on_clear_button(self): + # Clear the list, then set the "No search Results" message. + self.list_view.clear() + self.check_search_result() + def on_lock_button_toggled(self, checked): if checked: self.sender().setIcon(self.lock_icon) diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index c73b02c48..b45cc745d 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -34,6 +34,7 @@ bibles_search_text.png bibles_search_reference.png bibles_upgrade_alert.png + bibles_search_clear.png bibles_search_unlock.png bibles_search_lock.png
From 7c74b5031847a313eb283a47385cf6fba23d7714 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Wed, 15 Jun 2016 00:55:37 +0300 Subject: [PATCH 51/69] - Code cleanup (Removed 2 un-required empty rows) --- openlp/plugins/bibles/lib/mediaitem.py | 1 - tests/functional/openlp_plugins/bibles/test_mediaitem.py | 1 - 2 files changed, 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 34c1dcfc8..f43516ec2 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -971,7 +971,6 @@ class BibleMediaItem(MediaManagerItem): """ Displays the search results in the media manager. All data needed for further action is saved for/in each row. """ - items = self.build_display_results(bible, second_bible, self.search_results) for bible_verse in items: self.list_view.addItem(bible_verse) diff --git a/tests/functional/openlp_plugins/bibles/test_mediaitem.py b/tests/functional/openlp_plugins/bibles/test_mediaitem.py index 9297722bb..05418f177 100644 --- a/tests/functional/openlp_plugins/bibles/test_mediaitem.py +++ b/tests/functional/openlp_plugins/bibles/test_mediaitem.py @@ -23,7 +23,6 @@ This module contains tests for the lib submodule of the Presentations plugin. """ from unittest import TestCase - from openlp.core.common import Registry from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem from tests.functional import MagicMock, patch From 1d7396121678e78f2530b0f7ed774f7fe409d6cd Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Fri, 17 Jun 2016 00:48:05 +0300 Subject: [PATCH 52/69] - Added the Images by using "bzr add" E:\bzr\openlp\combined-reference-and-text-search>bzr add E:\bzr\openlp\combined- reference-and-text-search\resources\images adding resources/images/bibles_search_clear.png adding resources/images/bibles_search_combined.png --- resources/images/bibles_search_clear.png | Bin 0 -> 1166 bytes resources/images/bibles_search_combined.png | Bin 0 -> 1108 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 resources/images/bibles_search_clear.png create mode 100644 resources/images/bibles_search_combined.png diff --git a/resources/images/bibles_search_clear.png b/resources/images/bibles_search_clear.png new file mode 100644 index 0000000000000000000000000000000000000000..b2d550690abe545ed17ede131ac6271223b87bc6 GIT binary patch literal 1166 zcmb7DZAep57=G{W-JN&tQ?E{w8HVCWD+(k1S2mkVClMvs4=Is^s7Q+NXY?r#^fRRF@aXTlUL5^;yvROgKU)zU{+h~QkR9SZ!FgWt;Uw42cUB7)l7$U`<)4XnvZYrPXE0FLYyWQWcDJ8g~zMahaqT+AlFW z(ff7&-r0`m1Wu5Y2A;v{DQ?Bjxceu~0l%WV{?1Y*A|gouNId+@TD8i4g-=^lc(lZr zQ_KpC!8_u01m8dCf(YjQwS|5sFvj$vNAAawotcX&($&-hK8uesRmny=3aWo?3WM!X zFx6W!w&E(0#RZ4FG} zOyqRT-EwX~zPmZWAIJFVZC<0vQu`tr8q1|91qe~Bau8x+4+MN`QubbH2$AFBC6dH7 za5{l3PA`3}$;dyy6}=fLnJH#MJw*CC`LFbMdZ$%FeKt*#mlJb4G*ABW)wS_>lh5#qZe nzmWjX6NXE~NSu&}<`}r_EjB67UTByZj_YEtsIhjHpT7PR7ZCrW literal 0 HcmV?d00001 diff --git a/resources/images/bibles_search_combined.png b/resources/images/bibles_search_combined.png new file mode 100644 index 0000000000000000000000000000000000000000..de5e94a70c073801863f3b0964de09380b7c9c6c GIT binary patch literal 1108 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4(FKV3GE8aSX8#WE5a||C{kY5KPE7 z0?LvG3MQTdYhWTx8>VW!2Ec5=)P@kjYXCwSZWaqRDP)^rY+T`l)c}}ckY*Sgn?)co zioGz%4It!ys)PYbEWn}+SBQhe(OrdN0J Date: Fri, 17 Jun 2016 01:27:06 +0300 Subject: [PATCH 53/69] - Clear the results button now also clears the text input field and gives it focus. --- openlp/plugins/bibles/lib/mediaitem.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index f43516ec2..a863bb8ee 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -549,9 +549,11 @@ class BibleMediaItem(MediaManagerItem): self.advanced_book_combo_box.setFocus() def on_clear_button(self): - # Clear the list, then set the "No search Results" message. + # Clear the list, then set the "No search Results" message, then clear the text field and give it focus. self.list_view.clear() self.check_search_result() + self.quick_search_edit.clear() + self.quick_search_edit.setFocus() def on_lock_button_toggled(self, checked): if checked: From aae7de5899ac7e8fac0a3336b10af8691e3c0bd9 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sun, 24 Jul 2016 21:54:34 +0300 Subject: [PATCH 54/69] Changed icons to oxygen icons. --- resources/images/bibles_search_clear.png | Bin 1166 -> 2073 bytes resources/images/bibles_search_combined.png | Bin 1108 -> 1614 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/resources/images/bibles_search_clear.png b/resources/images/bibles_search_clear.png index b2d550690abe545ed17ede131ac6271223b87bc6..3e052bffd11748059d5e46d5c086ddc190b6b999 100644 GIT binary patch literal 2073 zcmV+!2RP)REG=wpRd*%GeBQq1Rq16ModiH<&$(P#k zCE)OX!0+{J=XL3Y>Zw!y1d|C3*!0*pshCPE)l~_U@+T%d;QJfCwK_2};LmmCpuMB} zHxnMD0L^EfXHVadCNZ|k1pCcsl4h} zlz>)vJxW8j9DxZH9EjRg9DQ+5YM5dDPR3eaCZswH9BA0K!5^{(VaQpGLaQop@@LHu zyCPe^)C5*7uJ>0~J+P&^RNy@P zhdg{LB_SEwACl>n}O| z#kGRKBP}bYSBD&ngYgy^oC+nI?SKgb`V`GbC8EO)uB{8YqyTqt@EjNoLsm4&0J_Kh zCH%(R=|R6;d&~wA9YY#YGN8&?$QcnF$DkM%^xPW!bQdA_DZsn6^QQ!J&iBA!h6;qh zPRQ-EQ!^l(?!b&iRXL21gL?>>Hm-n%2MP|mTtZRU=SF@GL3B8RYrP@{MGmPfhry9} zmY%ru33z&F=Hlvb{^xzfsv5*$w{mvD#_7vzIfq~&4xSQ0)etz{jt7_2=Bj4I%Vxw~ z1Ddxi-CGcFFCdhI!C4^2WAF+DK3;^&rl6~*53vjpgF4w)zhY)lxHrZV!EUjJaxHu? zkMI6!BmMD>L9S!v94fd4POzF0iiVO?Utr-wb8~ewqS=i2k6*$U*Du;qJthCOj-I$M ztF9ceSPF`yLDDtwstkwQjh?|coQ%ljQ6*i})eDFcBf0_3Fj#l}boS;aZLE?b$1aKT z@@MAEBDH_{2jfMVak|ck-Hsbe=cDarzo!0uWA+ov_AV&$HNSr1 zw9&DA37k9!Cjdc`Q8^TYzqrt)0QI*gaH4rJe=+8qPp!r;YAV9Dr!IEk!Rm4tP$9;$ z(5(bnMT3>;5OST!$SNY;@qxUNjJ?WC5IS$M;kp`j;M_%{GLZ9D*^-(MHAY1X$)-O2 zYPlDTnrpSB@LNW?G%R>WJE03y-#5`)NaUQO)(6Lv(gU z36h%3G*Kf?j}61|Gzx=mXo?C+(~<9UBO)rTS~8i6Q{Kl{R^Zr$%SL&A-oBCrQ;&nU zq%0bV85GgLl<=k8t0OmCyL*>~A70L#jzmV~e;<|aU`*v~`8giKlcH&5A!_4!>(rtk zBrwKw21+<++UV#hOgpjwibHOI*h4y!-fu;Kjz-PqQ0uq8bz&$}as2|4t`wGLY1$s3A9?@y=G`zm~%Ldnec z!bU$EjL4Hq{PvK~1<{;BMh8mFfSZwY8jQSVFeU literal 1166 zcmb7DZAep57=G{W-JN&tQ?E{w8HVCWD+(k1S2mkVClMvs4=Is^s7Q+NXY?r#^fRRF@aXTlUL5^;yvROgKU)zU{+h~QkR9SZ!FgWt;Uw42cUB7)l7$U`<)4XnvZYrPXE0FLYyWQWcDJ8g~zMahaqT+AlFW z(ff7&-r0`m1Wu5Y2A;v{DQ?Bjxceu~0l%WV{?1Y*A|gouNId+@TD8i4g-=^lc(lZr zQ_KpC!8_u01m8dCf(YjQwS|5sFvj$vNAAawotcX&($&-hK8uesRmny=3aWo?3WM!X zFx6W!w&E(0#RZ4FG} zOyqRT-EwX~zPmZWAIJFVZC<0vQu`tr8q1|91qe~Bau8x+4+MN`QubbH2$AFBC6dH7 za5{l3PA`3}$;dyy6}=fLnJH#MJw*CC`LFbMdZ$%FeKt*#mlJb4G*ABW)wS_>lh5#qZe nzmWjX6NXE~NSu&}<`}r_EjB67UTByZj_YEtsIhjHpT7PR7ZCrW diff --git a/resources/images/bibles_search_combined.png b/resources/images/bibles_search_combined.png index de5e94a70c073801863f3b0964de09380b7c9c6c..6a9b6360e331c4fc4476f0cefaa75339873c9849 100644 GIT binary patch literal 1614 zcmV-U2C?~xP)3fiiP4Y7A3rb>Kl~64kO&e{Vl=2hi7ghU87yshG=196qce1# zcgDR>W+z^6+i6JH$;!FUv({c`pNA=(PD8?EGMNEb@Nh#T&XnA+03pu-P?kXs9!?|) zGYsOTYdw*busIM6exHcPSrJSEKzFZh=(w z8;i>>KorYQ-=05@WHO0FBB4WoNckJ9)rvUPOfiY!Ylb;P#O=X@2a%hbD}84b!0d`J zOzMMkbBc_EU8t(6LVkWe@(3ft!?=9;vif$%jvc6}sezwd@%elVc25Zy8ymxl6)R9w zRJ7b7Fssb%1c%e9GOMYrMQdxTt^ln$IT#rkQH8c{-8$6Q*Q@tZlxNPIQ7%4-q zci`fc$akCFb*AWCo;g}_yTRoDN;*?NH*ed9U@*w{29N_RLbBI^Yon>D2`O@MsZizG zefW!G_UYcCpD%7K7@GYWrqGWffU{R5p-_lB(~&rxPJU;|Uf$90i35TK1wLM$vSM2^K`5Wo;pffO@?Vrc=HohdLANL_vNmufH{lwDviW zn2-()0(h>+Vlg3JP>9`bm+M6ZNN9xMrp6~RY1)G$dn`C`>@URpAHbBFGmw*LwM@^< z%y4ZiW%cp|h=_{va=5qb#BBO$9P22>p|=MRojOX4F~fA?{ep{=VzFT`JkKTo*4$h* z_g$NI!H>srVApEAaomf@=qr@9rgI%80T#`VN*tWAf}@41JwSAWBvR4+MD zqq65^BYq2a?)V^? z_x1JhZpn)lFWW4Prze9mCsAoSJLJRT@mvFNn?)>iDs}?cNu8dP%FD}DJ25eV zp`oF`3*Fs400x9S>yZrlZ**cx=F*~E3Nx+T>%gh@&yHCal)|Gx?C=-TD3|lU%4Ywuad+KlI>kxUHfUj_ya&t$c+LXFnF)$ z!zPo800ukc^?L8Lx3_lz@DRd6o=t$7qjc2L9U>?Ut%Pj3a&DliPt!s5T4!hHO8|xl zk;Tc4)6fcFEuoGR#DhhQFiaTdYaw5*023#Yfe8;5+*zFZ)UeF>7Z5B71U(Uar~m)} M07*qoM6N<$f=Axxr~m)} literal 1108 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4(FKV3GE8aSX8#WE5a||C{kY5KPE7 z0?LvG3MQTdYhWTx8>VW!2Ec5=)P@kjYXCwSZWaqRDP)^rY+T`l)c}}ckY*Sgn?)co zioGz%4It!ys)PYbEWn}+SBQhe(OrdN0J Date: Thu, 28 Jul 2016 23:30:14 +0300 Subject: [PATCH 55/69] - Removed the clean icon manual sizing. --- openlp/plugins/bibles/lib/mediaitem.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index a863bb8ee..b28f9f119 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -161,7 +161,6 @@ class BibleMediaItem(MediaManagerItem): search_button_layout.setObjectName(prefix + 'search_button_layout') search_button_layout.addStretch() clear_button = QtWidgets.QPushButton(tab) - clear_button.setFixedSize(22, 22) clear_button.setIcon(self.clear_icon) clear_button.setObjectName(prefix + 'ClearButton') lock_button = QtWidgets.QToolButton(tab) From 3937fbccf948d70f946e3f7b40630877c4738ba0 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 30 Jul 2016 18:19:44 +0300 Subject: [PATCH 56/69] - Changed the Clear button to use QToolButton instead of QPushButton. (Fixes the issue where the clear button is larger than the lock button). --- openlp/plugins/bibles/lib/mediaitem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index b28f9f119..98e84241e 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -160,7 +160,8 @@ class BibleMediaItem(MediaManagerItem): search_button_layout = QtWidgets.QHBoxLayout() search_button_layout.setObjectName(prefix + 'search_button_layout') search_button_layout.addStretch() - clear_button = QtWidgets.QPushButton(tab) + # Note: If we use QPushButton instead of the QToolButton, the icon will be larger than the Lock icon. + clear_button = QtWidgets.QToolButton(tab) clear_button.setIcon(self.clear_icon) clear_button.setObjectName(prefix + 'ClearButton') lock_button = QtWidgets.QToolButton(tab) From feba589d078edf9cf1d5946d2fc9bbdf9101b37f Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 30 Jul 2016 22:49:37 +0300 Subject: [PATCH 57/69] - Lock button now gives focus to Search field. --- openlp/plugins/bibles/lib/mediaitem.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 98e84241e..debf786f7 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -556,6 +556,7 @@ class BibleMediaItem(MediaManagerItem): self.quick_search_edit.setFocus() def on_lock_button_toggled(self, checked): + self.quick_search_edit.setFocus() if checked: self.sender().setIcon(self.lock_icon) else: From 7a4ed4813a3f198dd522b141273d5bf17d926568 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sun, 31 Jul 2016 14:01:03 +0300 Subject: [PATCH 58/69] - Replaced the new icons with 48x48 versions. --- resources/images/bibles_search_clear.png | Bin 2073 -> 3911 bytes resources/images/bibles_search_combined.png | Bin 1614 -> 2705 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/resources/images/bibles_search_clear.png b/resources/images/bibles_search_clear.png index 3e052bffd11748059d5e46d5c086ddc190b6b999..551ce7c9698b5d9e1bd41d4518ba6202424d99e5 100644 GIT binary patch delta 3888 zcmV-056|$K5XT-NiBL{Q4GJ0x0000DNk~Le0000m0000m2nGNE09OL}hmj!~3k5L% z00l7tx9uoWkwzzf4#Y`BK~#9!)tU*ARP~+5zyEi4zrLos=ju6OhM8d)U}OTwFvIPE zMidn>Q8XJ3(bZ_h4RPZI>>4zyDe*{DtdyxlOO&W+vK~+600RTlbM*9m zzU#mLo;9g4?7C6Vs`*rXt7~eyy1$?I`*pw9RgX|g@pbTj%o9KLpE`BQ|K?loo!HiK zD2=nk*CuehbMp&{Sm^3duqSR({?7SV-1ZdC0vx^uF8k&J!8Ei5iO3*4PKT?sr1)wu zMvcJTD{fk>YZ-qu)DOibBOHmZA5{Wgw`*xE9D*zfuq={z?alX}8#My=-Fb^@=-CC) z!5~zd4LQw!di$YYJeM3b0*e;Ty)u)IyCY1%uBzzm8+-wbQ6pftiI+zPf^evI=sFFq zdGyz>j~ao8|NTdPOUo_@_4UB*av*2WS3lgo&loiVvu93SoJd6Mspt??)rqcSr`Cfp zY6KLKUy|Q_pU)4?;tySS`No15Q%f3MF6!{T42j8P--jphkgCE^jm z(z8$_sp}jQ~&RmH%_}{m2^J_V3^M^Sz@+;I~gbFoDwCwAfG|{Qg4Z4DMAh zMvcJaiQ}(HCgMbv6iBMu7<}aU3tz6U|HCVU6yXc9k&ufvU3~G*7k$2azZL<)uuOeP zJRE|5$5)7CS8s|Jl`*u?KMBB#8we@HKL``P$O4|Qx6UXu6y@CU3WFDA=sIY_)aFz{$bdVP!<^@yg2g0%%>PGX{a?#Z9xF`0^F9dM_MoQqA~f8z z6eg2+kx6_dzsMeY;I8!^r?7}vIh(_-z{@MSDczX?s_DohloTWB74Xh?Zi8;oBLcAW zT1p2nf?pA`$Of$SHjNQx{^TCek3Yd*5gP08$(A?Jx$bwvPyH69tIwLiBX_jgqH%kF zkAKWWpCU<=*WzeGL9A*ZmB0w3Kq)eQ5w9#?ft*E;XPLy^l=gzLl8~!Qfi;!mD}@>V zdN;IPoxtDqbIzTG9Z#;oi9hZF<2nIn3Cr1X{}_MD;lD6)O}qY;35+C{{#1(R;hi=e@VJre@5kW2SFq>7y~so|DQ-mhGZL6mTmGO;5&V)U zfKUsWYz`%bZcu6=bo4NPU{{%l1<-sS-j=ud0U`H12H^0AOrq67RqZ(BQX;4*0-^*+ z5;ztJJi0c%ifphK)l1Jo$J+;n%Y&7__0#faB=FN!D;5{H)NdECk=yMOlF1Yk&{0(2 zfN2;=rxLLH{GeJ6oFL* z0)@%ic#cRcLOvWv zWcHZ5If7$PK7R3@7xZN%!;z_pmcGMIY z$VE<}t2c&EqC66o8=;g1o^UWMGWeh@T*mXREJpSIThq?8t%8}M4B1$5ECrSd51&$~jAz~zff{h>Hf*TjZ zViNgDjFjL$xBT)sx0V(bT*qD%$#f2Z5+7Ta3_=4z=vfUGHHXgwyq<&PR8d~&K(SN6 z#7Y&U^FV{Yu}W&4*CJqRrvRT*psY0KwDG(ua~wXVR+&@&t&0>)4rIVMSI7JK$ z#Zc^Xf@(TsRe{9wY*JZ>f=DOSjnf=|-cC4<5Vq2JM{pE`Cmh1_+wsg_c7RXB&F1=l zz=O5tpYze!mfFp!-QAVDjvlYlDl0IttOV-ulMqY_kx~c%1U4z3AcD@Dh5jSmo@8(D z$K1%`8?L&Ff99?$zoBc{d#6vTo|et&_^_iJZ7p@svIz{Zee|&Msz-vzbI>&db|%NO zn5KoSrlC6E0SwbRxUB=J87+h|DN4wH@EcH$!_d4oJonKqA|z90^Z4?gS1*{fi{mWz zJVFbAx zC?)N&mg9XxKb+BAeThvGxMyG6f%B%1gWKj{B`Kn@3{*~F0y6qS5fpe-h?W6=UXh?P z0n@Tj>USa%*MfR?KOc%jxq>OpkWTi3fFjX80~@z@5G|23CNz|!CTb%+>^2e>8;KmDEVD~t&zpKX#6gYUAqM()uN#r1l z{O}_O44-*DE(LB?hA8E)kF}1>X*z4ro`EMuUxs(q71OywRGvNy~mEdc5v%95K2!gpNIVBp=GLDlpUt2xjDiWe{y2* zyb`bNc1MzTdFzX3zsq0Fq7F}7{{doaDJV)$Apcrt`EI5dtaglSN8 z1ygAd`Uv4j4kpci0VJcdHKQhtD_-@42`g;qTtufvLd!`RwK1hHS+cK5YC@_T zfu1Fln)o|}WvQCX&eC43GftDLU?gOLPP7ZczMNu}?LBZrX{sr51P@0=!_N&=l(?M1 zP#l#dp5ddPjAmeWD9ENX@H~f1B8Qx2WMr9V4y-;a513JZ(Pa-=;6lVQL(sW6luSAh zAJpfp+-#m+{B%}Q+Won=8W09MACM|^OR60nnYT(!%K1S|Pa=^kHZ|?SNGdDWk1d?k zHxT!Ld;W>TsW0#A2W?_v#PexStFr-ijb ze}%X9-9LBUwQyGbCX>ivMb9OrR88&-kNBD2tunk~p9&44kjtuy=+KEmCBs3f;O2QK yp}`~{&ly*aDRuu$1ybEEn-&ZP%;Dl+A^!~sfZ}yOn+WXy0000REG=wpRd*%Fp$s;opv7yxiw|e$}`^lHu z@g?B!f57kcZ0B|9h3ctO{sfZ=4cPS9H>sFPEY(#Bl=3GgJmC8qzO_0rGT_g3<)FQz z`!^FF;C2dY`Z_-cBm9L`-+Q)gLIZZ~*yb=7-%18&UG!cz}OQ`KLu8sVy#cHj^U1%Ys{77Tt2k+SJ&);*vfwy)Sr&95S zp>PRO$IpZ-=hga%rvCmtLZ5u$XSd+t158v zXU!0QyCPe^)C5*7uJ>0~J+P&^RNy@4!mWIREj5LuG$%t*cwr=pZTKb_4^!IUR6Sh9I{OK~4T!Zgsms z0~Vaw-=b-ze2Xa`*CKrSy9<_0t1R8^_qg~>CJSn{fEfmCypCXHVQyA4)}MX^*r5-sGxtX43m6YzS$`~h^l*MivfkMQx{1Da&YpBj~qfxqi} zfAZ@uIsL`8g1{p!E2dY69E*eT78sm=3MHHEfC&To6wOE_qQefZtqZ!O0C#Zk92gBl zRy4@~y2t$`{KnkrLBCyl%mxu1LmE;tpvqau84(=EpcoeP+#39J7a{j4z`M2crv!7( z_rPI>3WUH;$nCRJGa#Jqz>GyzIgF5ldkC2}u7HLI3J$wmLQ&Y~Mt%-KbU1>4YrP@{ zMGmPfhry9}mY%ru33z&F=Hlvb{^xzfsv5*$w{mvD#_7vzIfq~&4xSQ0)etz{jt7_2 z=Bj4I%Vxw~1Ddxi-CGcFFCdhI!C4^2WAF+DK3;^&rl6~*53vjpgF4w)zhY)lxHrZV z!EUjJaxHu?kMI6!BmMD>L9SzeW)07uPS^ zQavUAwT_;+FsrT{u~-UjA zl9~@SMnwzBrat}UU+X^`$?V$s$V1%ZBS(>*RDusFhxUtCjvK&cTAjS=h}v8WkG5X> zX+w2U&Gnl@baq7vlA6pkQ6o-|4a4y?3WIKFiV8{7k?(UOA}XzaS~8i6Q{Kl{R^Zr$ z%SL&A-oBCrQ;&nUq%0bV85GgLl<=k8t0OmCyL*>~A70L#jzmV~e;<|aU`*v~`8giK zlcH&5A!_4!>(rtkBrwKw21+<++UV#hOgpjwibHOIjC| zMDI_h)B7rXo(b2B&Dc0D(mkY^=DaZVtA&sk1oRwohFZ_0z=Kn~NT zEKR8lR4000N*?yQ9X~ff`pwHuyTWz3a$Hdi1?5FeP5M~zxB^Bwylx%MZLr%D)M}$7 zYcq#nmkko=9*C}pB{C(|#qKpK;haol(f+JDP*vvL&he~0$&8W0=;X{@#N!JXy8$tn zG&PZ9-VsYXG#a(#IBc#+Y^bz5CQSnkE5yf>>L zBrHn0u!XK5y0AdAnXE3K2vF#(gIE5(GY_7C~Z>^ee{G$K!gMwO6Ly`5C48-bPS}# zhwQK?pY>nqL%x@;j4;HAOyjq4B`q}->FMbk0rV;zQkswet?nfFk&zLCQ7WLK`?{r? zz@@#vKQ$76GR8@4@-ZHP=y{{T$0K0222i7Kf;G?t0s&Z+wd2%~m=9Cpv(}(tf>)u% z&#_fVC>+3@}6yo<2R0t(S0EYFc%$+I}AQBe^rDJh_&7^KJ5Xq98vX=gyu*b5j%JmE@!~`x?y5nKNOv zTH*8gkgtBrzG$k7^%N3{5fBtg>p_mnAnASWkBPi~1!e7UYpPdYw6 zt}VP`kX z<}X;F=MJn_tIurZ9VC~X zolWq3pEk_;_3N={(IOgvB)H*`+@MM&nw-GNlP4?Rcy;Z^AYy=LpVlK-hr@w2Pd)YD z@7NeEbBBQ05|~a@t2Jg7TDEK%Lr}uaETNO@a&uTMZEspFQ*QtN5vo76u z_}!(SESwpg$kJzwGk&ui4imKL1@S<17)6sXl>|6e2#8MZ0aXpWM_v{DXr*bcLm)osf+m*%r_b0K{N-waY7~o^)0F^`#Kb~23SvIB2 zn%19`KqwFhk5#|$?H7GFf80^Es{77~w-**S4~1d#?1f?>p~NK6o2@4ve_Ypp`M&;s zGjs$1K{F&KgpeV!nsY3xla$h=Jut4cdvG{(cjs%K?-r!BrhN7jeeT+?2hnNqBGr9> zz$J;fGar>pgGq<_q8P9(&St zCvDx*TzqwZ0E6}>SUo?SuntInxX|rcSy`Oe^a4SP%J;FoV33x+p$R=eU;zMqB+>Fg z;O4&X_nclnuNjL!;>4Hsj3JO!4~zGg$ZL5*cq6PS2_r8nsik`uol zK#$V)rn~;OTmC9+UVIyKW@Tghi=D7$y@y;}&{jfh@S^fQArKwci9A7n0^I*3?E&-f z+^f{>ob@D{hc;sG+76^!?0EjA8%VYN2_fIb=<*pC6mx?cHoxCb55yW13t&934@@8& zAu%|oq5>KDpF&gr8XVl(hu*Ff)EsI=TKG6Hat%muT9QMI*X!lBnq_jb@DZ6(8AS{d zfkL&@B#G4gH7-8eos92Gl@xn%6`J|F=YA#q$1c=MR2)X znnZu>D9uf@a7i(y1S4NW!5=l$4e# z5_8ajO(>jMh;Qzxz}~%XH2TI7?%1h7gjmCM(zdp?njRpr2L;aY(aLd25->?{ui|i^ ztgH-Wvnz0W^l5y5cwQcMR~BPiwHxjJ7KGYsL1D=8en)aZlmy}ckG>QzmCvW<0Si?~ zM2?6&t8(97R5BMgeQU66kp-Jp7vkCH$Kkd96~T@-Kq)CH(VIO1-{0TQEr);?0s=Z3 zJc*hrITTLnP;U|u53zvvlW)rhsV7i8tO+cQ)(w1m%`Idc|3Cl`2f zo1B0VKBmxrlH9X!B7&>GyA;nY`wQ-RXCOQpg3aGfpxWwU%@Ze1;QICJSg~RS3JMB% zmBQci1jg$ZuH2IFx_lS8T$)5(UEP&Ed-fa!&>~ms=6`6+|IU;sU8P?3b6J33+#-l@ z!mh3^G&D5e)US?U>$*Z9*oyqJ)%e+O{*AkCO@Ksy=nWE~XLK$dK73e{Z)s^E35J_8 zN&$+Ci|7?y2`x%8yb|d)8{?cOvk4W4cc8q5;BRYdYh?pSZ)k07Y;3QrtgMZIZ&Nx-@X01|%oUW0 z%tN?;ga-jKo=L*vS%5y@`>6j{D;D}Ls0vjhdn2hh^c>dCC26%(O^h6FJ%Js#xGEZrWL?#|fE5n70f5&H*H>12_L3H(zg^k{0K@ji^8|KEq zu3fthsP8V*^5iDq9|{2>LEubolHmcp$LU0W)xwYCT0GBCBp`X(_GGEA_Ujs;XC%N0_j!ESCcQ|4u-E zLWsz;OWvOgX+8&Ad(6kRUn5M`ziQG<$$kjW&bVZ2* z&r*4rmN#R5svh7A#yL4++_)Js>338TAZY1xj&tYEy}M(_4(|RMm3DJZsW!=oxsdVg zEbxyhEmdmcWBhL=OiM??<#yyM$1mVGr%OQoQ=hHW&JcS@1OiOd2$7(GpAG?&1QpUg f1PN0qn5O&(UUTW@CzQg300000NkvXXu0mjfH*X2r delta 1573 zcmV+=2HN?N70wJHiBL{Q4GJ0x0000DNk~Le0000W0000W2nGNE0CReJ^pPPN3j=ll z00VXbebs`@kwzzf13fiiP4Y7A3rb>Kl~64kO&e{Vl=2hi7ghU87yshG=196qce1# zcgDR>W+z^6+i6JH$;!FUv({c`pNA=(PD8?EGMNEb@Nh$aBhHlEumB;?0Z^7f4jxV< z2{R1hrE5Krm9RMw41S-8$5|0f0zh}KZsjkzr&dC~|9@C47C0S_HUPg6M1bx;TOyu7 zJduQu3Cw085Kxs*dei&FlC`idIMqxsiQ#L8IYY$l!Gi~po0}_rXBEKg ziZD#-gL89=jDuaMs;WYMem?RDBg4bEeEG8acE^r?9jK|PfuCIQ`Fsp^PYD*utIX{LhtsJttEsI;Yip~n0IfMW7#SH+g|=?pI@H(KtM^irXU?2aE>%=i zz?qi^85RRyZ*Q;t#r++pZk#QAUu=?LNT*WD(&px7{fuB(EXoas!vPD4Vd3(Q+m@CV zNT~0B7c0U`r{8&Q`}QWcS3BDF&555j$S^QclwEaoHFAhR$VHrm2=gd2P1EF=5Xg|R zD>4-qci`fc$akCFb*AWCo;g}_yTRoDN;*?NH*ed9U@*w{29N_RLbBI^Yon>D2`O@M zsZizGefW!G_UYcCpD%7K7@GYWrqGWffU{SBB%x4~Bf>Z3(*|d4T{!ei46na` zHHx(MIgpr;4h;f$uE%0AAzo03-ENobMFmJ`gy5#eCoyT-gClz^IB@JQ#QYz?l$tY; zlW4U}&&zM6LDVaF`uX&@>SSA?0D==Q_}{>;hyhci8P}jW4c!76qkl zY$z$ii3@)tHu^3~OH0){uN=_3AjG;IRAvi3Ti$k@&e+N8yxZ-@^~7$hO^4Bc@41Jw zSAWBvR4+MDqq65^ zBYq2a?)V^?_x1JhZpn)lFWW4Prze9mCsAoSJLJRT@mvFNn?)>iDs}?cNu8dPvsIo(C{Uh^8r)5}+ezi@E4HyMX~B4d29S`=3Y_b)tT2n-U-!(B$MKZrt$T$dSX! ziShAqcm@Zj+V}3=2cVxYFXY*VK-P3FItGhTCm*lZh4H&CT>t%7Jn__jKI9h^vDG~G zYFNt4%T+ruF@d3>p}-5>-8}#Xggon!4Ek?$VoK=n+1S{Kl`B`G`VluK#_pkR{YEZ6 zc0y%cT~iGq@9F7znVww%5EAkQ1!Qr;u+_R;F05L$N-AHuBU7)E#0`?|U0q%KX}|ab zKv2ky0v<4Uujj)ilZpUr20P^SdhfKiw|4>X5W+&9O@NxCbkx!vA}9>4glxHTZlJ19 z(?RuGXJ_Y20EP&W#mSA+&{DAz!Wl6DN{^2@e+BS)BURu*~=u X5G)A Date: Mon, 1 Aug 2016 19:42:29 +0200 Subject: [PATCH 59/69] Improve pylint testing, fixed a few issues. --- openlp/plugins/songs/lib/openlyricsxml.py | 4 ++-- tests/utils/test_pylint.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/lib/openlyricsxml.py b/openlp/plugins/songs/lib/openlyricsxml.py index 5adffb300..e2964661d 100644 --- a/openlp/plugins/songs/lib/openlyricsxml.py +++ b/openlp/plugins/songs/lib/openlyricsxml.py @@ -458,7 +458,7 @@ class OpenLyrics(object): self._add_tag_to_formatting(tag, tags_element) # Replace end tags. for tag in end_tags: - text = text.replace('{/{tag}}}'.format(tag=tag), '') + text = text.replace('{{{tag}}}'.format(tag=tag), '') # Replace \n with
. text = text.replace('\n', '
') element = etree.XML('{text}'.format(text=text)) @@ -643,7 +643,7 @@ class OpenLyrics(object): # Append text from tail and add formatting end tag. # TODO: Verify format() with template variables if element.tag == NSMAP % 'tag' and use_endtag: - text += '{/{name}}}'.format(name=element.get('name')) + text += '{{{name}}}'.format(name=element.get('name')) # Append text from tail. if element.tail: text += element.tail diff --git a/tests/utils/test_pylint.py b/tests/utils/test_pylint.py index dc6c83909..1675a41ee 100644 --- a/tests/utils/test_pylint.py +++ b/tests/utils/test_pylint.py @@ -48,7 +48,7 @@ class TestPylint(TestCase): """ # GIVEN: Some checks to disable and enable, and the pylint script disabled_checks = 'import-error,no-member' - enabled_checks = 'missing-format-argument-key,unused-format-string-argument' + enabled_checks = 'missing-format-argument-key,unused-format-string-argument,bad-format-string' if is_win() or 'arch' in platform.dist()[0].lower(): pylint_script = 'pylint' else: From 76be31fee1f71221b4c38885404b61d354ec855f Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 1 Aug 2016 20:00:58 +0200 Subject: [PATCH 60/69] Only run pylint tests if specified. --- tests/utils/test_pylint.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/utils/test_pylint.py b/tests/utils/test_pylint.py index 1675a41ee..3d1333967 100644 --- a/tests/utils/test_pylint.py +++ b/tests/utils/test_pylint.py @@ -23,8 +23,8 @@ Package to test for proper bzr tags. """ import os -import logging import platform +import sys from unittest import TestCase, SkipTest try: @@ -35,6 +35,14 @@ except ImportError: from openlp.core.common import is_win +in_argv = False +for arg in sys.argv: + if arg.endswith('test_pylint.py'): + in_argv = True + break +if not in_argv: + raise SkipTest('test_pylint.py not specified in arguments - skipping tests using pylint.') + TOLERATED_ERRORS = {'registryproperties.py': ['access-member-before-definition'], 'opensong.py': ['no-name-in-module'], 'maindisplay.py': ['no-name-in-module']} From 7ca7ae9c074a596c9ab2143f342f031253181a30 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 1 Aug 2016 20:49:01 +0200 Subject: [PATCH 61/69] Ignore distutils errors --- tests/utils/test_pylint.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/utils/test_pylint.py b/tests/utils/test_pylint.py index 3d1333967..6b60fcf79 100644 --- a/tests/utils/test_pylint.py +++ b/tests/utils/test_pylint.py @@ -92,6 +92,9 @@ class TestPylint(TestCase): # Filter out PyQt related errors elif ('no-name-in-module' in line or 'no-member' in line) and 'PyQt5' in line: continue + # Filter out distutils related errors + elif 'distutils' in line: + continue elif self._is_line_tolerated(line): continue else: From c47321210770c4fec2edf9aada7cf401fc76c0db Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 2 Aug 2016 20:57:10 +0200 Subject: [PATCH 62/69] Added pylint test to jenkins script, and fixed a format error. --- openlp/core/lib/screen.py | 2 +- scripts/jenkins_script.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index e7b4c0b97..31ff3d725 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -167,7 +167,7 @@ class ScreenList(object): :param number: The screen number (int). """ - log.info('remove_screen {number:d}'.forma(number=number)) + log.info('remove_screen {number:d}'.format(number=number)) for screen in self.screen_list: if screen['number'] == number: self.screen_list.remove(screen) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index 61f74986a..0711d1257 100755 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -63,9 +63,10 @@ class OpenLPJobs(object): Branch_Windows_Interface = 'Branch-04b-Windows_Interface_Tests' Branch_PEP = 'Branch-05a-Code_Analysis' Branch_Coverage = 'Branch-05b-Test_Coverage' + Branch_Pylint = 'Branch-05c-Code_Analysis2' Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows_Functional, Branch_Windows_Interface, - Branch_PEP, Branch_Coverage] + Branch_PEP, Branch_Coverage, Branch_Pylint] class Colour(object): From 82faa1da5e5e73fe81723d908038f23dc3d181ea Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 2 Aug 2016 21:32:36 +0200 Subject: [PATCH 63/69] Change pylint test so it works with nose2 --- tests/utils/test_pylint.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/utils/test_pylint.py b/tests/utils/test_pylint.py index 6b60fcf79..48c9e1393 100644 --- a/tests/utils/test_pylint.py +++ b/tests/utils/test_pylint.py @@ -35,14 +35,6 @@ except ImportError: from openlp.core.common import is_win -in_argv = False -for arg in sys.argv: - if arg.endswith('test_pylint.py'): - in_argv = True - break -if not in_argv: - raise SkipTest('test_pylint.py not specified in arguments - skipping tests using pylint.') - TOLERATED_ERRORS = {'registryproperties.py': ['access-member-before-definition'], 'opensong.py': ['no-name-in-module'], 'maindisplay.py': ['no-name-in-module']} @@ -54,6 +46,15 @@ class TestPylint(TestCase): """ Test for pylint errors """ + # Test if this file is specified in the arguments, if not skip the test. + in_argv = False + for arg in sys.argv: + if arg.endswith('test_pylint.py') or arg.endswith('test_pylint'): + in_argv = True + break + if not in_argv: + raise SkipTest('test_pylint.py not specified in arguments - skipping tests using pylint.') + # GIVEN: Some checks to disable and enable, and the pylint script disabled_checks = 'import-error,no-member' enabled_checks = 'missing-format-argument-key,unused-format-string-argument,bad-format-string' From 60767c8ce47b36b4d41cddf2197d515fe9bc7929 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Wed, 3 Aug 2016 18:26:10 +0100 Subject: [PATCH 64/69] Fixes bug #917164. A start on refactoring bibles --- openlp/core/common/languages.py | 201 ++++++++++++++++++ openlp/plugins/bibles/forms/languageform.py | 10 +- openlp/plugins/bibles/lib/db.py | 52 +---- openlp/plugins/bibles/lib/osis.py | 10 +- openlp/plugins/bibles/lib/sword.py | 7 +- openlp/plugins/bibles/lib/zefania.py | 8 +- .../openlp_plugins/bibles/test_swordimport.py | 6 +- 7 files changed, 235 insertions(+), 59 deletions(-) create mode 100644 openlp/core/common/languages.py diff --git a/openlp/core/common/languages.py b/openlp/core/common/languages.py new file mode 100644 index 000000000..1977b7891 --- /dev/null +++ b/openlp/core/common/languages.py @@ -0,0 +1,201 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2016 OpenLP Developers # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +The :mod:`languages` module provides a list of language names with utility functions. +""" +from collections import namedtuple + +from openlp.core.common import translate + + +Language = namedtuple('Language', ['id', 'name', 'code']) +languages = sorted([ + Language(1, translate('common.languages', '(Afan) Oromo', 'Language code: om'), 'om'), + Language(2, translate('common.languages', 'Abkhazian', 'Language code: ab'), 'ab'), + Language(3, translate('common.languages', 'Afar', 'Language code: aa'), 'aa'), + Language(4, translate('common.languages', 'Afrikaans', 'Language code: af'), 'af'), + Language(5, translate('common.languages', 'Albanian', 'Language code: sq'), 'sq'), + Language(6, translate('common.languages', 'Amharic', 'Language code: am'), 'am'), + Language(140, translate('common.languages', 'Amuzgo', 'Language code: amu'), 'amu'), + Language(152, translate('common.languages', 'Ancient Greek', 'Language code: grc'), 'grc'), + Language(7, translate('common.languages', 'Arabic', 'Language code: ar'), 'ar'), + Language(8, translate('common.languages', 'Armenian', 'Language code: hy'), 'hy'), + Language(9, translate('common.languages', 'Assamese', 'Language code: as'), 'as'), + Language(10, translate('common.languages', 'Aymara', 'Language code: ay'), 'ay'), + Language(11, translate('common.languages', 'Azerbaijani', 'Language code: az'), 'az'), + Language(12, translate('common.languages', 'Bashkir', 'Language code: ba'), 'ba'), + Language(13, translate('common.languages', 'Basque', 'Language code: eu'), 'eu'), + Language(14, translate('common.languages', 'Bengali', 'Language code: bn'), 'bn'), + Language(15, translate('common.languages', 'Bhutani', 'Language code: dz'), 'dz'), + Language(16, translate('common.languages', 'Bihari', 'Language code: bh'), 'bh'), + Language(17, translate('common.languages', 'Bislama', 'Language code: bi'), 'bi'), + Language(18, translate('common.languages', 'Breton', 'Language code: br'), 'br'), + Language(19, translate('common.languages', 'Bulgarian', 'Language code: bg'), 'bg'), + Language(20, translate('common.languages', 'Burmese', 'Language code: my'), 'my'), + Language(21, translate('common.languages', 'Byelorussian', 'Language code: be'), 'be'), + Language(142, translate('common.languages', 'Cakchiquel', 'Language code: cak'), 'cak'), + Language(22, translate('common.languages', 'Cambodian', 'Language code: km'), 'km'), + Language(23, translate('common.languages', 'Catalan', 'Language code: ca'), 'ca'), + Language(24, translate('common.languages', 'Chinese', 'Language code: zh'), 'zh'), + Language(141, translate('common.languages', 'Comaltepec Chinantec', 'Language code: cco'), 'cco'), + Language(25, translate('common.languages', 'Corsican', 'Language code: co'), 'co'), + Language(26, translate('common.languages', 'Croatian', 'Language code: hr'), 'hr'), + Language(27, translate('common.languages', 'Czech', 'Language code: cs'), 'cs'), + Language(28, translate('common.languages', 'Danish', 'Language code: da'), 'da'), + Language(29, translate('common.languages', 'Dutch', 'Language code: nl'), 'nl'), + Language(30, translate('common.languages', 'English', 'Language code: en'), 'en'), + Language(31, translate('common.languages', 'Esperanto', 'Language code: eo'), 'eo'), + Language(32, translate('common.languages', 'Estonian', 'Language code: et'), 'et'), + Language(33, translate('common.languages', 'Faeroese', 'Language code: fo'), 'fo'), + Language(34, translate('common.languages', 'Fiji', 'Language code: fj'), 'fj'), + Language(35, translate('common.languages', 'Finnish', 'Language code: fi'), 'fi'), + Language(36, translate('common.languages', 'French', 'Language code: fr'), 'fr'), + Language(37, translate('common.languages', 'Frisian', 'Language code: fy'), 'fy'), + Language(38, translate('common.languages', 'Galician', 'Language code: gl'), 'gl'), + Language(39, translate('common.languages', 'Georgian', 'Language code: ka'), 'ka'), + Language(40, translate('common.languages', 'German', 'Language code: de'), 'de'), + Language(41, translate('common.languages', 'Greek', 'Language code: el'), 'el'), + Language(42, translate('common.languages', 'Greenlandic', 'Language code: kl'), 'kl'), + Language(43, translate('common.languages', 'Guarani', 'Language code: gn'), 'gn'), + Language(44, translate('common.languages', 'Gujarati', 'Language code: gu'), 'gu'), + Language(143, translate('common.languages', 'Haitian Creole', 'Language code: ht'), 'ht'), + Language(45, translate('common.languages', 'Hausa', 'Language code: ha'), 'ha'), + Language(46, translate('common.languages', 'Hebrew (former iw)', 'Language code: he'), 'he'), + Language(144, translate('common.languages', 'Hiligaynon', 'Language code: hil'), 'hil'), + Language(47, translate('common.languages', 'Hindi', 'Language code: hi'), 'hi'), + Language(48, translate('common.languages', 'Hungarian', 'Language code: hu'), 'hu'), + Language(49, translate('common.languages', 'Icelandic', 'Language code: is'), 'is'), + Language(50, translate('common.languages', 'Indonesian (former in)', 'Language code: id'), 'id'), + Language(51, translate('common.languages', 'Interlingua', 'Language code: ia'), 'ia'), + Language(52, translate('common.languages', 'Interlingue', 'Language code: ie'), 'ie'), + Language(54, translate('common.languages', 'Inuktitut (Eskimo)', 'Language code: iu'), 'iu'), + Language(53, translate('common.languages', 'Inupiak', 'Language code: ik'), 'ik'), + Language(55, translate('common.languages', 'Irish', 'Language code: ga'), 'ga'), + Language(56, translate('common.languages', 'Italian', 'Language code: it'), 'it'), + Language(145, translate('common.languages', 'Jakalteko', 'Language code: jac'), 'jac'), + Language(57, translate('common.languages', 'Japanese', 'Language code: ja'), 'ja'), + Language(58, translate('common.languages', 'Javanese', 'Language code: jw'), 'jw'), + Language(150, translate('common.languages', 'K\'iche\'', 'Language code: quc'), 'quc'), + Language(59, translate('common.languages', 'Kannada', 'Language code: kn'), 'kn'), + Language(60, translate('common.languages', 'Kashmiri', 'Language code: ks'), 'ks'), + Language(61, translate('common.languages', 'Kazakh', 'Language code: kk'), 'kk'), + Language(146, translate('common.languages', 'Kekchí ', 'Language code: kek'), 'kek'), + Language(62, translate('common.languages', 'Kinyarwanda', 'Language code: rw'), 'rw'), + Language(63, translate('common.languages', 'Kirghiz', 'Language code: ky'), 'ky'), + Language(64, translate('common.languages', 'Kirundi', 'Language code: rn'), 'rn'), + Language(65, translate('common.languages', 'Korean', 'Language code: ko'), 'ko'), + Language(66, translate('common.languages', 'Kurdish', 'Language code: ku'), 'ku'), + Language(67, translate('common.languages', 'Laothian', 'Language code: lo'), 'lo'), + Language(68, translate('common.languages', 'Latin', 'Language code: la'), 'la'), + Language(69, translate('common.languages', 'Latvian, Lettish', 'Language code: lv'), 'lv'), + Language(70, translate('common.languages', 'Lingala', 'Language code: ln'), 'ln'), + Language(71, translate('common.languages', 'Lithuanian', 'Language code: lt'), 'lt'), + Language(72, translate('common.languages', 'Macedonian', 'Language code: mk'), 'mk'), + Language(73, translate('common.languages', 'Malagasy', 'Language code: mg'), 'mg'), + Language(74, translate('common.languages', 'Malay', 'Language code: ms'), 'ms'), + Language(75, translate('common.languages', 'Malayalam', 'Language code: ml'), 'ml'), + Language(76, translate('common.languages', 'Maltese', 'Language code: mt'), 'mt'), + Language(148, translate('common.languages', 'Mam', 'Language code: mam'), 'mam'), + Language(77, translate('common.languages', 'Maori', 'Language code: mi'), 'mi'), + Language(147, translate('common.languages', 'Maori', 'Language code: mri'), 'mri'), + Language(78, translate('common.languages', 'Marathi', 'Language code: mr'), 'mr'), + Language(79, translate('common.languages', 'Moldavian', 'Language code: mo'), 'mo'), + Language(80, translate('common.languages', 'Mongolian', 'Language code: mn'), 'mn'), + Language(149, translate('common.languages', 'Nahuatl', 'Language code: nah'), 'nah'), + Language(81, translate('common.languages', 'Nauru', 'Language code: na'), 'na'), + Language(82, translate('common.languages', 'Nepali', 'Language code: ne'), 'ne'), + Language(83, translate('common.languages', 'Norwegian', 'Language code: no'), 'no'), + Language(84, translate('common.languages', 'Occitan', 'Language code: oc'), 'oc'), + Language(85, translate('common.languages', 'Oriya', 'Language code: or'), 'or'), + Language(86, translate('common.languages', 'Pashto, Pushto', 'Language code: ps'), 'ps'), + Language(87, translate('common.languages', 'Persian', 'Language code: fa'), 'fa'), + Language(151, translate('common.languages', 'Plautdietsch', 'Language code: pdt'), 'pdt'), + Language(88, translate('common.languages', 'Polish', 'Language code: pl'), 'pl'), + Language(89, translate('common.languages', 'Portuguese', 'Language code: pt'), 'pt'), + Language(90, translate('common.languages', 'Punjabi', 'Language code: pa'), 'pa'), + Language(91, translate('common.languages', 'Quechua', 'Language code: qu'), 'qu'), + Language(92, translate('common.languages', 'Rhaeto-Romance', 'Language code: rm'), 'rm'), + Language(93, translate('common.languages', 'Romanian', 'Language code: ro'), 'ro'), + Language(94, translate('common.languages', 'Russian', 'Language code: ru'), 'ru'), + Language(95, translate('common.languages', 'Samoan', 'Language code: sm'), 'sm'), + Language(96, translate('common.languages', 'Sangro', 'Language code: sg'), 'sg'), + Language(97, translate('common.languages', 'Sanskrit', 'Language code: sa'), 'sa'), + Language(98, translate('common.languages', 'Scots Gaelic', 'Language code: gd'), 'gd'), + Language(99, translate('common.languages', 'Serbian', 'Language code: sr'), 'sr'), + Language(100, translate('common.languages', 'Serbo-Croatian', 'Language code: sh'), 'sh'), + Language(101, translate('common.languages', 'Sesotho', 'Language code: st'), 'st'), + Language(102, translate('common.languages', 'Setswana', 'Language code: tn'), 'tn'), + Language(103, translate('common.languages', 'Shona', 'Language code: sn'), 'sn'), + Language(104, translate('common.languages', 'Sindhi', 'Language code: sd'), 'sd'), + Language(105, translate('common.languages', 'Singhalese', 'Language code: si'), 'si'), + Language(106, translate('common.languages', 'Siswati', 'Language code: ss'), 'ss'), + Language(107, translate('common.languages', 'Slovak', 'Language code: sk'), 'sk'), + Language(108, translate('common.languages', 'Slovenian', 'Language code: sl'), 'sl'), + Language(109, translate('common.languages', 'Somali', 'Language code: so'), 'so'), + Language(110, translate('common.languages', 'Spanish', 'Language code: es'), 'es'), + Language(111, translate('common.languages', 'Sudanese', 'Language code: su'), 'su'), + Language(112, translate('common.languages', 'Swahili', 'Language code: sw'), 'sw'), + Language(113, translate('common.languages', 'Swedish', 'Language code: sv'), 'sv'), + Language(114, translate('common.languages', 'Tagalog', 'Language code: tl'), 'tl'), + Language(115, translate('common.languages', 'Tajik', 'Language code: tg'), 'tg'), + Language(116, translate('common.languages', 'Tamil', 'Language code: ta'), 'ta'), + Language(117, translate('common.languages', 'Tatar', 'Language code: tt'), 'tt'), + Language(118, translate('common.languages', 'Tegulu', 'Language code: te'), 'te'), + Language(119, translate('common.languages', 'Thai', 'Language code: th'), 'th'), + Language(120, translate('common.languages', 'Tibetan', 'Language code: bo'), 'bo'), + Language(121, translate('common.languages', 'Tigrinya', 'Language code: ti'), 'ti'), + Language(122, translate('common.languages', 'Tonga', 'Language code: to'), 'to'), + Language(123, translate('common.languages', 'Tsonga', 'Language code: ts'), 'ts'), + Language(124, translate('common.languages', 'Turkish', 'Language code: tr'), 'tr'), + Language(125, translate('common.languages', 'Turkmen', 'Language code: tk'), 'tk'), + Language(126, translate('common.languages', 'Twi', 'Language code: tw'), 'tw'), + Language(127, translate('common.languages', 'Uigur', 'Language code: ug'), 'ug'), + Language(128, translate('common.languages', 'Ukrainian', 'Language code: uk'), 'uk'), + Language(129, translate('common.languages', 'Urdu', 'Language code: ur'), 'ur'), + Language(153, translate('common.languages', 'Uspanteco', 'Language code: usp'), 'usp'), + Language(130, translate('common.languages', 'Uzbek', 'Language code: uz'), 'uz'), + Language(131, translate('common.languages', 'Vietnamese', 'Language code: vi'), 'vi'), + Language(132, translate('common.languages', 'Volapuk', 'Language code: vo'), 'vo'), + Language(133, translate('common.languages', 'Welch', 'Language code: cy'), 'cy'), + Language(134, translate('common.languages', 'Wolof', 'Language code: wo'), 'wo'), + Language(135, translate('common.languages', 'Xhosa', 'Language code: xh'), 'xh'), + Language(136, translate('common.languages', 'Yiddish (former ji)', 'Language code: yi'), 'yi'), + Language(137, translate('common.languages', 'Yoruba', 'Language code: yo'), 'yo'), + Language(138, translate('common.languages', 'Zhuang', 'Language code: za'), 'za'), + Language(139, translate('common.languages', 'Zulu', 'Language code: zu'), 'zu') + ], key=lambda language: language.name) + + +def get_language(name): + """ + Find the language by its name or code. + + :param name: The name or abbreviation of the language. + :return: The first match as a Language namedtuple or None + """ + if name: + name_lower = name.lower() + name_title = name_lower[:1].upper() + name_lower[1:] + for language in languages: + if language.name == name_title or language.code == name_lower: + return language + return None \ No newline at end of file diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index 461f02c74..1ba71ad6e 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -29,9 +29,9 @@ from PyQt5.QtWidgets import QDialog from PyQt5 import QtCore from openlp.core.common import translate +from openlp.core.common.languages import languages from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.bibles.forms.languagedialog import Ui_LanguageDialog -from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) @@ -51,11 +51,11 @@ class LanguageForm(QDialog, Ui_LanguageDialog): self.setupUi(self) def exec(self, bible_name): - self.language_combo_box.addItem('') if bible_name: - self.bible_label.setText(str(bible_name)) - items = BiblesResourcesDB.get_languages() - self.language_combo_box.addItems([item['name'] for item in items]) + self.bible_label.setText(bible_name) + self.language_combo_box.addItem('') + for language in languages: + self.language_combo_box.addItem(language.name, language.id) return QDialog.exec(self) def accept(self): diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index c23ade4a7..87f511d83 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -128,6 +128,12 @@ class BibleDB(Manager, RegistryProperties): The name of the database. This is also used as the file name for SQLite databases. """ log.info('BibleDB loaded') + self._setup(parent, **kwargs) + + def _setup(self, parent, **kwargs): + """ + Run some initial setup. This method is separate from __init__ in order to mock it out in tests. + """ self.bible_plugin = parent self.session = None if 'path' not in kwargs: @@ -465,14 +471,13 @@ class BibleDB(Manager, RegistryProperties): """ log.debug('BibleDB.get_language()') from openlp.plugins.bibles.forms import LanguageForm - language = None + language_id = None language_form = LanguageForm(self.wizard) if language_form.exec(bible_name): - language = str(language_form.language_combo_box.currentText()) - if not language: + combo_box = language_form.language_combo_box + language_id = combo_box.itemData(combo_box.currentIndex()) + if not language_id: return False - language = BiblesResourcesDB.get_language(language) - language_id = language['id'] self.save_meta('language_id', language_id) return language_id @@ -767,43 +772,6 @@ class BiblesResourcesDB(QtCore.QObject, Manager): return book[0] return None - @staticmethod - def get_language(name): - """ - Return a dict containing the language id, name and code by name or abbreviation. - - :param name: The name or abbreviation of the language. - """ - log.debug('BiblesResourcesDB.get_language("{name}")'.format(name=name)) - if not isinstance(name, str): - name = str(name) - language = BiblesResourcesDB.run_sql( - 'SELECT id, name, code FROM language WHERE name = ? OR code = ?', (name, name.lower())) - if language: - return { - 'id': language[0][0], - 'name': str(language[0][1]), - 'code': str(language[0][2]) - } - else: - return None - - @staticmethod - def get_languages(): - """ - Return a dict containing all languages with id, name and code. - """ - log.debug('BiblesResourcesDB.get_languages()') - languages = BiblesResourcesDB.run_sql('SELECT id, name, code FROM language ORDER by name') - if languages: - return [{ - 'id': language[0], - 'name': str(language[1]), - 'code': str(language[2]) - } for language in languages] - else: - return None - @staticmethod def get_testament_reference(): """ diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 85aea70b3..4b217022e 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -23,7 +23,7 @@ import logging from lxml import etree -from openlp.core.common import translate, trace_error_handler +from openlp.core.common import languages, translate, trace_error_handler from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB from openlp.core.lib.ui import critical_error_message_box @@ -62,9 +62,11 @@ class OSISBible(BibleDB): namespace = {'ns': 'http://www.bibletechnologies.net/2003/OSIS/namespace'} # Find bible language language_id = None - language = osis_bible_tree.xpath("//ns:osisText/@xml:lang", namespaces=namespace) - if language: - language_id = BiblesResourcesDB.get_language(language[0]) + lang = osis_bible_tree.xpath("//ns:osisText/@xml:lang", namespaces=namespace) + if lang: + language = languages.get_language(lang[0]) + if hasattr(language, 'id'): + language_id = language.id # The language couldn't be detected, ask the user if not language_id: language_id = self.get_language(bible_name) diff --git a/openlp/plugins/bibles/lib/sword.py b/openlp/plugins/bibles/lib/sword.py index 77f08cb47..b37e9b583 100644 --- a/openlp/plugins/bibles/lib/sword.py +++ b/openlp/plugins/bibles/lib/sword.py @@ -23,7 +23,7 @@ import logging from pysword import modules -from openlp.core.common import translate +from openlp.core.common import languages, translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB @@ -57,9 +57,12 @@ class SwordBible(BibleDB): pysword_modules = modules.SwordModules(self.sword_path) pysword_module_json = pysword_modules.parse_modules()[self.sword_key] bible = pysword_modules.get_bible_from_module(self.sword_key) + language_id = None language = pysword_module_json['lang'] language = language[language.find('.') + 1:] - language_id = BiblesResourcesDB.get_language(language)['id'] + language = languages.get_language(language) + if hasattr(language, 'id'): + language_id = language.id self.save_meta('language_id', language_id) books = bible.get_structure().get_books() # Count number of books diff --git a/openlp/plugins/bibles/lib/zefania.py b/openlp/plugins/bibles/lib/zefania.py index 482d98107..96ab69072 100644 --- a/openlp/plugins/bibles/lib/zefania.py +++ b/openlp/plugins/bibles/lib/zefania.py @@ -21,9 +21,9 @@ ############################################################################### import logging -from lxml import etree, objectify +from lxml import etree -from openlp.core.common import translate +from openlp.core.common import languages, translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB @@ -62,7 +62,9 @@ class ZefaniaBible(BibleDB): language_id = None language = zefania_bible_tree.xpath("/XMLBIBLE/INFORMATION/language/text()") if language: - language_id = BiblesResourcesDB.get_language(language[0]) + language = languages.get_language(language[0]) + if hasattr(language, 'id'): + language_id = language.id # The language couldn't be detected, ask the user if not language_id: language_id = self.get_language(bible_name) diff --git a/tests/functional/openlp_plugins/bibles/test_swordimport.py b/tests/functional/openlp_plugins/bibles/test_swordimport.py index ca3c03691..25b6ab355 100644 --- a/tests/functional/openlp_plugins/bibles/test_swordimport.py +++ b/tests/functional/openlp_plugins/bibles/test_swordimport.py @@ -70,8 +70,8 @@ class TestSwordImport(TestCase): @patch('openlp.plugins.bibles.lib.sword.SwordBible.application') @patch('openlp.plugins.bibles.lib.sword.modules') - @patch('openlp.plugins.bibles.lib.db.BiblesResourcesDB') - def test_simple_import(self, mocked_bible_res_db, mocked_pysword_modules, mocked_application): + @patch('openlp.core.common.languages') + def test_simple_import(self, mocked_languages, mocked_pysword_modules, mocked_application): """ Test that a simple SWORD import works """ @@ -88,7 +88,7 @@ class TestSwordImport(TestCase): importer.create_verse = MagicMock() importer.create_book = MagicMock() importer.session = MagicMock() - mocked_bible_res_db.get_language.return_value = 'Danish' + mocked_languages.get_language.return_value = 'Danish' mocked_bible = MagicMock() mocked_genesis = MagicMock() mocked_genesis.name = 'Genesis' From db00a3980fe2bb4acabf15479adf973f3e568748 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Wed, 3 Aug 2016 20:56:53 +0100 Subject: [PATCH 65/69] Missed tests --- .../openlp_core_common/test_languages.py | 109 ++++++++++++++++++ .../openlp_plugins/bibles/test_db.py | 87 ++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 tests/functional/openlp_core_common/test_languages.py create mode 100644 tests/functional/openlp_plugins/bibles/test_db.py diff --git a/tests/functional/openlp_core_common/test_languages.py b/tests/functional/openlp_core_common/test_languages.py new file mode 100644 index 000000000..6ef48171d --- /dev/null +++ b/tests/functional/openlp_core_common/test_languages.py @@ -0,0 +1,109 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2016 OpenLP Developers # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +Package to test the openlp.core.lib.languages package. +""" +from unittest import TestCase + +from openlp.core.common import languages + + +class TestLanguages(TestCase): + + def languages_type_test(self): + """ + Test the languages variable type + """ + + # GIVEN: The languages module + # WHEN: Accessing the languages variable + # THEN: It should be of type list + self.assertIsInstance(languages.languages, list, 'languages.languages should be of type list') + + def language_selection_languages_type_test(self): + """ + Test the selection of a language + """ + + # GIVEN: A list of languages from the languages module + # WHEN: Selecting the first item + language = languages.languages[0] + + # THEN: It should be an instance of the Language namedtuple + self.assertIsInstance(language, languages.Language) + self.assertEqual(language.id, 1) + self.assertEqual(language.name, '(Afan) Oromo') + self.assertEqual(language.code, 'om') + + def get_language_name_test(self): + """ + Test get_language() when supplied with a language name. + """ + + # GIVEN: A language name, in capitals + # WHEN: Calling get_language with it + language = languages.get_language('YORUBA') + + # THEN: The Language found using that name should be returned + self.assertIsInstance(language, languages.Language) + self.assertEqual(language.id, 137) + self.assertEqual(language.name, 'Yoruba') + self.assertEqual(language.code, 'yo') + + def get_language_code_test(self): + """ + Test get_language() when supplied with a language code. + """ + + # GIVEN: A language code in capitals + # WHEN: Calling get_language with it + language = languages.get_language('IA') + + # THEN: The Language found using that code should be returned + self.assertIsInstance(language, languages.Language) + self.assertEqual(language.id, 51) + self.assertEqual(language.name, 'Interlingua') + self.assertEqual(language.code, 'ia') + + def get_language_invalid_test(self): + """ + Test get_language() when supplied with a string which is not a valid language name or code. + """ + + # GIVEN: A language code + # WHEN: Calling get_language with it + language = languages.get_language('qwerty') + + # THEN: None should be returned + self.assertIsNone(language) + + def get_language_invalid__none_test(self): + """ + Test get_language() when supplied with a string which is not a valid language name or code. + """ + + # GIVEN: A language code + # WHEN: Calling get_language with it + language = languages.get_language(None) + + # THEN: None should be returned + self.assertIsNone(language) \ No newline at end of file diff --git a/tests/functional/openlp_plugins/bibles/test_db.py b/tests/functional/openlp_plugins/bibles/test_db.py new file mode 100644 index 000000000..9eb841ccf --- /dev/null +++ b/tests/functional/openlp_plugins/bibles/test_db.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2016 OpenLP Developers # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +This module contains tests for the db submodule of the Bibles plugin. +""" + +from unittest import TestCase + +from openlp.plugins.bibles.lib.db import BibleDB +from tests.functional import MagicMock, patch + + +class TestBibleDB(TestCase): + """ + Test the functions in the BibleDB class. + """ + + def test_get_language_canceled(self): + """ + Test the BibleDB.get_language method when the user rejects the dialog box + """ + # GIVEN: A mocked LanguageForm with an exec method which returns QtDialog.Rejected and an instance of BibleDB + with patch('openlp.plugins.bibles.lib.db.BibleDB._setup'),\ + patch('openlp.plugins.bibles.forms.LanguageForm') as mocked_language_form: + + # The integer value of QtDialog.Rejected is 0. Using the enumeration causes a seg fault for some reason + mocked_language_form_instance = MagicMock(**{'exec.return_value': 0}) + mocked_language_form.return_value = mocked_language_form_instance + mocked_parent = MagicMock() + instance = BibleDB(mocked_parent) + mocked_wizard = MagicMock() + instance.wizard = mocked_wizard + + # WHEN: Calling get_language() + result = instance.get_language() + + # THEN: get_language() should return False + mocked_language_form.assert_called_once_with(mocked_wizard) + mocked_language_form_instance.exec.assert_called_once_with(None) + self.assertFalse(result, 'get_language() should return False if the user rejects the dialog box') + + def test_get_language_accepted(self): + """ + Test the BibleDB.get_language method when the user accepts the dialog box + """ + # GIVEN: A mocked LanguageForm with an exec method which returns QtDialog.Accepted an instance of BibleDB and + # a combobox with the selected item data as 10 + with patch('openlp.plugins.bibles.lib.db.BibleDB._setup'), \ + patch('openlp.plugins.bibles.lib.db.BibleDB.save_meta'), \ + patch('openlp.plugins.bibles.forms.LanguageForm') as mocked_language_form: + + # The integer value of QtDialog.Accepted is 1. Using the enumeration causes a seg fault for some reason + mocked_language_form_instance = MagicMock(**{'exec.return_value': 1, + 'language_combo_box.itemData.return_value': 10}) + mocked_language_form.return_value = mocked_language_form_instance + mocked_parent = MagicMock() + instance = BibleDB(mocked_parent) + mocked_wizard = MagicMock() + instance.wizard = mocked_wizard + + # WHEN: Calling get_language() + result = instance.get_language('Bible Name') + + # THEN: get_language() should return the id of the selected language in the combo box + mocked_language_form.assert_called_once_with(mocked_wizard) + mocked_language_form_instance.exec.assert_called_once_with('Bible Name') + self.assertEqual(result, 10, 'get_language() should return the id of the language the user has chosen when ' + 'they accept the dialog box') \ No newline at end of file From d9d740ad8b58f0abd0cbb3713b1121e86a536462 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Wed, 3 Aug 2016 21:10:41 +0100 Subject: [PATCH 66/69] Style fixes --- tests/functional/openlp_core_common/test_languages.py | 2 +- tests/functional/openlp_plugins/bibles/test_db.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_core_common/test_languages.py b/tests/functional/openlp_core_common/test_languages.py index 6ef48171d..fa6756d08 100644 --- a/tests/functional/openlp_core_common/test_languages.py +++ b/tests/functional/openlp_core_common/test_languages.py @@ -106,4 +106,4 @@ class TestLanguages(TestCase): language = languages.get_language(None) # THEN: None should be returned - self.assertIsNone(language) \ No newline at end of file + self.assertIsNone(language) diff --git a/tests/functional/openlp_plugins/bibles/test_db.py b/tests/functional/openlp_plugins/bibles/test_db.py index 9eb841ccf..2807a8a3e 100644 --- a/tests/functional/openlp_plugins/bibles/test_db.py +++ b/tests/functional/openlp_plugins/bibles/test_db.py @@ -84,4 +84,4 @@ class TestBibleDB(TestCase): mocked_language_form.assert_called_once_with(mocked_wizard) mocked_language_form_instance.exec.assert_called_once_with('Bible Name') self.assertEqual(result, 10, 'get_language() should return the id of the language the user has chosen when ' - 'they accept the dialog box') \ No newline at end of file + 'they accept the dialog box') From bf28102401afae3e87cdbac2b875e7ac84d0ca26 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Wed, 3 Aug 2016 21:17:48 +0100 Subject: [PATCH 67/69] More style fixes --- openlp/core/common/languages.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/common/languages.py b/openlp/core/common/languages.py index 1977b7891..18235ac10 100644 --- a/openlp/core/common/languages.py +++ b/openlp/core/common/languages.py @@ -182,7 +182,7 @@ languages = sorted([ Language(137, translate('common.languages', 'Yoruba', 'Language code: yo'), 'yo'), Language(138, translate('common.languages', 'Zhuang', 'Language code: za'), 'za'), Language(139, translate('common.languages', 'Zulu', 'Language code: zu'), 'zu') - ], key=lambda language: language.name) +], key=lambda language: language.name) def get_language(name): @@ -198,4 +198,4 @@ def get_language(name): for language in languages: if language.name == name_title or language.code == name_lower: return language - return None \ No newline at end of file + return None From 37a5050c38673a451082e89d7d479c17b44073de Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Thu, 4 Aug 2016 20:18:40 +0100 Subject: [PATCH 68/69] Removed language table from database --- .../bibles/resources/bibles_resources.sqlite | Bin 104448 -> 97280 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins/bibles/resources/bibles_resources.sqlite index 8f1777124032ee11b547fd6e1897f7e9b8b717a9..0db28194e553216f9e0597efa90032ec9a797c3e 100644 GIT binary patch delta 3493 zcmaJ^dr*|u6+ic$Zvhc`E%FeQ_roVF2nvbLW|9UZBp4Qr}$gaCmFaxsG#m)cjpq5F}Rj6eK3YFZD0Xm z>aHDxDZ4TWllz+pllrZMiG5{+3B6kh<9jC)PUu-hIKC%@Fs{3pFxGSujx$pUV;VSj zgdva?(N3?+#6JDFf6yRIx7iYChN6FBVWBW5s`26DRJ=7neHtDu3{_V-PK8)=RYdq< zPju)bF<}haK|(BuuL!L4efsHXw5VGZ9U{O}SLqaTqoLNu*o1|A#ChI`NfHK`Dz~}U zTZc*L&m)(3f?EGAT@AaFh^gN#2p12oCafFGAzUI`Bfy!NlgcZ9Y3CnkJsQLZR6PER_AS~^lK{&5JoUo*iYg^pMYo(}k$ggMci*|wWczd*5i8~ zBSIJ+%g%%7-ZxgA?OEt8|0ujd8NeD(P~-bpu-fE4t}-QIql4g?7J`)x1S?7jmUGRQ zB@iqP)eEW*WTtRHpWEDu=DN{pTl5kUs{RmtAkZubq@`3Q%q_}{9;a$Y2dFMpi%gLstRes&f$K~796p9ia1q{sUr-+V zIPoVR&U+!vt_fNpJ`iI>Eo=ch7@BOO8HH-HiO3`-YiN!wkjMjTXxL`@X80HftcQu( zsEG=ZPV(iVnmn$j;!R>jH4)zd48>G0xf!ZR;DCi%*F>RX*jW{gX@#}m|CDKiV$F0> z6WYN~9ep**)efC7*(YwJkmK1=6?D;*!Zpe6qczz|xz5vM6FHg1WF-+z5XEE#4Rb=A zCb{JWnrxy(Qhj7IBr{n~X?KE4XqqRR#c7nmHd3sIahiFKJhp<=jFY0bLzs_oP}mS2 zUIrUUZqxD>s_h2wE~irRw1vi4*r=4OJ0X_IdE|5hQ%q&# zsZ3DA?vycF(n6k`FhvFLPjcl@)w?KWCls+V8ycvmc9_9kVWyqDI_aCMwe{rL4uP6k zM7qsT7>tQz$_s!quGG2(R469|X`L^`T+Nn|rj-(G2tpT!e96pVw#Ej&Z0fbGPG*{q;bg|}z753! z-nU=i5bfJvx5D! z8))9mP^R8}&FZSB{yL$K&Fe|rN#%=Vn|d;Lz^Q;7wu@*`7fB;{lFV>>I-%Cb7SrNvf<@Z29X6~cXZbwM3`!e6$M^6E?xCrzrXwj2 zt@5$_o4hCw$pN`Vu9W36TZYilbBm6hv*KlOQ1pxMie^zK@$!(PA#cmuEC1w4x{<3Sw2tyIbtSb>vK%DeKqyd>X| zr{rPzf_zT4$;GlzCW%MlkK%1{T6|xuqj*IkM7L1l&sA$9$T0co#xR0+tE&%wU|Q#!KxT zjGI)=qq*69+SuuBjlikiK6BIgm}@3sLA3F%SLYn zIC{1ouT^d2l9ymU&(wD#=vu|INZ$+1-Z)M$cxWv#ygTjR)HIZ9R!ix%Q_bv<#B5C< zDOOGBkU3#wybv8F@)RX%`y^tGaQ2IjM8Ave}#$lnloDowT!}Hb`0=J_b z<~Z;34w$$L{Y{ok8{XQMBor?ZLX^s8vR-5X;TyVaM4u1XZ^^_9^^ zR&nQM8^&>?l%5~a&41vy;dy1x3Ov`#((UwYre_0b+FA4L3Ou&lIM?tB(bcQ)xKTvf zm*}}b&ztmo8F1V-ktEnn^s7SR9WvfF&3FH85{*tDe??kF?cb4L8bBuD`n`tb83{=+P3{^Osj@f3Q+HuQ9e?^WA7poh? zHk@GktN72xlO*qMGG>_;HTSaw^}V~HYTw;_b?NS`xH*7t;Q_Q`Eu9WS@`SX@DDjwP zx=+kGYsLvR>E1hP_+G5?zrR$ixu36od_PlNx<6HYb-!9wjKr&sk#x0xBvrjNQvP2x CW!?M$ delta 8221 zcmZ`;33OG*dH!eSY5@d@$J66IAqfezfSB_%x}vaNH9+Zk#%GeF|>-eRsIVc2b1? zJM+)X|Nryv_v-FXlkUEpeBacJYa((0zy7}&80ZUg%Oclg_Io-BGspazi!;r2^NIPb z`SlgIKq)8DmhnhowMxm$%TuRo`Xwq&(kZQg-T3K{zFVV2U8qp?jh+iNt6UJu4ggF} z2S^zYkd#Cw#{3pg#$M?eHW%(|$(>P;S=u6iaoOX|X-PIkV%{`=XC61_&2Ce4#hq-D z%9Bm2PLzd9Q<92iCYfC-v7)GOhQT3ciet+4peIk0wBMAiPvo)b#;j9`$MSQ+CPSOq zx)YLj$w3*w^C0%igNZlCO;4jtlgyt1O4(>y`b86;d%hBrl5+>SaxMZGJi7rfbmlI= zDQC(6Bd4Q)Q%_F@%sN#Am@_;Gm^(ZRaQewc!2FXF0Six50T#IsNdj&GV0r_!;Ye5{ ztS9TsW+kTHzmrFy=FzdCPZX5?uyNC!#2djXm7FNc%uLMBs2sC6DJ5@NjdBMP_s-8u z+!anuJW`pZQWI~^FZE`>sa$cjILR3!kY!M{=$~D1+l_lDIdOLWHZ=y@?l&iT#wI?C zlq+YnEOWW4JW)74C2#g@b#maAWxuMaug)hzo~(&q!6tqbKAdyZT^>sAOs2l=Y0#(RAmU8L6AAlE#fS zk(;}+E^Tx!tw?Pgi;X4HDCU>uW%IDP#~d?z%?7i;Ox8E_TlxiQ)KBS$w5z-HF1J9a(dS3mtx}?sjqpDG@P$ep?Qsj5?Z}OUaPrfN5G7Q3r2X_}u4ww?~q<{AU z4no4kqdhxI^ymw_SE-#d==|GxajPRmb%G`g{6y{Y&GR0<+v~HhWCW+y^JWYF;$2n_pdUs}nstoy4_$lj7^4 zkr;UQ$&#R%t=3~mQDSiKsI*C#T3HX>HAx`NWP8I_gk-iqX@j57qJp`p%R7^sZVJ3< z9|$l4lI`XJX#wRbyUGb7BLj?6ZeiM`A7@r3X6?&%ip@5a_|@9{_~wu)R~vEk2!!g# zZ!@U&i6PaE7TQhqbNe}H)W7Za#(nV{!&09394C@#3V-*Fyy z9>8ylld1)E+|*EFDdo`-&-D;xcV6a2fRTdjW2123XtxuxJ&)!U}*nxd5}$ zFP(Kf3NuX#=5k;(E$e@Dy!HHaOj^z>z~*y%0h`Xv1B{+yP1t|732@)p)qs1?l33%} zsepUVa{nD?n4EW?Sq8Z4ObBr283%C3>0^M~PwxWUcKSBJhSMxy^{1Hjx1QPuxaAa2 z)x}Ru!DI6&0I3}&vrWTfwsCj{;D%w6TYr)V)}34qxb`IRYfdHuu0GKYSaV_<;HneV zfGbZF16H5lsVa9r;0kvM;O#Djo81ktd_BOjBG!#s`G$<94nGR*-rZmBMf-J<*S5`DM+n*O@}OZ_+cZ`F%PYVYV${qOp^ zNi`8usI&D1Q>i{v@0)6~S-piC-fDWxU8v@NYA%_l%yZ`N%|Ds9%=_j)uei;sgl=6S zHJ%^$N&~0mpHJ(V>#E_@ow7A?ertZ>*{#zLRR~i^Gk(_D-Trhf`2yg%v2 zWRBg)gvji;+^%gvy6cm1c2Wl}{j$_f>cJo;V-jxtlsH2$CJVSwag+80e?r=2_69!f z+wGdAon|MN_A)!Mw8t`jE2IJPFw^%*rCqh$ZX?ZkLYi?3yn>5WxN$#rmf8t(SfAur z4Kd)?aJUlKPMOEyDqNyVrgHZxFk$*h;-tpYU8iJlQw@?{o0MC8AE-oSqCa7}nzY5v zj)HEBXge7Kxem$X`87DuDRb?x75o&3Yk_T&8UFB~6xbol>f)=NPr`fK8cl5hj-uK7 zzPW7fH$$e$Y%~=nY_xt?|AT%Sb$l3ge7jzu^L3hfU;R)$qaIPi>X6!w8eXb`@+oTY z%W_q|j{4nsp(-;TDsZGEV>Rx<%xJUu0XZhYd`AjAJY{5xJb*o+8FqI&a9!RB;@c&C zx+B@x-7bgldjK$;=g4eeqPRJ00d3Zbm2L^=a)tieFWqsE4Ao9&%ADp%xwq8g9U~r_ zFz%L64q4X#a}Y|Puylkj31mBxm$AyT7RBtsYA}n!TXWi-Ef6Fyl{;4ojlrGGpb-ye zQks>Xj8QPN8elwxBX)%@OU*Qc1T_Is!W4y3Lp|7=4Ph3VV)3M7t2p;ZB{Rfpt;8q> zbJ8s=mkx==B{##7Wf|2_IfItWSkrt{utJA|BwG!9F9=w6G3?KrOtQpxLMMI&>jH~| z5)4oS)i^=Dva4Zx7Mf%!Q73FNViKp@wWB`U?d`aQCDg?GOtjnCP4Gsvcnj1Qnqcu% zKN-^;O&ABqTPjhIKa4Z2_!*E;n%zxo8=`=PoSjC_I7b%6Gpam$SQOpIvWWs497}Rl zxGDPr23i#3@EDq<3dC6XeSMI4IMuFLEm2s~YQvdeilsyvye^FbZ6rGqF9E68=eOoU zOu|W)P^TxSPl$KQbg1$wFBaNy7mCF0CkjluVGMB17dBJd-A&j@y$;wSWv0LUSl!5;J8AG z`i|3}ZkU~{K*c&Jx)u$6i|*D#`joz?AJyO1&+1q7KkGUAZT*4%)EJX)vQ4p>hxU4% z*>0NA{NL_Xp3~-ndB}XrJgtLhwqG+pH}9E`uei^tIFpiXy1Ztq4)W4|QK@5gW`Em{ z9L$K{%!JH!)|xJ<<;iuPrlxSnmL2W79k$@qN;~Ay|G!_4BN_W;Yey5qZZN}Mu7u#L*r92L8*FD`1(Q!+<9kLI1 zD1qNzPvgXItSkHpyW&N5Vms$xs>$#==E%sqx|I-nR{%DyqZMnp$CR$ zh(`EAN6c*vSZk6R4sAEQiYNR&xX_=l$mO$tD&WiGJ1960o71D|mw#uTbapCqJWt^F zF())eU+3}<(5O6QTywxwnM{5Ciu;a^XSv9r<&kYLNe|S?RL;cPjhsMCzKb+k6{*5P zGXjIjq#rS`1|Gn~(E<5;u`=C7R$UgUgE^vJ9%A;SpY>s}4Rq)|VHYX3B(gz@ut;>P z6ve$9)QmM`*pi6#XGp_q%=$qU}W$i zMCD6chh(|Ps^t-SG!sH6=o5|7#$?tkR*AdBTr)p3&p=DVrqeW-6{ggy+#l&T^z-^J z@V*^QkCG~CfAgXu0T8j7Obonp&zWh0&jSV;d<=}gVR7Tc9JZ4~K z;$yfNP0z|Sw-YKx2CvCrb79{)X@y+$WK=QR9y)422qB?YMnX%>4C6U2^7$^H*>RNML_3%w&*x?A z#5U%Es2s&8;3CcEW$XZo<@EsGn!ABSiYJmam*#8+fsl*rUXroh+Zlyt@wNO24VmR4 zw^w4tdLEs}FFbso54cG5c^TVq8`kR%@51RWGJH0Wy^wtXKfRLa;wx4;P#u`iBz|cj zqd?r!pdq<=0M7}31ozB9Lp_Mi{eYpnC}D%Q0o?u+JW0Mt(@iIuIaVXk0 zIaFh2Cv8~oITJr{_%>um#Zb?e{o1^1UNKLb2h81Gs4p~Gc=7xX{ZlW{hjk}f^o2TC zr>b|=E9$a(K%G!+YPFi9QspE0DZ>1(R9cBj#$MX#4P_uuUyL>!?x{1wEy_aJ8 zCEkZ9UxPyoR;KrZkTV>$B3V)lC`Jf_KDgiBi!1bHrUEp?`+O|hD|;#ijfVD81b%C} z)pRrX!i}Ww)!MkX-AYGt`FnV`t&pE0F?eQ+Ey^U@?AZ{8P7&)c zqM9jUDRfAt{=5gHz&6^NO=r6o?PMKlAjQqN28*&6>~S1#mdtwkeXS=SgYF=fd0!Ts z;8qI9FO9qj1!RB)wvc=+FgBmjXEN(ZWfRWOIQBB662ouiW`C^{29CnPEr&QQ7OJIO ztkg`MbTnI<1DnW%cuG$kGS)_auPw$@Vhm?8H&_M~ku}CXS@}C9u->O**Z7e#ypBGw zsr=?fCZIkXi$U_NwX_!5(%$@_=;whL0`i$ob81X z?eL1B)x0oQZ9?Z2I{9i{T;s?lEKp;!>uzqD`*$YUC;)$udv(s>PNrlkzPDQx8K4uLA9fTc0j{9 z%kgRmG8BYn>h;nZ&)IQsnPtOQDked`R(42uDaG9Y44oXW)?~s$(kG!MmXUSXs7I&+ z#KVhugsmI1sb3Wiv0g0lS8QFdp~#Ldw2-vcL8I2yd5&fY+(r$q^LSE#IQ^w`fg{_1 z?83cS(YTRSk!?&31mo*4-Ma)&krfq&y?~z6+41-*_e*kqa9`v-oEeEgSuQc;(PD2Xzp9p47nlC z%JB``fjlcYA+yox`f-QoTD?`{3CK7c>AO;)d~Ayug+ z;16_^BXlm7L!beA5wC zgukFvxMN4|I;hGG{>U)$ts|<6YwsUX Date: Thu, 4 Aug 2016 21:37:04 +0100 Subject: [PATCH 69/69] part 2 - db changes --- openlp/plugins/bibles/lib/db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 87f511d83..ff305dec6 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -982,7 +982,7 @@ class OldBibleDB(QtCore.QObject, Manager): def get_verses(self, book_id): """ - Returns the verses of the Bible. + Returns the verses of the Bible. """ verses = self.run_sql( 'SELECT book_id, chapter, verse, text FROM verse WHERE book_id = ? ORDER BY id', (book_id, ))