Fix bug with service item edit ids missing

Fix name format error
Add debugging to help with service load and song edit bugs. Need to see what is happening when we hit them.

bzr-revno: 1120
This commit is contained in:
Tim Bentley 2010-11-21 14:43:34 +00:00
commit ea88d082d7
6 changed files with 21 additions and 9 deletions

View File

@ -514,7 +514,7 @@ class MediaManagerItem(QtGui.QWidget):
self.parent.serviceManager.addServiceItem(service_item,
replace=True)
else:
#Turn off the remote edit update message indicator
# Turn off the remote edit update message indicator
QtGui.QMessageBox.information(self,
translate('OpenLP.MediaManagerItem',
'Invalid Service Item'),

View File

@ -100,6 +100,7 @@ class ServiceItem(object):
self.bg_image_bytes = None
self.search_string = u''
self.data_string = u''
self.edit_id = None
self._new_item()
def _new_item(self):

View File

@ -308,7 +308,7 @@ class ServiceManager(QtGui.QWidget):
self.maintainAction.setVisible(False)
self.notesAction.setVisible(False)
if serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsEdit)\
and hasattr(serviceItem[u'service_item'], u'editId'):
and serviceItem[u'service_item'].edit_id:
self.editAction.setVisible(True)
if serviceItem[u'service_item']\
.is_capable(ItemCapabilities.AllowsMaintain):
@ -864,7 +864,7 @@ class ServiceManager(QtGui.QWidget):
editId, uuid = message.split(u':')
for item in self.serviceItems:
if item[u'service_item']._uuid == uuid:
item[u'service_item'].editId = editId
item[u'service_item'].edit_id = editId
def replaceServiceItem(self, newItem):
"""
@ -873,7 +873,7 @@ class ServiceManager(QtGui.QWidget):
"""
newItem.render()
for itemcount, item in enumerate(self.serviceItems):
if item[u'service_item'].editId == newItem.editId and \
if item[u'service_item'].edit_id == newItem.edit_id and \
item[u'service_item'].name == newItem.name:
newItem.merge(item[u'service_item'])
item[u'service_item'] = newItem
@ -983,7 +983,7 @@ class ServiceManager(QtGui.QWidget):
.is_capable(ItemCapabilities.AllowsEdit):
Receiver.send_message(u'%s_edit' %
self.serviceItems[item][u'service_item'].name.lower(), u'L:%s' %
self.serviceItems[item][u'service_item'].editId )
self.serviceItems[item][u'service_item'].edit_id )
def findServiceItem(self):
"""

View File

@ -942,7 +942,7 @@ class SlideController(QtGui.QWidget):
"""
self.songEdit = True
Receiver.send_message(u'%s_edit' % self.serviceItem.name.lower(),
u'P:%s' % self.serviceItem.editId)
u'P:%s' % self.serviceItem.edit_id)
def onGoLive(self):
"""

View File

@ -165,7 +165,7 @@ class CustomMediaItem(MediaManagerItem):
customSlide = self.parent.manager.get_object(CustomSlide, item_id)
title = customSlide.title
credit = customSlide.credits
service_item.editId = item_id
service_item.edit_id = item_id
theme = customSlide.theme_name
if theme:
service_item.theme = theme

View File

@ -192,6 +192,7 @@ class SongMediaItem(MediaManagerItem):
Handle the exit from the edit dialog and trigger remote updates
of songs
"""
log.debug(u'onSongListLoad')
# Called to redisplay the song list screen edit 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.
@ -259,6 +260,7 @@ class SongMediaItem(MediaManagerItem):
Receiver.send_message(u'songs_load_list')
def onNewClick(self):
log.debug(u'onNewClick')
self.edit_song_form.newSong()
self.edit_song_form.exec_()
@ -266,6 +268,7 @@ class SongMediaItem(MediaManagerItem):
self.song_maintenance_form.exec_()
def onRemoteEditClear(self):
log.debug(u'onRemoteEditClear')
self.remoteTriggered = None
self.remoteSong = -1
@ -275,6 +278,7 @@ class SongMediaItem(MediaManagerItem):
the Song Id in the payload along with an indicator to say which
type of display is required.
"""
log.debug(u'onRemoteEdit %s' % songid)
fields = songid.split(u':')
valid = self.parent.manager.get_object(Song, fields[1])
if valid:
@ -287,6 +291,7 @@ class SongMediaItem(MediaManagerItem):
"""
Edit a song
"""
log.debug(u'onEditClick')
if check_item_selected(self.listView,
translate('SongsPlugin.MediaItem',
'You must select an item to edit.')):
@ -324,6 +329,7 @@ class SongMediaItem(MediaManagerItem):
self.onSearchTextButtonClick()
def generateSlideData(self, service_item, item=None):
log.debug(u'generateSlideData (%s:%s)' % (service_item, item))
raw_footer = []
author_list = u''
author_audit = []
@ -345,7 +351,7 @@ class SongMediaItem(MediaManagerItem):
service_item.add_capability(ItemCapabilities.AddIfNewItem)
song = self.parent.manager.get_object(Song, item_id)
service_item.theme = song.theme_name
service_item.editId = item_id
service_item.edit_id = item_id
if song.lyrics.startswith(u'<?xml version='):
songXML = SongXMLParser(song.lyrics)
verseList = songXML.get_verses()
@ -357,7 +363,7 @@ class SongMediaItem(MediaManagerItem):
service_item.add_from_text(
verse[1][:30], unicode(verse[1]), verseTag)
else:
#Loop through the verse list and expand the song accordingly.
# Loop through the verse list and expand the song accordingly.
for order in song.verse_order.upper().split(u' '):
if len(order) == 0:
break
@ -397,6 +403,7 @@ class SongMediaItem(MediaManagerItem):
"""
Triggered by a song being loaded by the service item
"""
log.debug(u'serviceLoad')
if item.data_string:
search_results = self.parent.manager.get_all_objects(Song,
Song.search_title.like(u'%' +
@ -408,9 +415,13 @@ class SongMediaItem(MediaManagerItem):
if search_results:
for song in search_results:
count = 0
# temp debug to find why service items do not edit
log.debug(u'author list %s' % author_list)
for author in song.authors:
log.debug(u'author %s' % author.display_name)
if author.display_name in author_list:
count += 1
log.debug(u'found %s : %s' % (count, len(author_list)))
if count == len(author_list):
editId = song.id
uuid = item._uuid