From 3f21b3e2cac973af27bfad1f7e21fd76a08f2519 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sun, 15 May 2011 19:33:00 +0100 Subject: [PATCH] Remote custom search. Revert a few remote web changes --- openlp/core/lib/mediamanageritem.py | 7 +----- openlp/plugins/bibles/lib/mediaitem.py | 7 +----- openlp/plugins/custom/lib/mediaitem.py | 16 ++++++++++++- openlp/plugins/remotes/html/index.html | 30 +++++++++--------------- openlp/plugins/remotes/html/openlp.js | 4 ---- openlp/plugins/remotes/lib/httpserver.py | 4 ++-- openlp/plugins/songs/lib/mediaitem.py | 7 +----- 7 files changed, 31 insertions(+), 44 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index da01be6d1..234959042 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -102,6 +102,7 @@ class MediaManagerItem(QtGui.QWidget): self.remoteTriggered = None self.singleServiceItem = True self.quickPreviewAllowed = False + self.hasSearch = False self.pageLayout = QtGui.QVBoxLayout(self) self.pageLayout.setSpacing(0) self.pageLayout.setMargin(0) @@ -586,12 +587,6 @@ class MediaManagerItem(QtGui.QWidget): item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] return item_id - def hasSearch(self): - """ - Returns whether this plugin supports the search method - """ - return False - def search(self, string): """ Performs a plugin specific search for items containing ``string`` diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index a169dc401..01d69d10a 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -61,6 +61,7 @@ class BibleMediaItem(MediaManagerItem): # Place to store the search results for both bibles. self.settings = self.parent.settings_tab self.quickPreviewAllowed = True + self.hasSearch = True self.search_results = {} self.second_search_results = {} check_search_result(self.listView, self.search_results) @@ -878,12 +879,6 @@ class BibleMediaItem(MediaManagerItem): self.settingsSection + u'/verse layout style', QtCore.QVariant(self.settings.layout_style)) - def hasSearch(self): - """ - Returns whether this plugin supports the search method - """ - return True - def search(self, string): """ Search for some Bible verses (by reference). diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 4bd3a8d4b..e05b56314 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -27,6 +27,7 @@ import logging from PyQt4 import QtCore, QtGui +from sqlalchemy.sql import or_, func from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ check_item_selected @@ -47,6 +48,7 @@ class CustomMediaItem(MediaManagerItem): MediaManagerItem.__init__(self, parent, self, icon) self.singleServiceItem = False self.quickPreviewAllowed = True + self.hasSearch = True # Holds information about whether the edit is remotly triggered and # which Custom is required. self.remoteCustom = -1 @@ -161,4 +163,16 @@ class CustomMediaItem(MediaManagerItem): else: raw_footer.append(u'') service_item.raw_footer = raw_footer - return True \ No newline at end of file + return True + + def search(self, string): + search_results = self.manager.get_all_objects(CustomSlide, + or_(func.lower(CustomSlide.title).like(u'%' + + string.lower() + u'%'), + func.lower(CustomSlide.text).like(u'%' + + string.lower() + u'%')), + order_by_ref=CustomSlide.title) + results = [] + for custom in search_results: + results.append([custom.id, custom.title]) + return results diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index b07aaec8c..fd7fb3715 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -52,20 +52,16 @@ Back

Service Manager

Refresh - +
-
- Previous Slide - Next Slide + Blank + Show + Prev + Next
@@ -75,18 +71,14 @@ Refresh
- -
+
- Previous Song - Next Song + Blank + Show + Prev + Next
@@ -113,7 +105,7 @@
- +
Search diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 69a213fa2..04945425b 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -247,8 +247,6 @@ $("#service-next").live("click", OpenLP.nextItem); $("#service-previous").live("click", OpenLP.previousItem); $("#service-blank").live("click", OpenLP.blankDisplay); $("#service-unblank").live("click", OpenLP.unblankDisplay); -$("#service-nextslide").live("click", OpenLP.nextSlide); -$("#service-previousslide").live("click", OpenLP.previousSlide); // Slide Controller $("#slide-controller").live("pagebeforeshow", OpenLP.loadController); $("#controller-refresh").live("click", OpenLP.loadController); @@ -256,8 +254,6 @@ $("#controller-next").live("click", OpenLP.nextSlide); $("#controller-previous").live("click", OpenLP.previousSlide); $("#controller-blank").live("click", OpenLP.blankDisplay); $("#controller-unblank").live("click", OpenLP.unblankDisplay); -$("#controller-nextsong").live("click", OpenLP.nextItem); -$("#controller-previoussong").live("click", OpenLP.previousItem); // Alerts $("#alert-submit").live("click", OpenLP.showAlert); // Search diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 259ecfe49..e1e2857bf 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -457,7 +457,7 @@ class HttpConnection(object): searches = [] for plugin in self.parent.parent.pluginManager.plugins: media_item = plugin.mediaItem - if media_item and media_item.hasSearch(): + if media_item and media_item.hasSearch: searches.append(plugin.name) return HttpResponse( json.dumps({u'results': {u'items': searches}}), @@ -473,7 +473,7 @@ class HttpConnection(object): text = json.loads(self.url_params[u'data'][0])[u'request'][u'text'] plugin = self.parent.parent.pluginManager.get_plugin_by_name(type) media_item = plugin.mediaItem - if media_item and media_item.hasSearch(): + if media_item and media_item.hasSearch: results = media_item.search(text) return HttpResponse( json.dumps({u'results': {u'items': results}}), diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index ccd68705a..66d2b5630 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -74,6 +74,7 @@ class SongMediaItem(MediaManagerItem): self.editItem = None self.whitespace = re.compile(r'\W+', re.UNICODE) self.quickPreviewAllowed = True + self.hasSearch = True def addEndHeaderBar(self): self.addToolbarSeparator() @@ -480,12 +481,6 @@ class SongMediaItem(MediaManagerItem): return locale.strcoll(unicode(song_1.title.lower()), unicode(song_2.title.lower())) - def hasSearch(self): - """ - Returns whether this plugin supports the search method - """ - return True - def search(self, string): """ Search for some songs