Add Service Item update from edit with config flag

This commit is contained in:
Tim Bentley 2010-10-06 20:27:30 +01:00
parent 39f1aa2e09
commit 7863a2ebfc
4 changed files with 81 additions and 12 deletions

View File

@ -815,6 +815,21 @@ class ServiceManager(QtGui.QWidget):
if item[u'service_item']._uuid == uuid:
item[u'service_item'].editId = editId
def replaceServiceItem(self, newItem):
"""
Using the service item passed replace the one with the same edit id
if found.
"""
newItem.render()
for itemcount, item in enumerate(self.serviceItems):
if item[u'service_item'].editId == newItem.editId and \
item[u'service_item'].name == newItem.name:
newItem.merge(item[u'service_item'])
item[u'service_item'] = newItem
self.repaintServiceList(itemcount + 1, 0)
self.parent.LiveController.replaceServiceManagerItem(newItem)
self.parent.serviceChanged(False, self.serviceName)
def addServiceItem(self, item, rebuild=False, expand=True, replace=False):
"""
Add a Service item to the list

View File

@ -60,6 +60,7 @@ class SongMediaItem(MediaManagerItem):
# Holds information about whether the edit is remotly triggered and
# which Song is required.
self.remoteSong = -1
self.editItem = None
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
@ -123,7 +124,7 @@ class SongMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'textChanged(const QString&)'),
self.onSearchTextEditChanged)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'songs_load_list'), self.onSearchTextButtonClick)
QtCore.SIGNAL(u'songs_load_list'), self.onSongListLoad)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.configUpdated)
QtCore.QObject.connect(Receiver.get_receiver(),
@ -137,6 +138,12 @@ class SongMediaItem(MediaManagerItem):
self.searchAsYouType = QtCore.QSettings().value(
self.settingsSection + u'/search as type',
QtCore.QVariant(u'False')).toBool()
self.updateServiceOnEdit = QtCore.QSettings().value(
self.settingsSection + u'/update service on edit',
QtCore.QVariant(u'False')).toBool()
self.AddSongFromServide = QtCore.QSettings().value(
self.settingsSection + u'/add song from service',
QtCore.QVariant(u'True')).toBool()
def retranslateUi(self):
self.SearchTextLabel.setText(
@ -179,14 +186,25 @@ class SongMediaItem(MediaManagerItem):
Author.display_name.like(u'%' + search_keywords + u'%'),
Author.display_name.asc())
self.displayResultsAuthor(search_results)
#Called to redisplay the song list screen edith from a search
def onSongListLoad(self):
"""
Handle the exit from the edit dialog and trigger remote updates
of songs
"""
# 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.
if self.remoteTriggered == u'L':
self.onAddClick()
if self.remoteTriggered == u'P':
self.onPreviewClick()
# Push edits to the service manager to update items
if self.editItem and self.updateServiceOnEdit:
item = self.buildServiceItem(self.editItem)
self.parent.serviceManager.replaceServiceItem(item)
self.onRemoteEditClear()
self.onSearchTextButtonClick()
def displayResultsSong(self, searchresults):
log.debug(u'display results Song')
@ -271,8 +289,8 @@ class SongMediaItem(MediaManagerItem):
if check_item_selected(self.listView,
translate('SongsPlugin.MediaItem',
'You must select an item to edit.')):
item = self.listView.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.editItem = self.listView.currentItem()
item_id = (self.editItem.data(QtCore.Qt.UserRole)).toInt()[0]
self.edit_song_form.loadSong(item_id, False)
self.edit_song_form.exec_()

View File

@ -51,8 +51,14 @@ class SongsTab(SettingsTab):
self.SearchAsTypeCheckBox.setObjectName(u'SearchAsTypeCheckBox')
self.SongsModeLayout.addWidget(self.SearchAsTypeCheckBox)
self.SongBarActiveCheckBox = QtGui.QCheckBox(self.SongsModeGroupBox)
self.SongBarActiveCheckBox.setObjectName(u'SearchAsTypeCheckBox')
self.SongBarActiveCheckBox.setObjectName(u'SongBarActiveCheckBox')
self.SongsModeLayout.addWidget(self.SongBarActiveCheckBox)
self.SongUpdateOnEditCheckBox = QtGui.QCheckBox(self.SongsModeGroupBox)
self.SongUpdateOnEditCheckBox.setObjectName(u'SongUpdateOnEditCheckBox')
self.SongsModeLayout.addWidget(self.SongUpdateOnEditCheckBox)
self.SongAddFromServiceCheckBox = QtGui.QCheckBox(self.SongsModeGroupBox)
self.SongAddFromServiceCheckBox.setObjectName(u'SongAddFromServiceCheckBox')
self.SongsModeLayout.addWidget(self.SongAddFromServiceCheckBox)
self.SongsLayout.setWidget(
0, QtGui.QFormLayout.LabelRole, self.SongsModeGroupBox)
QtCore.QObject.connect(self.SearchAsTypeCheckBox,
@ -60,7 +66,13 @@ class SongsTab(SettingsTab):
self.onSearchAsTypeCheckBoxChanged)
QtCore.QObject.connect(self.SongBarActiveCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.SongBarActiveCheckBoxChanged)
self.onSongBarActiveCheckBoxChanged)
QtCore.QObject.connect(self.SongUpdateOnEditCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onSongUpdateOnEditCheckBoxChanged)
QtCore.QObject.connect(self.SongBarActiveCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onSongAddFromServiceCheckBoxChanged)
def retranslateUi(self):
self.SongsModeGroupBox.setTitle(
@ -69,6 +81,10 @@ class SongsTab(SettingsTab):
translate('SongsPlugin.SongsTab', 'Enable search as you type'))
self.SongBarActiveCheckBox.setText(translate('SongsPlugin.SongsTab',
'Display verses on live tool bar'))
self.SongUpdateOnEditCheckBox.setText(
translate('SongsPlugin.SongsTab', 'Update service from song edit'))
self.SongAddFromServiceCheckBox.setText(translate('SongsPlugin.SongsTab',
'Add songs from service being Loaded'))
def onSearchAsTypeCheckBoxChanged(self, check_state):
self.song_search = False
@ -76,12 +92,24 @@ class SongsTab(SettingsTab):
if check_state == QtCore.Qt.Checked:
self.song_search = True
def SongBarActiveCheckBoxChanged(self, check_state):
def onSongBarActiveCheckBoxChanged(self, check_state):
self.song_bar = False
# we have a set value convert to True/False
if check_state == QtCore.Qt.Checked:
self.song_bar = True
def onSongUpdateOnEditCheckBoxChanged(self, check_state):
self.update_edit = False
# we have a set value convert to True/False
if check_state == QtCore.Qt.Checked:
self.update_edit = True
def onSongAddFromServiceCheckBoxChanged(self, check_state):
self.update_load = False
# we have a set value convert to True/False
if check_state == QtCore.Qt.Checked:
self.update_load = True
def load(self):
settings = QtCore.QSettings()
settings.beginGroup(self.settingsSection)
@ -89,8 +117,14 @@ class SongsTab(SettingsTab):
u'search as type', QtCore.QVariant(False)).toBool()
self.song_bar = settings.value(
u'display songbar', QtCore.QVariant(True)).toBool()
self.update_edit = settings.value(
u'update service on edit', QtCore.QVariant(False)).toBool()
self.update_load = settings.value(
u'add song from service', QtCore.QVariant(True)).toBool()
self.SearchAsTypeCheckBox.setChecked(self.song_search)
self.SongBarActiveCheckBox.setChecked(self.song_bar)
self.SongUpdateOnEditCheckBox.setChecked(self.update_edit)
self.SongAddFromServiceCheckBox.setChecked(self.update_load)
settings.endGroup()
def save(self):
@ -98,4 +132,6 @@ class SongsTab(SettingsTab):
settings.beginGroup(self.settingsSection)
settings.setValue(u'search as type', QtCore.QVariant(self.song_search))
settings.setValue(u'display songbar', QtCore.QVariant(self.song_bar))
settings.setValue(u'update service on edit', QtCore.QVariant(self.update_edit))
settings.setValue(u'add song from service', QtCore.QVariant(self.update_load))
settings.endGroup()