forked from openlp/openlp
- improved 'auto select'
- fixed a traceback - improved parentage - clean ups
This commit is contained in:
parent
97dea99310
commit
59d374517e
@ -112,13 +112,10 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
self.requiredIcons()
|
self.requiredIcons()
|
||||||
self.setupUi()
|
self.setupUi()
|
||||||
self.retranslateUi()
|
self.retranslateUi()
|
||||||
self.autoSelectItem = None
|
self.auto_select_id = -1
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'%s_service_load' % self.parent.name.lower()),
|
QtCore.SIGNAL(u'%s_service_load' % self.parent.name.lower()),
|
||||||
self.serviceLoad)
|
self.serviceLoad)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
|
||||||
QtCore.SIGNAL(u'%s_set_autoselect_item' % self.parent.name.lower()),
|
|
||||||
self.setAutoSelectItem)
|
|
||||||
|
|
||||||
def requiredIcons(self):
|
def requiredIcons(self):
|
||||||
"""
|
"""
|
||||||
@ -479,9 +476,6 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
if keepFocus:
|
if keepFocus:
|
||||||
self.listView.setFocus()
|
self.listView.setFocus()
|
||||||
|
|
||||||
def setAutoSelectItem(self, itemToSelect=None):
|
|
||||||
self.autoSelectItem = itemToSelect
|
|
||||||
|
|
||||||
def onLiveClick(self):
|
def onLiveClick(self):
|
||||||
"""
|
"""
|
||||||
Send an item live by building a service item then adding that service
|
Send an item live by building a service item then adding that service
|
||||||
@ -617,6 +611,16 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||||
return item_id
|
return item_id
|
||||||
|
|
||||||
|
def save_auto_select_id(self):
|
||||||
|
"""
|
||||||
|
Sorts out, what item to select after loading a list.
|
||||||
|
"""
|
||||||
|
# The item to select has not been set.
|
||||||
|
if self.auto_select_id == -1:
|
||||||
|
item = self.listView.currentItem()
|
||||||
|
if item:
|
||||||
|
self.auto_select_id = item.data(QtCore.Qt.UserRole).toInt()[0]
|
||||||
|
|
||||||
def search(self, string):
|
def search(self, string):
|
||||||
"""
|
"""
|
||||||
Performs a plugin specific search for items containing ``string``
|
Performs a plugin specific search for items containing ``string``
|
||||||
|
@ -1044,7 +1044,8 @@ class SlideController(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
From the preview display request the Item to be added to service
|
From the preview display request the Item to be added to service
|
||||||
"""
|
"""
|
||||||
self.parent.serviceManagerContents.addServiceItem(self.serviceItem)
|
if self.serviceItem:
|
||||||
|
self.parent.serviceManagerContents.addServiceItem(self.serviceItem)
|
||||||
|
|
||||||
def onGoLiveClick(self):
|
def onGoLiveClick(self):
|
||||||
"""
|
"""
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from forms import EditCustomForm
|
|
||||||
|
|
||||||
from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
||||||
from openlp.core.lib.db import Manager
|
from openlp.core.lib.db import Manager
|
||||||
from openlp.plugins.custom.lib import CustomMediaItem, CustomTab
|
from openlp.plugins.custom.lib import CustomMediaItem, CustomTab
|
||||||
@ -52,7 +50,6 @@ class CustomPlugin(Plugin):
|
|||||||
CustomMediaItem, CustomTab)
|
CustomMediaItem, CustomTab)
|
||||||
self.weight = -5
|
self.weight = -5
|
||||||
self.manager = Manager(u'custom', init_schema)
|
self.manager = Manager(u'custom', init_schema)
|
||||||
self.edit_custom_form = EditCustomForm(self)
|
|
||||||
self.icon_path = u':/plugins/plugin_custom.png'
|
self.icon_path = u':/plugins/plugin_custom.png'
|
||||||
self.icon = build_icon(self.icon_path)
|
self.icon = build_icon(self.icon_path)
|
||||||
|
|
||||||
|
@ -43,13 +43,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
Class documentation goes here.
|
Class documentation goes here.
|
||||||
"""
|
"""
|
||||||
log.info(u'Custom Editor loaded')
|
log.info(u'Custom Editor loaded')
|
||||||
def __init__(self, parent):
|
def __init__(self, parent, manager):
|
||||||
"""
|
"""
|
||||||
Constructor
|
Constructor
|
||||||
"""
|
"""
|
||||||
QtGui.QDialog.__init__(self)
|
QtGui.QDialog.__init__(self)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.manager = self.parent.manager
|
self.manager = manager
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
# Create other objects and forms.
|
# Create other objects and forms.
|
||||||
self.editSlideForm = EditCustomSlideForm(self)
|
self.editSlideForm = EditCustomSlideForm(self)
|
||||||
@ -115,8 +115,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
def accept(self):
|
def accept(self):
|
||||||
log.debug(u'accept')
|
log.debug(u'accept')
|
||||||
if self.saveCustom():
|
if self.saveCustom():
|
||||||
Receiver.send_message(u'custom_set_autoselect_item',
|
|
||||||
self.customSlide.id)
|
|
||||||
Receiver.send_message(u'custom_load_list')
|
Receiver.send_message(u'custom_load_list')
|
||||||
QtGui.QDialog.accept(self)
|
QtGui.QDialog.accept(self)
|
||||||
|
|
||||||
@ -138,7 +136,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
self.customSlide.text = unicode(sxml.extract_xml(), u'utf-8')
|
self.customSlide.text = unicode(sxml.extract_xml(), u'utf-8')
|
||||||
self.customSlide.credits = unicode(self.creditEdit.text())
|
self.customSlide.credits = unicode(self.creditEdit.text())
|
||||||
self.customSlide.theme_name = unicode(self.themeComboBox.currentText())
|
self.customSlide.theme_name = unicode(self.themeComboBox.currentText())
|
||||||
return self.manager.save_object(self.customSlide)
|
success = self.manager.save_object(self.customSlide)
|
||||||
|
self.parent.auto_select_id = self.customSlide.id
|
||||||
|
return success
|
||||||
|
|
||||||
def onUpButtonClicked(self):
|
def onUpButtonClicked(self):
|
||||||
selectedRow = self.slideListView.currentRow()
|
selectedRow = self.slideListView.currentRow()
|
||||||
|
@ -35,6 +35,7 @@ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
|
|||||||
check_item_selected, translate
|
check_item_selected, translate
|
||||||
from openlp.core.lib.searchedit import SearchEdit
|
from openlp.core.lib.searchedit import SearchEdit
|
||||||
from openlp.core.lib.ui import UiStrings
|
from openlp.core.lib.ui import UiStrings
|
||||||
|
from openlp.plugins.custom.forms import EditCustomForm
|
||||||
from openlp.plugins.custom.lib import CustomXMLParser
|
from openlp.plugins.custom.lib import CustomXMLParser
|
||||||
from openlp.plugins.custom.lib.db import CustomSlide
|
from openlp.plugins.custom.lib.db import CustomSlide
|
||||||
|
|
||||||
@ -57,6 +58,7 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
def __init__(self, parent, plugin, icon):
|
def __init__(self, parent, plugin, icon):
|
||||||
self.IconPath = u'custom/custom'
|
self.IconPath = u'custom/custom'
|
||||||
MediaManagerItem.__init__(self, parent, self, icon)
|
MediaManagerItem.__init__(self, parent, self, icon)
|
||||||
|
self.edit_custom_form = EditCustomForm(self, self.parent.manager)
|
||||||
self.singleServiceItem = False
|
self.singleServiceItem = False
|
||||||
self.quickPreviewAllowed = True
|
self.quickPreviewAllowed = True
|
||||||
self.hasSearch = True
|
self.hasSearch = True
|
||||||
@ -136,6 +138,8 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
self.onRemoteEditClear()
|
self.onRemoteEditClear()
|
||||||
|
|
||||||
def loadList(self, custom_slides):
|
def loadList(self, custom_slides):
|
||||||
|
# Sort out what custom we want to select after loading the list.
|
||||||
|
self.save_auto_select_id()
|
||||||
self.listView.clear()
|
self.listView.clear()
|
||||||
# Sort the customs by its title considering language specific
|
# Sort the customs by its title considering language specific
|
||||||
# characters. lower() is needed for windows!
|
# characters. lower() is needed for windows!
|
||||||
@ -146,33 +150,34 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
custom_name.setData(
|
custom_name.setData(
|
||||||
QtCore.Qt.UserRole, QtCore.QVariant(custom_slide.id))
|
QtCore.Qt.UserRole, QtCore.QVariant(custom_slide.id))
|
||||||
self.listView.addItem(custom_name)
|
self.listView.addItem(custom_name)
|
||||||
# Auto-select the item if name has been set
|
# Auto-select the custom.
|
||||||
if custom_slide.id == self.autoSelectItem:
|
if custom_slide.id == self.auto_select_id:
|
||||||
self.listView.setCurrentItem(custom_name)
|
self.listView.setCurrentItem(custom_name)
|
||||||
|
self.auto_select_id = -1
|
||||||
|
|
||||||
def onNewClick(self):
|
def onNewClick(self):
|
||||||
self.parent.edit_custom_form.loadCustom(0)
|
self.edit_custom_form.loadCustom(0)
|
||||||
self.parent.edit_custom_form.exec_()
|
self.edit_custom_form.exec_()
|
||||||
self.initialise()
|
self.initialise()
|
||||||
|
|
||||||
def onRemoteEditClear(self):
|
def onRemoteEditClear(self):
|
||||||
self.remoteTriggered = None
|
self.remoteTriggered = None
|
||||||
self.remoteCustom = -1
|
self.remoteCustom = -1
|
||||||
|
|
||||||
def onRemoteEdit(self, customid):
|
def onRemoteEdit(self, message):
|
||||||
"""
|
"""
|
||||||
Called by ServiceManager or SlideController by event passing
|
Called by ServiceManager or SlideController by event passing
|
||||||
the Song Id in the payload along with an indicator to say which
|
the custom Id in the payload along with an indicator to say which
|
||||||
type of display is required.
|
type of display is required.
|
||||||
"""
|
"""
|
||||||
fields = customid.split(u':')
|
remote_type, custom_id = message.split(u':')
|
||||||
valid = self.manager.get_object(CustomSlide, fields[1])
|
custom_id = int(custom_id)
|
||||||
|
valid = self.manager.get_object(CustomSlide, custom_id)
|
||||||
if valid:
|
if valid:
|
||||||
self.remoteCustom = fields[1]
|
self.remoteCustom = custom_id
|
||||||
self.remoteTriggered = fields[0]
|
self.remoteTriggered = remote_type
|
||||||
self.parent.edit_custom_form.loadCustom(fields[1],
|
self.edit_custom_form.loadCustom(custom_id, (remote_type == u'P'))
|
||||||
(fields[0] == u'P'))
|
self.edit_custom_form.exec_()
|
||||||
self.parent.edit_custom_form.exec_()
|
|
||||||
|
|
||||||
def onEditClick(self):
|
def onEditClick(self):
|
||||||
"""
|
"""
|
||||||
@ -181,8 +186,8 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
if check_item_selected(self.listView, UiStrings().SelectEdit):
|
if check_item_selected(self.listView, UiStrings().SelectEdit):
|
||||||
item = self.listView.currentItem()
|
item = self.listView.currentItem()
|
||||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||||
self.parent.edit_custom_form.loadCustom(item_id, False)
|
self.edit_custom_form.loadCustom(item_id, False)
|
||||||
self.parent.edit_custom_form.exec_()
|
self.edit_custom_form.exec_()
|
||||||
self.initialise()
|
self.initialise()
|
||||||
|
|
||||||
def onDeleteClick(self):
|
def onDeleteClick(self):
|
||||||
@ -203,7 +208,6 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
self.searchTextEdit.setFocus()
|
self.searchTextEdit.setFocus()
|
||||||
|
|
||||||
def generateSlideData(self, service_item, item=None, xmlVersion=False):
|
def generateSlideData(self, service_item, item=None, xmlVersion=False):
|
||||||
raw_slides = []
|
|
||||||
raw_footer = []
|
raw_footer = []
|
||||||
slide = None
|
slide = None
|
||||||
theme = None
|
theme = None
|
||||||
@ -221,8 +225,7 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
service_item.theme = theme
|
service_item.theme = theme
|
||||||
customXML = CustomXMLParser(customSlide.text)
|
customXML = CustomXMLParser(customSlide.text)
|
||||||
verseList = customXML.get_verses()
|
verseList = customXML.get_verses()
|
||||||
for verse in verseList:
|
raw_slides = [verse[1] for verse in verseList]
|
||||||
raw_slides.append(verse[1])
|
|
||||||
service_item.title = title
|
service_item.title = title
|
||||||
for slide in raw_slides:
|
for slide in raw_slides:
|
||||||
service_item.add_from_text(slide[:30], slide)
|
service_item.add_from_text(slide[:30], slide)
|
||||||
@ -260,7 +263,7 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
def onSearchTextEditChanged(self, text):
|
def onSearchTextEditChanged(self, text):
|
||||||
"""
|
"""
|
||||||
If search as type enabled invoke the search on each key press.
|
If search as type enabled invoke the search on each key press.
|
||||||
If the Title is being searched do not start till 2 characters
|
If the Title is being searched do not start until 2 characters
|
||||||
have been entered.
|
have been entered.
|
||||||
"""
|
"""
|
||||||
search_length = 2
|
search_length = 2
|
||||||
@ -283,8 +286,5 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
func.lower(CustomSlide.text).like(u'%' +
|
func.lower(CustomSlide.text).like(u'%' +
|
||||||
string.lower() + u'%')),
|
string.lower() + u'%')),
|
||||||
order_by_ref=CustomSlide.title)
|
order_by_ref=CustomSlide.title)
|
||||||
results = []
|
return [[custom.id, custom.title] for custom in search_results]
|
||||||
for custom in search_results:
|
|
||||||
results.append([custom.id, custom.title])
|
|
||||||
return results
|
|
||||||
|
|
||||||
|
@ -696,7 +696,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.clearCaches()
|
self.clearCaches()
|
||||||
if self._validate_song():
|
if self._validate_song():
|
||||||
self.saveSong()
|
self.saveSong()
|
||||||
Receiver.send_message(u'songs_set_autoselect_item',self.song.id)
|
|
||||||
Receiver.send_message(u'songs_load_list')
|
Receiver.send_message(u'songs_load_list')
|
||||||
self.song = None
|
self.song = None
|
||||||
QtGui.QDialog.accept(self)
|
QtGui.QDialog.accept(self)
|
||||||
@ -756,6 +755,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.song.topics.append(self.manager.get_object(Topic, topicId))
|
self.song.topics.append(self.manager.get_object(Topic, topicId))
|
||||||
clean_song(self.manager, self.song)
|
clean_song(self.manager, self.song)
|
||||||
self.manager.save_object(self.song)
|
self.manager.save_object(self.song)
|
||||||
|
self.parent.auto_select_id = self.song.id
|
||||||
|
|
||||||
def _processLyrics(self):
|
def _processLyrics(self):
|
||||||
"""
|
"""
|
||||||
|
@ -232,6 +232,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
|
|
||||||
def displayResultsSong(self, searchresults):
|
def displayResultsSong(self, searchresults):
|
||||||
log.debug(u'display results Song')
|
log.debug(u'display results Song')
|
||||||
|
self.save_auto_select_id()
|
||||||
self.listView.clear()
|
self.listView.clear()
|
||||||
# Sort the songs by its title considering language specific characters.
|
# Sort the songs by its title considering language specific characters.
|
||||||
# lower() is needed for windows!
|
# lower() is needed for windows!
|
||||||
@ -245,8 +246,9 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
|
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
|
||||||
self.listView.addItem(song_name)
|
self.listView.addItem(song_name)
|
||||||
# Auto-select the item if name has been set
|
# Auto-select the item if name has been set
|
||||||
if song.id == self.autoSelectItem :
|
if song.id == self.auto_select_id:
|
||||||
self.listView.setCurrentItem(song_name)
|
self.listView.setCurrentItem(song_name)
|
||||||
|
self.auto_select_id = -1
|
||||||
|
|
||||||
def displayResultsAuthor(self, searchresults):
|
def displayResultsAuthor(self, searchresults):
|
||||||
log.debug(u'display results Author')
|
log.debug(u'display results Author')
|
||||||
@ -487,7 +489,4 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
Search for some songs
|
Search for some songs
|
||||||
"""
|
"""
|
||||||
search_results = self.searchEntire(string)
|
search_results = self.searchEntire(string)
|
||||||
results = []
|
return [[song.id, song.title] for song in search_results]
|
||||||
for song in search_results:
|
|
||||||
results.append([song.id, song.title])
|
|
||||||
return results
|
|
||||||
|
Loading…
Reference in New Issue
Block a user