Cleanup Remote Editing again

This commit is contained in:
Tim Bentley 2009-11-03 06:15:35 +00:00
parent 2d473d9436
commit 8c77de16c4
4 changed files with 36 additions and 37 deletions

View File

@ -93,9 +93,6 @@ class EventReceiver(QtCore.QObject):
``config_updated`` ``config_updated``
Informs components the config has changed Informs components the config has changed
``edit_song``
Requests the current song on the preview display be loaded for edit
``preview_song`` ``preview_song``
Tells the song plugin the edit has finished and the song can be previewed Tells the song plugin the edit has finished and the song can be previewed
Only available if the edit was triggered by the Preview button. Only available if the edit was triggered by the Preview button.

View File

@ -597,7 +597,7 @@ class ServiceManager(QtGui.QWidget):
item, count = self.findServiceItem() item, count = self.findServiceItem()
if self.serviceItems[item][u'data'].editEnabled: if self.serviceItems[item][u'data'].editEnabled:
self.remoteEditTriggered = True self.remoteEditTriggered = True
Receiver().send_message(u'%s_edit' % self.serviceItems[item][u'data'].name, Receiver().send_message(u'%s_edit' % self.serviceItems[item][u'data'].name, u'L:%s' %
self.serviceItems[item][u'data'].editId ) self.serviceItems[item][u'data'].editId )
def onRemoteEditClear(self): def onRemoteEditClear(self):

View File

@ -323,7 +323,7 @@ class SlideController(QtGui.QWidget):
""" """
Allows the Preview toolbar to be customised Allows the Preview toolbar to be customised
""" """
if item.name == u'Songs' and item.fromPlugin: if (item.name == u'Songs' or item.name == u'Custom') and item.fromPlugin:
self.Toolbar.makeWidgetsVisible(self.song_list) self.Toolbar.makeWidgetsVisible(self.song_list)
else: else:
self.Toolbar.makeWidgetsInvisible(self.song_list) self.Toolbar.makeWidgetsInvisible(self.song_list)
@ -561,7 +561,8 @@ class SlideController(QtGui.QWidget):
def onEditSong(self): def onEditSong(self):
self.songEdit = True self.songEdit = True
Receiver().send_message(u'edit_song') Receiver().send_message(u'%s_edit' % self.commandItem.name, u'P:%s' %
self.commandItem.editId )
def onGoLive(self): def onGoLive(self):
""" """

View File

