forked from openlp/openlp
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
This commit is contained in:
parent
0ac56e5a19
commit
3c70500c23
@ -282,14 +282,17 @@ class BibleManager(RegistryProperties):
|
|||||||
translate('BiblesPlugin.BibleManager', 'Your scripture reference is either not supported by '
|
translate('BiblesPlugin.BibleManager', 'Your scripture reference is either not supported by '
|
||||||
'OpenLP or is invalid. Please make sure your reference '
|
'OpenLP or is invalid. Please make sure your reference '
|
||||||
'conforms to one of the following patterns or consult the manual:\n\n'
|
'conforms to one of the following patterns or consult the manual:\n\n'
|
||||||
'Book Chapter\n'
|
'Book Chapter | John 3:16\n'
|
||||||
'Book Chapter%(range)sChapter\n'
|
'Book Chapter%(range)sChapter | John 3%(range)s4\n'
|
||||||
'Book Chapter%(verse)sVerse%(range)sVerse\n'
|
'Book Chapter%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17\n'
|
||||||
'Book Chapter%(verse)sVerse%(range)sVerse%(list)sVerse'
|
'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'
|
'Book Chapter%(verse)sVerse%(range)sVerse%(list)sChapter'
|
||||||
'%(verse)sVerse%(range)sVerse\n'
|
'%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17%'
|
||||||
'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse',
|
'(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 '
|
'Please pay attention to the appended "s" of the wildcards '
|
||||||
'and refrain from translating the words inside the names in the brackets.')
|
'and refrain from translating the words inside the names in the brackets.')
|
||||||
% reference_separators
|
% reference_separators
|
||||||
@ -344,23 +347,18 @@ class BibleManager(RegistryProperties):
|
|||||||
translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.')
|
translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.')
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
if len(text) < 3 or str.isspace(text):
|
||||||
if not len(text) == 0 and len(text) < 3:
|
|
||||||
self.main_window.information_message(
|
self.main_window.information_message(
|
||||||
translate('BiblesPlugin.BibleManager', 'Keyword is too short'),
|
translate('BiblesPlugin.BibleManager', 'Keyword is too short'),
|
||||||
translate('BiblesPlugin.BibleManager', 'The keyword you have entered is shorter '
|
translate('BiblesPlugin.BibleManager', 'The keyword you have entered is empty or shorter '
|
||||||
'than 3 characters long.\nPlease try again with '
|
'than 3 characters long. Please try again with '
|
||||||
'a longer keyword.')
|
'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:
|
elif text:
|
||||||
return self.db_cache[bible].verse_search(text)
|
return self.db_cache[bible].verse_search(text)
|
||||||
else:
|
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
|
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=False):
|
||||||
|
@ -436,7 +436,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
Settings().setValue(self.settings_section + '/quick bible', self.quickVersionComboBox.currentText())
|
Settings().setValue(self.settings_section + '/quick bible', self.quickVersionComboBox.currentText())
|
||||||
books = []
|
books = []
|
||||||
# We have to do a 'Reference Search' (Or as part of Combined Search).
|
# 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()
|
bibles = self.plugin.manager.get_bibles()
|
||||||
bible = self.quickVersionComboBox.currentText()
|
bible = self.quickVersionComboBox.currentText()
|
||||||
if bible:
|
if bible:
|
||||||
@ -689,24 +689,42 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
continue
|
continue
|
||||||
new_search_results.append(verse)
|
new_search_results.append(verse)
|
||||||
text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse))
|
text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse))
|
||||||
if passage_not_found():
|
if passage_not_found:
|
||||||
# This function appears to be broken / Does nothing?
|
self.main_window.information_message(
|
||||||
QtGui.QMessageBox.information(
|
translate('BiblesPlugin.MediaItem', 'Information'),
|
||||||
self, translate('BiblesPlugin.MediaItem', 'Information'),
|
|
||||||
translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses '
|
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 '
|
'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,
|
'verses have not been included in the results.') % count)
|
||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
|
||||||
self.search_results = new_search_results
|
self.search_results = new_search_results
|
||||||
self.second_search_results = bibles[second_bible].get_verses(text)
|
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:
|
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)
|
self.search_results = self.plugin.manager.get_verses_combined(bible, text)
|
||||||
if second_bible and self.search_results:
|
if second_bible and self.search_results:
|
||||||
self.second_search_results = \
|
self.second_search_results = \
|
||||||
self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id)
|
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 keyword is shorter than 3, message is given and search is finalized.
|
||||||
if not self.search_results:
|
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()
|
self.application.set_busy_cursor()
|
||||||
bibles = self.plugin.manager.get_bibles()
|
bibles = self.plugin.manager.get_bibles()
|
||||||
self.search_results = self.plugin.manager.verse_search(bible, second_bible, text)
|
self.search_results = self.plugin.manager.verse_search(bible, second_bible, text)
|
||||||
@ -725,23 +743,42 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
continue
|
continue
|
||||||
new_search_results.append(verse)
|
new_search_results.append(verse)
|
||||||
text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse))
|
text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse))
|
||||||
if passage_not_found():
|
if passage_not_found:
|
||||||
# This function appears to be broken / Does nothing?
|
self.main_window.information_message(
|
||||||
QtGui.QMessageBox.information(
|
translate('BiblesPlugin.MediaItem', 'Information'),
|
||||||
self, translate('BiblesPlugin.MediaItem', 'Information'),
|
|
||||||
translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses '
|
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 '
|
'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,
|
'verses have not been included in the results.') % count)
|
||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
|
||||||
self.search_results = new_search_results
|
self.search_results = new_search_results
|
||||||
self.second_search_results = bibles[second_bible].get_verses(text)
|
self.second_search_results = bibles[second_bible].get_verses(text)
|
||||||
# If no Text or Reference is found, message is given.
|
# If no Text or Reference is found, message is given.
|
||||||
if not self.search_results:
|
if not self.search_results:
|
||||||
self.main_window.information_message(
|
reference_separators = {
|
||||||
translate('BiblesPlugin.BibleManager', 'Scripture Reference Errorhhh'),
|
'verse': get_reference_separator('sep_v_display'),
|
||||||
translate('BiblesPlugin.BibleManager', 'You did not enter a search '
|
'range': get_reference_separator('sep_r_display'),
|
||||||
'different keywords by a space to search for all of your '
|
'list': get_reference_separator('sep_l_display')}
|
||||||
'them by a comma to search for one of them.'))
|
self.main_window.information_message(
|
||||||
|
translate('BiblesPlugin.BibleManager', 'Nothing found'),
|
||||||
|
translate('BiblesPlugin.BibleManager', '<strong>OpenLP couldn’t find '
|
||||||
|
'anything with your search.</strong><br><br>'
|
||||||
|
'If you tried to search with Scripture Reference, please make sure that your '
|
||||||
|
'reference follows one of the following patterns:<br><br>'
|
||||||
|
'Book Chapter | John 3:16<br>'
|
||||||
|
'Book Chapter%(range)sChapter | John 3%(range)s4<br>'
|
||||||
|
'Book Chapter%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17<br>'
|
||||||
|
'Book Chapter%(verse)sVerse%(range)sVerse%(list)sVerse'
|
||||||
|
'%(range)sVerse | John 3%(verse)s16-17%(list)s20%(range)s22<br>'
|
||||||
|
'Book Chapter%(verse)sVerse%(range)sVerse%(list)sChapter'
|
||||||
|
'%(verse)sVerse%(range)sVerse | John 3%(verse)s16%(range)s17%'
|
||||||
|
'(list)s5%(verse)s7%(range)s9<br>'
|
||||||
|
'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse'
|
||||||
|
' | John 3%(verse)s16%(range)s4%(verse)s2<br><br>'
|
||||||
|
'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
|
# Finalizing the search
|
||||||
if not self.quickLockButton.isChecked():
|
if not self.quickLockButton.isChecked():
|
||||||
self.list_view.clear()
|
self.list_view.clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user