diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index ef2520dac..7a1d1a679 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -223,6 +223,28 @@ def resize_image(image, width, height, background=QtCore.Qt.black): painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) return new_image +def check_search_result(treeWidget, search_results): + """ + Checks if the given ``search_results`` is empty and adds a + "No Search Results" item to the given ``treeWidget``. + + ``treeWidget`` + The ``QTreeWidget`` where the "No Search Results" item should be added + to, if the ``search_results`` is empty. + + ``search_results`` + This can either be a list or a dict. + """ + if search_results or treeWidget.count(): + return + message = translate('OpenLP.MediaManagerItem', 'No Search Results') + item = QtGui.QListWidgetItem(message) + item.setFlags(QtCore.Qt.NoItemFlags) + font = QtGui.QFont() + font.setItalic(True) + item.setFont(font) + treeWidget.addItem(item) + def check_item_selected(list_widget, message): """ Check if a list item is selected so an action may be performed on it diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 7d21b57c4..461828d9e 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -29,7 +29,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ - translate + translate, check_search_result from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings, add_widget_completer, \ media_item_combo_box, critical_error_message_box, find_and_set_in_combo_box @@ -61,6 +61,7 @@ class BibleMediaItem(MediaManagerItem): self.quickPreviewAllowed = True self.search_results = {} self.second_search_results = {} + check_search_result(self.listView, self.search_results) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles) @@ -522,8 +523,9 @@ class BibleMediaItem(MediaManagerItem): self.__checkSecondBible(bible, second_bible) elif self.search_results: self.displayResults(bible, second_bible) - Receiver.send_message(u'cursor_normal') self.advancedSearchButton.setEnabled(True) + check_search_result(self.listView, self.search_results) + Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') def onQuickSearchButton(self): @@ -563,6 +565,7 @@ class BibleMediaItem(MediaManagerItem): elif self.search_results: self.displayResults(bible, second_bible) self.quickSearchButton.setEnabled(True) + check_search_result(self.listView, self.search_results) Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 745ee3f67..dbd0eb9af 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -329,7 +329,7 @@ class SongExportForm(OpenLPWizard): self.availableListWidget, unicode(text)) ] for item in self._findListWidgetItems(self.availableListWidget): - item.setHidden(False if item in search_result else True) + item.setHidden(item not in search_result) def onUncheckButtonClicked(self): """ @@ -360,4 +360,5 @@ class SongExportForm(OpenLPWizard): SettingsManager.get_last_dir(self.plugin.settingsSection, 1), options=QtGui.QFileDialog.ShowDirsOnly)) SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1) - self.directoryLineEdit.setText(path) \ No newline at end of file + self.directoryLineEdit.setText(path) + diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index a3015d422..3b014d4b0 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ - translate, check_item_selected, PluginStatus + translate, check_item_selected, PluginStatus, check_search_result from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \ @@ -199,6 +199,7 @@ class SongMediaItem(MediaManagerItem): search_results = self.parent.manager.get_all_objects(Song, Song.theme_name == search_keywords) self.displayResultsSong(search_results) + check_search_result(self.listView, search_results) def onSongListLoad(self): """