From d61ded487e1ec8c0e87fafed86bcd3250560b612 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Wed, 9 Mar 2016 02:25:07 +0200 Subject: [PATCH] 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)