forked from openlp/openlp
Improved a bunch of comments.
This commit is contained in:
parent
8e20bfa19c
commit
f5e7e932d1
@ -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', '<strong>The search you have entered is empty or shorter '
|
||||
'than 3 characters long.<br>Please try again with '
|
||||
@ -163,7 +162,6 @@ class UiStrings(object):
|
||||
self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available')
|
||||
self.BibleNoBibles = translate('OpenLP.Ui', '<strong>There are no Bibles currently installed.</strong><br><br>'
|
||||
'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')
|
||||
|
@ -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.
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user