- 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.
This commit is contained in:
suutari-olli 2016-06-11 13:10:15 +03:00
parent 8f7f9f9804
commit 4ec7e5e879
3 changed files with 30 additions and 6 deletions

View File

@ -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', '<strong>The search you have entered is empty or shorter '
'than 3 characters long.<br>Please try again with '
'a longer search.</strong><br><br>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.</strong><br><br>Please try again with '
'a longer search.')
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.')

View File

@ -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.

View File

@ -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,