← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/NoSearchResults into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/NoSearchResults into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/NoSearchResults/+merge/61016

Hello,

- Move the No Search Results code. (I do not expect the code to be used by another QListWidget.)
- Remove setUniformItemSizes
-- 
https://code.launchpad.net/~googol-hush/openlp/NoSearchResults/+merge/61016
Your team OpenLP Core is requested to review the proposed merge of lp:~googol-hush/openlp/NoSearchResults into lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2011-05-11 08:13:10 +0000
+++ openlp/core/lib/__init__.py	2011-05-15 12:38:23 +0000
@@ -223,28 +223,6 @@
     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

=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py	2011-05-13 14:39:37 +0000
+++ openlp/core/lib/mediamanageritem.py	2011-05-15 12:38:23 +0000
@@ -244,7 +244,6 @@
         """
         # Add the List widget
         self.listView = ListWidgetWithDnD(self, self.plugin.name)
-        self.listView.setUniformItemSizes(True)
         self.listView.setSpacing(1)
         self.listView.setSelectionMode(
             QtGui.QAbstractItemView.ExtendedSelection)
@@ -552,6 +551,20 @@
         """
         pass
 
+    def check_search_result(self):
+        """
+        Checks if the listView is empty and adds a "No Search Results" item.
+        """
+        if self.listView.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)
+        self.listView.addItem(item)
+
     def _getIdOfItemToGenerate(self, item, remoteItem):
         """
         Utility method to check items being submitted for slide generation.

=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py	2011-05-14 20:12:01 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py	2011-05-15 12:38:23 +0000
@@ -29,7 +29,7 @@
 from PyQt4 import QtCore, QtGui
 
 from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
-    translate, check_search_result
+    translate
 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
@@ -63,7 +63,7 @@
         self.quickPreviewAllowed = True
         self.search_results = {}
         self.second_search_results = {}
-        check_search_result(self.listView, self.search_results)
+        self.check_search_result()
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles)
 
@@ -600,7 +600,7 @@
         elif self.search_results:
             self.displayResults(bible, second_bible)
         self.advancedSearchButton.setEnabled(True)
-        check_search_result(self.listView, self.search_results)
+        self.check_search_result()
         Receiver.send_message(u'cursor_normal')
         Receiver.send_message(u'openlp_process_events')
 
@@ -641,7 +641,7 @@
         elif self.search_results:
             self.displayResults(bible, second_bible)
         self.quickSearchButton.setEnabled(True)
-        check_search_result(self.listView, self.search_results)
+        self.check_search_result()
         Receiver.send_message(u'cursor_normal')
         Receiver.send_message(u'openlp_process_events')
 

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2011-05-08 11:35:10 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2011-05-15 12:38:23 +0000
@@ -32,7 +32,7 @@
 from sqlalchemy.sql import or_
 
 from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
-    translate, check_item_selected, PluginStatus, check_search_result
+    translate, check_item_selected, PluginStatus
 from openlp.core.lib.searchedit import SearchEdit
 from openlp.core.lib.ui import UiStrings
 from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \
@@ -199,7 +199,7 @@
             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)
+        self.check_search_result()
 
     def onSongListLoad(self):
         """


Follow ups