forked from openlp/openlp
do not delete temporary tags when resetting the list; preparations
This commit is contained in:
parent
627b9429aa
commit
953ff87ff5
@ -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'<br>', 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):
|
||||
|
@ -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',
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user