From cc9ef10821f67a7e5493d36c21fbdca422ab856c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 29 Nov 2010 16:02:41 +0000 Subject: [PATCH] Songs get created correctly and displays refreshed --- openlp/core/ui/servicemanager.py | 2 ++ openlp/plugins/songs/forms/editsongform.py | 7 +++++-- openlp/plugins/songs/lib/mediaitem.py | 11 ++++++----- openlp/plugins/songs/lib/xml.py | 23 +++++++++++++++------- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 454819f32..6d721823a 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -789,6 +789,8 @@ class ServiceManager(QtGui.QWidget): self.serviceName = name[len(name) - 1] self.parent.addRecentFile(filename) self.parent.serviceChanged(True, self.serviceName) + # Refresh Plugin lists + Receiver.send_message(u'plugin_list_refresh') def validateItem(self, serviceItem): """ diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 8c92583d5..c9868d2e3 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -636,8 +636,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.song.title = unicode(self.TitleEditItem.text()) self.song.alternate_title = unicode(self.AlternativeEdit.text()) self.song.copyright = unicode(self.CopyrightEditItem.text()) - self.song.search_title = self.song.title + u'@' + \ - self.song.alternate_title + if self.song.alternate_title: + self.song.search_title = self.song.title + u'@' + \ + self.song.alternate_title + else: + self.song.search_title = self.song.title self.song.comments = unicode(self.CommentsEdit.toPlainText()) self.song.verse_order = unicode(self.VerseOrderEdit.text()) self.song.ccli_number = unicode(self.CCLNumberEdit.text()) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 2ffa096a6..432eee744 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -114,6 +114,8 @@ class SongMediaItem(MediaManagerItem): self.SearchButtonLayout.addWidget(self.ClearTextButton) self.pageLayout.addLayout(self.SearchButtonLayout) # Signals and slots + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'plugin_list_refresh'), self.onSearchTextButtonClick) QtCore.QObject.connect(self.SearchTextEdit, QtCore.SIGNAL(u'returnPressed()'), self.onSearchTextButtonClick) QtCore.QObject.connect(self.SearchTextButton, @@ -397,7 +399,6 @@ class SongMediaItem(MediaManagerItem): ] service_item.data_string = {u'title':song.search_title, u'authors':author_list} - # if xmlVersion: service_item.xml_version = self.openLyrics.song_to_xml(song) return True @@ -408,8 +409,8 @@ class SongMediaItem(MediaManagerItem): log.debug(u'serviceLoad') 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 == + item.data_string[u'title'].split(u'@')[0].lower() , Song.search_title.asc()) author_list = item.data_string[u'authors'].split(u', ') editId = 0 @@ -427,11 +428,11 @@ class SongMediaItem(MediaManagerItem): # Authors different if self.addSongFromService: editId = self.openLyrics. \ - xmlToSong(item.xml_version) + xml_to_song(item.xml_version) else: # Title does not match if self.addSongFromService: - editId = self.openLyrics.xmlToSong(item.xml_version) + editId = self.openLyrics.xml_to_song(item.xml_version) # Update service with correct song id if editId != 0: Receiver.send_message(u'service_item_update', diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index f5f285396..2d9855ca8 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -281,14 +281,15 @@ class OpenLyricsParser(object): element = self._add_text_to_element(u'lines', element) for line in unicode(verse[1]).split(u'\n'): self._add_text_to_element(u'line', element, line) - print self._dump_xml(song_xml) - self.xml_to_song(self._extract_xml(song_xml)) - return u'' #self.xml_to_song(self._extract_xml(song_xml)) + return self._extract_xml(song_xml) def xml_to_song(self, xml): """ Create a Song from OpenLyrics format xml """ + # No xml get out of here + if not xml: + return 0 song = Song() if xml[:5] == u'