@ -53,12 +53,10 @@ class SongMediaItem(MediaManagerItem):
self.edit_song_form = EditSongForm(self.parent.songmanager, self) self.edit_song_form = EditSongForm(self.parent.songmanager, self)
self.song_maintenance_form = SongMaintenanceForm( self.song_maintenance_form = SongMaintenanceForm(
self.parent.songmanager, self) self.parent.songmanager, self)
#fromPreview holds the id of the item if the song editor needs to trigger a preview #Holds information about whether the edit is remotly triggered and which
#without closing. It is set to -1 if this function is inactive #Song is required.
self.fromPreview = -1 self.remoteTriggered = None
#fromServiceManager holds the id of the item if the song editor needs to trigger posting self.remoteSong = -1
#to the servicemanager without closing. It is set to -1 if this function is inactive
self.fromServiceManager = -1
def initPluginNameVisible(self): def initPluginNameVisible(self):
self.PluginNameVisible = self.trUtf8(u'Song') self.PluginNameVisible = self.trUtf8(u'Song')
@ -128,8 +126,6 @@ class SongMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'load_song_list'), self.onSearchTextButtonClick) QtCore.SIGNAL(u'load_song_list'), self.onSearchTextButtonClick)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.configUpdated) QtCore.SIGNAL(u'config_updated'), self.configUpdated)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'edit_song'), self.onEventEditSong)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'preview_song'), self.onPreviewClick) QtCore.SIGNAL(u'preview_song'), self.onPreviewClick)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
@ -172,6 +168,14 @@ class SongMediaItem(MediaManagerItem):
search_results = self.parent.songmanager.get_song_from_author( search_results = self.parent.songmanager.get_song_from_author(
search_keywords) search_keywords)
self.displayResultsAuthor(search_results) self.displayResultsAuthor(search_results)
#Called to redisplay the song list screen edith from a search
#or from the exit of the Song 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()
def displayResultsSong(self, searchresults): def displayResultsSong(self, searchresults):
log.debug(u'display results Song') log.debug(u'display results Song')
@ -188,12 +192,6 @@ class SongMediaItem(MediaManagerItem):
song_name = QtGui.QListWidgetItem(song_detail) song_name = QtGui.QListWidgetItem(song_detail)
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)
if song.id == self.fromPreview:
self.ListView.setCurrentItem(song_name)
self.onPreviewClick()
self.fromPreview = -1
if song.id == self.fromServiceManager:
self.onAddClick()
def displayResultsAuthor(self, searchresults): def displayResultsAuthor(self, searchresults):
log.debug(u'display results Author') log.debug(u'display results Author')
@ -213,6 +211,11 @@ class SongMediaItem(MediaManagerItem):
self.SearchTextEdit.clear() self.SearchTextEdit.clear()
def onSearchTextEditChanged(self, text): def onSearchTextEditChanged(self, text):
"""
If search as type enabled invoke the search on each key press.
If the Lyrics are being searched do not start till 7 characters
have been entered.
"""
if self.searchAsYouType: if self.searchAsYouType:
search_length = 1 search_length = 1
if self.SearchTypeComboBox.currentIndex() == 1: if self.SearchTypeComboBox.currentIndex() == 1:
@ -240,28 +243,30 @@ class SongMediaItem(MediaManagerItem):
self.song_maintenance_form.exec_() self.song_maintenance_form.exec_()
def onRemoteEditClear(self): def onRemoteEditClear(self):
self.fromServiceManager = -1 self.remoteTriggered = None
self.remoteSong = -1
def onRemoteEdit(self, songid): def onRemoteEdit(self, songid):
valid = self.parent.songmanager.get_song(songid) """
Called by ServiceManager or SlideController by event passing
the Song Id in the payload along with an indicator to say which
type of display is required.
"""
fields = songid.split(u':')
valid = self.parent.songmanager.get_song(fields[1])
if valid is not None: if valid is not None:
self.fromServiceManager = songid self.remoteSong = fields[1]
self.edit_song_form.loadSong(songid, False) self.remoteTriggered = fields[0]
self.edit_song_form.loadSong(fields[1], (fields[0] == u'P'))
self.edit_song_form.exec_() self.edit_song_form.exec_()
def onEditClick(self, preview=False): def onEditClick(self, preview=False):
item = self.ListView.currentItem() item = self.ListView.currentItem()
if item is not None: if item is not None:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.fromPreview = -1 self.edit_song_form.loadSong(item_id, False)
if preview:
self.fromPreview = item_id
self.edit_song_form.loadSong(item_id, preview)
self.edit_song_form.exec_() self.edit_song_form.exec_()
def onEventEditSong (self):
self.onEditClick(True)
def onDeleteClick(self): def onDeleteClick(self):
item = self.ListView.currentItem() item = self.ListView.currentItem()
if item is not None: if item is not None:
@ -271,21 +276,17 @@ class SongMediaItem(MediaManagerItem):
self.ListView.takeItem(row) self.ListView.takeItem(row)
def generateSlideData(self, service_item): def generateSlideData(self, service_item):
#raw_slides =[]
raw_footer = [] raw_footer = []
author_list = u'' author_list = u''
author_audit = [] author_audit = []
ccl = u'' ccl = u''
if self.fromServiceManager == -1: if self.remoteTriggered is None:
item = self.ListView.currentItem() item = self.ListView.currentItem()
if item is None: if item is None:
return False return False
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
else: else:
item_id = self.fromServiceManager item_id = self.remoteSong
#if we are in preview mode do not reset the servicemanage id
if self.fromPreview != -1:
self.fromServiceManager = -1
song = self.parent.songmanager.get_song(item_id) song = self.parent.songmanager.get_song(item_id)
service_item.theme = song.theme_name service_item.theme = song.theme_name
service_item.editEnabled = True service_item.editEnabled = True