From 68b38aa88c96f1b800b3cbc55c2229c3400e6d86 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 30 Sep 2010 18:07:27 +0100 Subject: [PATCH 1/6] fix up rest of service load updates --- openlp/core/lib/serviceitem.py | 10 +++++++++- openlp/core/ui/servicemanager.py | 4 ++++ openlp/plugins/songs/lib/mediaitem.py | 22 +++++++++++++++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 17508e274..b4dc263e9 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -102,6 +102,8 @@ class ServiceItem(object): self.footer = None self.bg_image_bytes = None self._new_item() + self.search_string = u'' + self.data_string = u'' def _new_item(self): """ @@ -259,7 +261,9 @@ class ServiceItem(object): u'audit':self.audit, u'notes':self.notes, u'from_plugin':self.from_plugin, - u'capabilities':self.capabilities + u'capabilities':self.capabilities, + u'search':self.search_string, + u'data':self.data_string } service_data = [] if self.service_item_type == ServiceItemType.Text: @@ -297,6 +301,10 @@ class ServiceItem(object): self.notes = header[u'notes'] self.from_plugin = header[u'from_plugin'] self.capabilities = header[u'capabilities'] + # Added later so may not be present in older services. + if u'search' in header: + self.search_string = header[u'search'] + self.data_string = header[u'data'] if self.service_item_type == ServiceItemType.Text: for slide in serviceitem[u'serviceitem'][u'data']: self._raw_frames.append(slide) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 521be71a6..9ae90580a 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -810,9 +810,13 @@ class ServiceManager(QtGui.QWidget): """ Triggered from plugins to update service items. """ + editId, uuid = message.split(u':') print message for item in self.serviceItems: print item[u'service_item'].title, item[u'service_item']._uuid + if item[u'service_item']._uuid == uuid: + print u'match' + item[u'service_item'].editId = editId def addServiceItem(self, item, rebuild=False, expand=True, replace=False): """ diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index c1ca57227..29e105bdc 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -372,11 +372,31 @@ class SongMediaItem(MediaManagerItem): service_item.audit = [ song.title, author_audit, song.copyright, unicode(song.ccli_number) ] + service_item.data_string = {u'title':song.search_title, u'authors':author_list} return True def serviceLoad(self, item): """ Triggered by a song being loaded by the service item """ - Receiver.send_message(u'service_item_update', u'0:0') + print item.data_string[u'title'].split(u'@')[0] + search_results = self.parent.manager.get_all_objects(Song, + Song.search_title.like(u'%' + item.data_string[u'title'].split(u'@')[0] + u'%'), + Song.search_title.asc()) + print item.data_string[u'authors'].split(u',') + author_list = item.data_string[u'authors'].split(u',') + editId = 0 + uuid = 0 + if search_results: + for song in search_results: + count = 0 + for author in song.authors: + if author.display_name in author_list: + count += 1 + if count == len(author_list): + editId = song.id + uuid = item._uuid + if editId != 0: + Receiver.send_message(u'service_item_update', + u'%s:%s' %(editId, uuid)) From 4d3a473e91683e92b0937bdbc9bfbec91bb1d964 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 30 Sep 2010 21:21:45 +0100 Subject: [PATCH 2/6] Service Manager loading - finished --- openlp/core/ui/servicemanager.py | 3 --- openlp/plugins/songs/lib/mediaitem.py | 39 +++++++++++++-------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 9ae90580a..818a83c84 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -811,11 +811,8 @@ class ServiceManager(QtGui.QWidget): Triggered from plugins to update service items. """ editId, uuid = message.split(u':') - print message for item in self.serviceItems: - print item[u'service_item'].title, item[u'service_item']._uuid if item[u'service_item']._uuid == uuid: - print u'match' item[u'service_item'].editId = editId def addServiceItem(self, item, rebuild=False, expand=True, replace=False): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 29e105bdc..078741ca7 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -379,24 +379,23 @@ class SongMediaItem(MediaManagerItem): """ Triggered by a song being loaded by the service item """ - print item.data_string[u'title'].split(u'@')[0] - search_results = self.parent.manager.get_all_objects(Song, - Song.search_title.like(u'%' + item.data_string[u'title'].split(u'@')[0] + u'%'), - Song.search_title.asc()) - print item.data_string[u'authors'].split(u',') - author_list = item.data_string[u'authors'].split(u',') - editId = 0 - uuid = 0 - if search_results: - for song in search_results: - count = 0 - for author in song.authors: - if author.display_name in author_list: - count += 1 - if count == len(author_list): - editId = song.id - uuid = item._uuid - if editId != 0: - Receiver.send_message(u'service_item_update', - u'%s:%s' %(editId, uuid)) + if item.data_string: + search_results = self.parent.manager.get_all_objects(Song, + Song.search_title.like(u'%' + item.data_string[u'title'].split(u'@')[0] + u'%'), + Song.search_title.asc()) + author_list = item.data_string[u'authors'].split(u',') + editId = 0 + uuid = 0 + if search_results: + for song in search_results: + count = 0 + for author in song.authors: + if author.display_name in author_list: + count += 1 + if count == len(author_list): + editId = song.id + uuid = item._uuid + if editId != 0: + Receiver.send_message(u'service_item_update', + u'%s:%s' %(editId, uuid)) From 7863a2ebfca914e2c1102845cfed78ccf2aa333e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 6 Oct 2010 20:27:30 +0100 Subject: [PATCH 3/6] Add Service Item update from edit with config flag --- openlp/core/lib/mediamanageritem.py | 6 ++-- openlp/core/ui/servicemanager.py | 15 ++++++++++ openlp/plugins/songs/lib/mediaitem.py | 30 +++++++++++++++---- openlp/plugins/songs/lib/songstab.py | 42 +++++++++++++++++++++++++-- 4 files changed, 81 insertions(+), 12 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 9528b7895..457249b35 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -474,8 +474,8 @@ class MediaManagerItem(QtGui.QWidget): translate('OpenLP.MediaManagerItem', 'You must select one or more items.')) else: - #Is it posssible to process multiple list items to generate multiple - #service items? + # Is it posssible to process multiple list items to generate multiple + # service items? if self.singleServiceItem or self.remoteTriggered: log.debug(self.plugin.name + u' Add requested') service_item = self.buildServiceItem() @@ -504,7 +504,7 @@ class MediaManagerItem(QtGui.QWidget): log.debug(self.plugin.name + u' Add requested') service_item = self.parent.serviceManager.getServiceItem() if not service_item: - QtGui.QMessageBox.information(self, + QtGui.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'No Service Item Selected'), translate('OpenLP.MediaManagerItem', diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 818a83c84..6d02299c3 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -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 diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 232406c57..ce1d89ca2 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -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 - #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. + + 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_() diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index 39a53f1c6..e79a455aa 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -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() From 16b4aa0715cfbcd8139aa944969c3afbadc25d8a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 6 Oct 2010 21:10:26 +0100 Subject: [PATCH 4/6] fix line lenght --- openlp/plugins/songs/lib/mediaitem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index ce1d89ca2..b71201386 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -397,7 +397,8 @@ class SongMediaItem(MediaManagerItem): """ if item.data_string: search_results = self.parent.manager.get_all_objects(Song, - Song.search_title.like(u'%' + item.data_string[u'title'].split(u'@')[0] + u'%'), + Song.search_title.like(u'%' + + item.data_string[u'title'].split(u'@')[0] + u'%'), Song.search_title.asc()) author_list = item.data_string[u'authors'].split(u',') editId = 0 From c262d9ad7599c9955e29944f4251f87272dd0f91 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 6 Oct 2010 21:24:53 +0100 Subject: [PATCH 5/6] Fix remote edit issue --- openlp/plugins/songs/lib/mediaitem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index b71201386..b50005486 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -200,7 +200,8 @@ class SongMediaItem(MediaManagerItem): if self.remoteTriggered == u'P': self.onPreviewClick() # Push edits to the service manager to update items - if self.editItem and self.updateServiceOnEdit: + if self.editItem and self.updateServiceOnEdit and \ + not self.remoteTriggered: item = self.buildServiceItem(self.editItem) self.parent.serviceManager.replaceServiceItem(item) self.onRemoteEditClear() From bccc3c56ca063574d9de724e61138819304f96ab Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 6 Oct 2010 21:30:49 +0100 Subject: [PATCH 6/6] Fix text issues --- openlp/core/ui/servicemanager.py | 2 +- openlp/plugins/songs/lib/songstab.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 6d02299c3..d751b76be 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -830,7 +830,7 @@ class ServiceManager(QtGui.QWidget): self.parent.LiveController.replaceServiceManagerItem(newItem) self.parent.serviceChanged(False, self.serviceName) - def addServiceItem(self, item, rebuild=False, expand=True, replace=False): + def addServiceItem(self, item, rebuild=False, expand=False, replace=False): """ Add a Service item to the list diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index e79a455aa..03c1e8844 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -84,7 +84,7 @@ class SongsTab(SettingsTab): self.SongUpdateOnEditCheckBox.setText( translate('SongsPlugin.SongsTab', 'Update service from song edit')) self.SongAddFromServiceCheckBox.setText(translate('SongsPlugin.SongsTab', - 'Add songs from service being Loaded')) + 'Add missing songs when opening service')) def onSearchAsTypeCheckBoxChanged(self, check_state): self.song_search = False