2009-03-13 06:13:11 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
2009-09-08 19:58:05 +00:00
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2011-12-27 10:33:55 +00:00
|
|
|
# Copyright (c) 2008-2012 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan #
|
2012-06-22 14:14:53 +00:00
|
|
|
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
2012-11-11 21:16:14 +00:00
|
|
|
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
2012-10-24 17:20:37 +00:00
|
|
|
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
2012-10-21 13:16:22 +00:00
|
|
|
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
|
|
|
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
2012-12-01 07:57:54 +00:00
|
|
|
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
2009-09-08 19:58:05 +00:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the Free #
|
|
|
|
# Software Foundation; version 2 of the License. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
|
|
# more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License along #
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
|
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
|
|
###############################################################################
|
2009-03-13 06:13:11 +00:00
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from PyQt4 import QtCore, QtGui
|
2011-05-15 18:33:00 +00:00
|
|
|
from sqlalchemy.sql import or_, func
|
2009-03-13 06:13:11 +00:00
|
|
|
|
2012-12-22 22:40:58 +00:00
|
|
|
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, check_item_selected, translate, \
|
|
|
|
ServiceItemContext, PluginStatus
|
2011-02-13 14:21:12 +00:00
|
|
|
from openlp.core.lib.ui import UiStrings
|
2012-05-11 12:22:34 +00:00
|
|
|
from openlp.core.lib.settings import Settings
|
2011-05-27 09:34:14 +00:00
|
|
|
from openlp.plugins.custom.forms import EditCustomForm
|
2012-12-22 22:40:58 +00:00
|
|
|
from openlp.plugins.custom.lib import CustomXMLParser, CustomXMLBuilder
|
2010-06-15 02:08:22 +00:00
|
|
|
from openlp.plugins.custom.lib.db import CustomSlide
|
2009-03-13 06:13:11 +00:00
|
|
|
|
2010-02-27 15:31:23 +00:00
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2011-05-15 19:07:40 +00:00
|
|
|
class CustomSearch(object):
|
|
|
|
"""
|
2011-05-18 14:34:35 +00:00
|
|
|
An enumeration for custom search methods.
|
2011-05-15 19:07:40 +00:00
|
|
|
"""
|
|
|
|
Titles = 1
|
|
|
|
Themes = 2
|
|
|
|
|
|
|
|
|
2009-03-13 06:13:11 +00:00
|
|
|
class CustomMediaItem(MediaManagerItem):
|
|
|
|
"""
|
|
|
|
This is the custom media manager item for Custom Slides.
|
|
|
|
"""
|
2009-03-15 19:31:33 +00:00
|
|
|
log.info(u'Custom Media Item loaded')
|
2009-03-13 06:13:11 +00:00
|
|
|
|
2010-09-15 17:55:27 +00:00
|
|
|
def __init__(self, parent, plugin, icon):
|
2009-09-11 04:54:22 +00:00
|
|
|
self.IconPath = u'custom/custom'
|
2011-05-28 09:53:37 +00:00
|
|
|
MediaManagerItem.__init__(self, parent, plugin, icon)
|
2012-04-21 22:29:08 +00:00
|
|
|
self.edit_custom_form = EditCustomForm(self, self.plugin.formParent,
|
2011-05-28 19:38:19 +00:00
|
|
|
self.plugin.manager)
|
2010-04-06 19:16:14 +00:00
|
|
|
self.singleServiceItem = False
|
2011-04-02 09:52:32 +00:00
|
|
|
self.quickPreviewAllowed = True
|
2011-05-15 18:33:00 +00:00
|
|
|
self.hasSearch = True
|
2009-11-06 18:50:46 +00:00
|
|
|
# Holds information about whether the edit is remotly triggered and
|
|
|
|
# which Custom is required.
|
|
|
|
self.remoteCustom = -1
|
2011-05-28 09:53:37 +00:00
|
|
|
self.manager = plugin.manager
|
2009-10-29 13:44:33 +00:00
|
|
|
|
|
|
|
def addEndHeaderBar(self):
|
2012-03-03 13:52:57 +00:00
|
|
|
self.toolbar.addSeparator()
|
2011-12-30 21:40:13 +00:00
|
|
|
self.addSearchToToolBar()
|
2011-05-15 19:07:40 +00:00
|
|
|
# Signals and slots
|
|
|
|
QtCore.QObject.connect(self.searchTextEdit,
|
|
|
|
QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
|
|
|
|
QtCore.QObject.connect(self.searchTextEdit,
|
|
|
|
QtCore.SIGNAL(u'searchTypeChanged(int)'),
|
2012-04-02 00:19:16 +00:00
|
|
|
self.onSearchTextButtonClicked)
|
2009-10-29 13:44:33 +00:00
|
|
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
2010-04-16 07:31:01 +00:00
|
|
|
QtCore.SIGNAL(u'custom_edit'), self.onRemoteEdit)
|
2009-10-29 13:44:33 +00:00
|
|
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
2011-02-16 03:28:06 +00:00
|
|
|
QtCore.SIGNAL(u'custom_edit_clear'), self.onRemoteEditClear)
|
2009-10-29 13:44:33 +00:00
|
|
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
2011-06-01 21:06:45 +00:00
|
|
|
QtCore.SIGNAL(u'custom_load_list'), self.loadList)
|
2009-11-06 18:50:46 +00:00
|
|
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
2010-04-16 07:31:01 +00:00
|
|
|
QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
|
2012-12-22 22:40:58 +00:00
|
|
|
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated)
|
2012-12-23 00:00:24 +00:00
|
|
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
|
|
|
QtCore.SIGNAL(u'custom_create_from_service'), self.create_from_service_item)
|
2012-12-22 22:40:58 +00:00
|
|
|
|
|
|
|
def config_updated(self):
|
|
|
|
self.add_custom_from_service = Settings().value(
|
|
|
|
self.settingsSection + u'/add custom from service', QtCore.QVariant(u'True')).toBool()
|
2009-03-13 06:13:11 +00:00
|
|
|
|
2011-05-15 19:07:40 +00:00
|
|
|
def retranslateUi(self):
|
|
|
|
self.searchTextLabel.setText(u'%s:' % UiStrings().Search)
|
|
|
|
self.searchTextButton.setText(UiStrings().Search)
|
|
|
|
|
2009-03-13 06:13:11 +00:00
|
|
|
def initialise(self):
|
2011-05-15 19:07:40 +00:00
|
|
|
self.searchTextEdit.setSearchTypes([
|
|
|
|
(CustomSearch.Titles, u':/songs/song_search_title.png',
|
2012-03-25 21:09:44 +00:00
|
|
|
translate('SongsPlugin.MediaItem', 'Titles'),
|
|
|
|
translate('SongsPlugin.MediaItem', 'Search Titles...')),
|
2011-05-15 19:07:40 +00:00
|
|
|
(CustomSearch.Themes, u':/slides/slide_theme.png',
|
2012-03-26 09:41:59 +00:00
|
|
|
UiStrings().Themes, UiStrings().SearchThemes)
|
2011-05-15 19:07:40 +00:00
|
|
|
])
|
2011-02-04 18:42:37 +00:00
|
|
|
self.loadList(self.manager.get_all_objects(
|
2010-07-18 23:37:24 +00:00
|
|
|
CustomSlide, order_by_ref=CustomSlide.title))
|
2012-05-11 12:22:34 +00:00
|
|
|
self.searchTextEdit.setCurrentSearchType(Settings().value(
|
2011-05-15 19:07:40 +00:00
|
|
|
u'%s/last search type' % self.settingsSection,
|
2011-05-15 19:18:50 +00:00
|
|
|
QtCore.QVariant(CustomSearch.Titles)).toInt()[0])
|
2012-12-22 22:40:58 +00:00
|
|
|
self.config_updated()
|
2009-04-25 06:11:15 +00:00
|
|
|
|
2011-05-20 15:18:57 +00:00
|
|
|
def loadList(self, custom_slides):
|
2011-05-27 09:34:14 +00:00
|
|
|
# Sort out what custom we want to select after loading the list.
|
2011-09-01 19:45:36 +00:00
|
|
|
self.saveAutoSelectId()
|
2010-07-07 16:03:30 +00:00
|
|
|
self.listView.clear()
|
2012-10-12 19:40:15 +00:00
|
|
|
custom_slides.sort()
|
2011-05-20 15:18:57 +00:00
|
|
|
for custom_slide in custom_slides:
|
|
|
|
custom_name = QtGui.QListWidgetItem(custom_slide.title)
|
2009-09-21 17:56:36 +00:00
|
|
|
custom_name.setData(
|
2011-05-20 15:18:57 +00:00
|
|
|
QtCore.Qt.UserRole, QtCore.QVariant(custom_slide.id))
|
2010-07-07 16:03:30 +00:00
|
|
|
self.listView.addItem(custom_name)
|
2011-05-27 09:34:14 +00:00
|
|
|
# Auto-select the custom.
|
2011-09-01 19:45:36 +00:00
|
|
|
if custom_slide.id == self.autoSelectId:
|
2011-05-19 22:20:00 +00:00
|
|
|
self.listView.setCurrentItem(custom_name)
|
2011-09-01 19:45:36 +00:00
|
|
|
self.autoSelectId = -1
|
2011-06-01 21:06:45 +00:00
|
|
|
# Called to redisplay the custom list screen edith from a search
|
|
|
|
# or from the exit of the Custom edit dialog. If remote editing is
|
|
|
|
# active trigger it and clean up so it will not update again.
|
|
|
|
if self.remoteTriggered == u'L':
|
|
|
|
self.onAddClick()
|
|
|
|
if self.remoteTriggered == u'P':
|
|
|
|
self.onPreviewClick()
|
|
|
|
self.onRemoteEditClear()
|
2011-05-19 22:20:00 +00:00
|
|
|
|
2009-09-11 04:54:22 +00:00
|
|
|
def onNewClick(self):
|
2011-05-27 09:34:14 +00:00
|
|
|
self.edit_custom_form.loadCustom(0)
|
|
|
|
self.edit_custom_form.exec_()
|
2011-06-01 21:06:45 +00:00
|
|
|
self.onClearTextButtonClick()
|
2011-05-31 03:52:17 +00:00
|
|
|
self.onSelectionChange()
|
2009-03-13 06:13:11 +00:00
|
|
|
|
2009-10-29 13:44:33 +00:00
|
|
|
def onRemoteEditClear(self):
|
2009-11-06 18:50:46 +00:00
|
|
|
self.remoteTriggered = None
|
|
|
|
self.remoteCustom = -1
|
|
|
|
|
2011-05-27 09:34:14 +00:00
|
|
|
def onRemoteEdit(self, message):
|
2009-11-06 18:50:46 +00:00
|
|
|
"""
|
|
|
|
Called by ServiceManager or SlideController by event passing
|
2011-05-27 09:34:14 +00:00
|
|
|
the custom Id in the payload along with an indicator to say which
|
2009-11-06 18:50:46 +00:00
|
|
|
type of display is required.
|
|
|
|
"""
|
2011-05-27 09:34:14 +00:00
|
|
|
remote_type, custom_id = message.split(u':')
|
|
|
|
custom_id = int(custom_id)
|
|
|
|
valid = self.manager.get_object(CustomSlide, custom_id)
|
2009-11-03 19:01:53 +00:00
|
|
|
if valid:
|
2011-05-27 09:34:14 +00:00
|
|
|
self.remoteCustom = custom_id
|
|
|
|
self.remoteTriggered = remote_type
|
|
|
|
self.edit_custom_form.loadCustom(custom_id, (remote_type == u'P'))
|
|
|
|
self.edit_custom_form.exec_()
|
2011-09-01 19:45:36 +00:00
|
|
|
self.autoSelectId = -1
|
2012-04-02 00:19:16 +00:00
|
|
|
self.onSearchTextButtonClicked()
|
2009-10-29 13:44:33 +00:00
|
|
|
|
2009-09-11 04:54:22 +00:00
|
|
|
def onEditClick(self):
|
2010-06-16 01:23:57 +00:00
|
|
|
"""
|
|
|
|
Edit a custom item
|
|
|
|
"""
|
2011-04-15 21:43:59 +00:00
|
|
|
if check_item_selected(self.listView, UiStrings().SelectEdit):
|
2010-07-07 16:03:30 +00:00
|
|
|
item = self.listView.currentItem()
|
2009-06-19 18:41:38 +00:00
|
|
|
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
2011-05-27 09:34:14 +00:00
|
|
|
self.edit_custom_form.loadCustom(item_id, False)
|
|
|
|
self.edit_custom_form.exec_()
|
2011-09-01 19:45:36 +00:00
|
|
|
self.autoSelectId = -1
|
2012-04-02 00:19:16 +00:00
|
|
|
self.onSearchTextButtonClicked()
|
2009-03-13 06:13:11 +00:00
|
|
|
|
2009-09-11 04:54:22 +00:00
|
|
|
def onDeleteClick(self):
|
2010-06-16 01:23:57 +00:00
|
|
|
"""
|
|
|
|
Remove a custom item from the list and database
|
|
|
|
"""
|
2011-04-15 21:43:59 +00:00
|
|
|
if check_item_selected(self.listView, UiStrings().SelectDelete):
|
2011-06-08 01:37:07 +00:00
|
|
|
items = self.listView.selectedIndexes()
|
2011-06-28 04:52:46 +00:00
|
|
|
if QtGui.QMessageBox.question(self,
|
2011-06-28 20:35:28 +00:00
|
|
|
UiStrings().ConfirmDelete,
|
2011-06-28 04:52:46 +00:00
|
|
|
translate('CustomPlugin.MediaItem',
|
2011-06-28 19:05:05 +00:00
|
|
|
'Are you sure you want to delete the %n selected custom'
|
2012-03-17 21:30:53 +00:00
|
|
|
' slide(s)?', '',
|
2011-06-28 04:52:46 +00:00
|
|
|
QtCore.QCoreApplication.CodecForTr, len(items)),
|
2011-06-28 13:29:36 +00:00
|
|
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
|
|
|
|
QtGui.QMessageBox.No),
|
|
|
|
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
|
2011-06-28 04:52:46 +00:00
|
|
|
return
|
2010-07-07 16:03:30 +00:00
|
|
|
row_list = [item.row() for item in self.listView.selectedIndexes()]
|
2010-06-28 19:05:55 +00:00
|
|
|
row_list.sort(reverse=True)
|
|
|
|
id_list = [(item.data(QtCore.Qt.UserRole)).toInt()[0]
|
2010-07-07 16:03:30 +00:00
|
|
|
for item in self.listView.selectedIndexes()]
|
2010-06-28 19:05:55 +00:00
|
|
|
for id in id_list:
|
2011-05-28 09:53:37 +00:00
|
|
|
self.plugin.manager.delete_object(CustomSlide, id)
|
2012-04-02 00:19:16 +00:00
|
|
|
self.onSearchTextButtonClicked()
|
2009-03-13 06:13:11 +00:00
|
|
|
|
2011-05-26 06:23:22 +00:00
|
|
|
def onFocus(self):
|
|
|
|
self.searchTextEdit.setFocus()
|
|
|
|
|
2011-09-06 17:53:43 +00:00
|
|
|
def generateSlideData(self, service_item, item=None, xmlVersion=False,
|
2012-10-20 08:20:11 +00:00
|
|
|
remote=False, context=ServiceItemContext.Service):
|
2011-02-01 00:33:50 +00:00
|
|
|
item_id = self._getIdOfItemToGenerate(item, self.remoteCustom)
|
2011-08-28 17:45:13 +00:00
|
|
|
service_item.add_capability(ItemCapabilities.CanEdit)
|
|
|
|
service_item.add_capability(ItemCapabilities.CanPreview)
|
|
|
|
service_item.add_capability(ItemCapabilities.CanLoop)
|
2011-08-31 07:49:57 +00:00
|
|
|
service_item.add_capability(ItemCapabilities.CanSoftBreak)
|
2012-12-22 22:40:58 +00:00
|
|
|
service_item.add_capability(ItemCapabilities.OnLoadUpdate)
|
2011-05-28 09:53:37 +00:00
|
|
|
customSlide = self.plugin.manager.get_object(CustomSlide, item_id)
|
2009-06-17 05:11:16 +00:00
|
|
|
title = customSlide.title
|
|
|
|
credit = customSlide.credits
|
2010-11-20 18:14:43 +00:00
|
|
|
service_item.edit_id = item_id
|
2009-06-17 05:11:16 +00:00
|
|
|
theme = customSlide.theme_name
|
2010-03-09 19:43:11 +00:00
|
|
|
if theme:
|
2009-06-17 05:11:16 +00:00
|
|
|
service_item.theme = theme
|
2012-06-16 16:02:22 +00:00
|
|
|
custom_xml = CustomXMLParser(customSlide.text)
|
|
|
|
verse_list = custom_xml.get_verses()
|
2012-06-16 15:51:04 +00:00
|
|
|
raw_slides = [verse[1] for verse in verse_list]
|
2012-06-08 13:27:40 +00:00
|
|
|
service_item.title = title
|
2009-11-06 18:50:46 +00:00
|
|
|
for slide in raw_slides:
|
2012-06-10 13:39:45 +00:00
|
|
|
service_item.add_from_text(slide)
|
2012-05-11 12:22:34 +00:00
|
|
|
if Settings().value(self.settingsSection + u'/display footer',
|
2010-04-28 14:17:42 +00:00
|
|
|
QtCore.QVariant(True)).toBool() or credit:
|
2012-05-20 18:26:24 +00:00
|
|
|
service_item.raw_footer.append(u' '.join([title, credit]))
|
2009-12-13 08:57:58 +00:00
|
|
|
else:
|
2012-05-20 18:26:24 +00:00
|
|
|
service_item.raw_footer.append(u'')
|
2011-05-15 19:07:40 +00:00
|
|
|
return True
|
|
|
|
|
2012-04-02 00:19:16 +00:00
|
|
|
def onSearchTextButtonClicked(self):
|
2011-05-15 19:07:40 +00:00
|
|
|
# Save the current search type to the configuration.
|
2012-05-11 12:22:34 +00:00
|
|
|
Settings().setValue(u'%s/last search type' %
|
2011-05-15 19:07:40 +00:00
|
|
|
self.settingsSection,
|
|
|
|
QtCore.QVariant(self.searchTextEdit.currentSearchType()))
|
|
|
|
# Reload the list considering the new search type.
|
|
|
|
search_keywords = unicode(self.searchTextEdit.displayText())
|
|
|
|
search_results = []
|
|
|
|
search_type = self.searchTextEdit.currentSearchType()
|
|
|
|
if search_type == CustomSearch.Titles:
|
|
|
|
log.debug(u'Titles Search')
|
2011-05-28 09:53:37 +00:00
|
|
|
search_results = self.plugin.manager.get_all_objects(CustomSlide,
|
2011-05-15 19:07:40 +00:00
|
|
|
CustomSlide.title.like(u'%' + self.whitespace.sub(u' ',
|
2011-05-19 04:48:10 +00:00
|
|
|
search_keywords) + u'%'), order_by_ref=CustomSlide.title)
|
2011-05-15 19:07:40 +00:00
|
|
|
self.loadList(search_results)
|
|
|
|
elif search_type == CustomSearch.Themes:
|
|
|
|
log.debug(u'Theme Search')
|
2011-05-28 09:53:37 +00:00
|
|
|
search_results = self.plugin.manager.get_all_objects(CustomSlide,
|
2011-05-15 19:07:40 +00:00
|
|
|
CustomSlide.theme_name.like(u'%' + self.whitespace.sub(u' ',
|
2011-05-19 04:48:10 +00:00
|
|
|
search_keywords) + u'%'), order_by_ref=CustomSlide.title)
|
2011-05-15 19:07:40 +00:00
|
|
|
self.loadList(search_results)
|
2011-09-02 19:04:07 +00:00
|
|
|
self.checkSearchResult()
|
2011-05-15 19:07:40 +00:00
|
|
|
|
|
|
|
def onSearchTextEditChanged(self, text):
|
|
|
|
"""
|
|
|
|
If search as type enabled invoke the search on each key press.
|
2011-05-27 09:34:14 +00:00
|
|
|
If the Title is being searched do not start until 2 characters
|
2011-05-15 19:07:40 +00:00
|
|
|
have been entered.
|
|
|
|
"""
|
|
|
|
search_length = 2
|
|
|
|
if len(text) > search_length:
|
2012-04-02 00:19:16 +00:00
|
|
|
self.onSearchTextButtonClicked()
|
2012-04-29 15:31:56 +00:00
|
|
|
elif not text:
|
2011-05-15 19:07:40 +00:00
|
|
|
self.onClearTextButtonClick()
|
|
|
|
|
2012-12-22 22:40:58 +00:00
|
|
|
def serviceLoad(self, item):
|
|
|
|
"""
|
|
|
|
Triggered by a song being loaded by the service manager.
|
|
|
|
"""
|
|
|
|
log.debug(u'serviceLoad')
|
|
|
|
if not self.add_custom_from_service:
|
|
|
|
return
|
|
|
|
if self.plugin.status != PluginStatus.Active:
|
|
|
|
return
|
|
|
|
custom = self.plugin.manager.get_object_filtered(CustomSlide, CustomSlide.title == item.title)
|
|
|
|
if custom:
|
|
|
|
return
|
2012-12-23 00:00:24 +00:00
|
|
|
self.create_from_service_item(item)
|
|
|
|
|
|
|
|
def create_from_service_item(self, item):
|
|
|
|
"""
|
|
|
|
Create a custom slide from a text service item
|
|
|
|
"""
|
2012-12-22 22:40:58 +00:00
|
|
|
custom = CustomSlide()
|
|
|
|
custom.title = item.title
|
2012-12-23 00:00:24 +00:00
|
|
|
if item.theme:
|
|
|
|
custom.theme_name = item.theme
|
|
|
|
else:
|
|
|
|
custom.theme_name = u''
|
2012-12-22 22:40:58 +00:00
|
|
|
footer = u' '.join(item.raw_footer)
|
|
|
|
if footer:
|
|
|
|
if footer.startswith(item.title):
|
|
|
|
custom.credits = footer[len(item.title) + 1:]
|
|
|
|
else:
|
|
|
|
custom.credits = footer
|
|
|
|
else:
|
|
|
|
custom.credits = u''
|
|
|
|
custom_xml = CustomXMLBuilder()
|
|
|
|
for (idx, slide) in enumerate(item._raw_frames):
|
|
|
|
custom_xml.add_verse_to_lyrics(u'custom', unicode(idx + 1), slide['raw_slide'])
|
|
|
|
custom.text = unicode(custom_xml.extract_xml(), u'utf-8')
|
|
|
|
self.plugin.manager.save_object(custom)
|
|
|
|
self.onSearchTextButtonClicked()
|
2012-12-23 00:00:24 +00:00
|
|
|
if item.name.lower() == u'custom':
|
|
|
|
Receiver.send_message(u'service_item_update', u'%s:%s:%s' % (custom.id, item._uuid, False))
|
2012-12-22 22:40:58 +00:00
|
|
|
|
2011-05-15 19:07:40 +00:00
|
|
|
def onClearTextButtonClick(self):
|
|
|
|
"""
|
|
|
|
Clear the search text.
|
|
|
|
"""
|
|
|
|
self.searchTextEdit.clear()
|
2012-04-02 00:19:16 +00:00
|
|
|
self.onSearchTextButtonClicked()
|
2011-05-18 14:27:29 +00:00
|
|
|
|
2012-03-15 06:15:21 +00:00
|
|
|
def search(self, string, showError):
|
2011-05-15 18:33:00 +00:00
|
|
|
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)
|
2011-05-27 09:34:14 +00:00
|
|
|
return [[custom.id, custom.title] for custom in search_results]
|
2011-05-18 14:27:29 +00:00
|
|
|
|