From 953ff87ff58c01424a13bf0356b259f3daed1552 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 26 Aug 2011 17:06:22 +0200 Subject: [PATCH] do not delete temporary tags when resetting the list; preparations --- openlp/core/lib/formattingtags.py | 3 +++ openlp/plugins/songs/lib/mediaitem.py | 3 +++ openlp/plugins/songs/lib/xml.py | 11 ++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index 8230da36a..bb4c0bcc8 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -49,6 +49,8 @@ class FormattingTags(object): """ Resets the html_expands list. """ + temporary_tags = [tag for tag in FormattingTags.html_expands + if tag[u'temporary']] FormattingTags.html_expands = [] base_tags = [] # Append the base tags. @@ -131,6 +133,7 @@ class FormattingTags(object): u'start tag': u'{br}', u'start html': u'
', u'end tag': u'', u'end html': u'', u'protected': True, u'temporary': False}) FormattingTags.add_html_tags(base_tags) + FormattingTags.add_html_tags(temporary_tags) @staticmethod def add_html_tags(tags): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index a2814a1df..b1a5f3572 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -513,6 +513,9 @@ class SongMediaItem(MediaManagerItem): if add_song and self.addSongFromService: editId = self.openLyrics.xml_to_song(item.xml_version) self.onSearchTextButtonClick() + else: + # Make sure we temporary import formatting tags. + self.openLyrics.xml_to_song(item.xml_version, False) # Update service with correct song id. if editId: Receiver.send_message(u'service_item_update', diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index c6dd90c03..79b0bc986 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -322,7 +322,7 @@ class OpenLyrics(object): self._add_text_to_element(u'line', lines_element, line) return self._extract_xml(song_xml) - def xml_to_song(self, xml): + def xml_to_song(self, xml, save_to_db=True): """ Create and save a song from OpenLyrics format xml to the database. Since we also export XML from external sources (e. g. OpenLyrics import), we @@ -330,6 +330,10 @@ class OpenLyrics(object): ``xml`` The XML to parse (unicode). + + ``save_to_db`` + Switch to prevent storing songs to the database. Defaults to + ``True``. """ # No xml get out of here. if not xml: @@ -356,8 +360,9 @@ class OpenLyrics(object): self._process_songbooks(properties, song) self._process_topics(properties, song) clean_song(self.manager, song) - self.manager.save_object(song) - return song.id + if save_to_db: + self.manager.save_object(song) + return song.id def _add_text_to_element(self, tag, parent, text=None, label=None): if label: