Fix - do not save temporary key by formatting tags into openlp configuration

This commit is contained in:
Martin Zibricky 2011-09-22 22:30:15 +02:00
parent 8b6887036b
commit 354bec8b33
3 changed files with 11 additions and 4 deletions

View File

@ -56,7 +56,7 @@ class FormattingTags(object):
Resets the html_expands list.
"""
temporary_tags = [tag for tag in FormattingTags.html_expands
if tag[u'temporary']]
if tag.get(u'temporary')]
FormattingTags.html_expands = []
base_tags = []
# Append the base tags.
@ -148,8 +148,12 @@ class FormattingTags(object):
"""
tags = []
for tag in FormattingTags.html_expands:
if not tag[u'protected'] and not tag[u'temporary']:
if not tag[u'protected'] and not tag.get(u'temporary'):
tags.append(tag)
# Remove key 'temporary' from tags. It is not needed to be saved.
for tag in tags:
if u'temporary' in tag:
del tag[u'temporary']
# Formatting Tags were also known as display tags.
QtCore.QSettings().setValue(u'displayTags/html_tags',
QtCore.QVariant(cPickle.dumps(tags) if tags else u''))

View File

@ -177,7 +177,7 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog):
QtGui.QTableWidgetItem(html[u'start html']))
self.tagTableWidget.setItem(linenumber, 3,
QtGui.QTableWidgetItem(html[u'end html']))
# Tags saved prior to 1.9.7 do not have this key.
# Permanent (persistent) tags do not have this key.
if u'temporary' not in html:
html[u'temporary'] = False
self.tagTableWidget.resizeRowsToContents()

View File

@ -562,8 +562,11 @@ class OpenLyrics(object):
# Some tags have only start html e.g. {br}
u'end html': tag.close.text if hasattr(tag, 'close') else u'',
u'protected': False,
u'temporary': temporary
}
# Add 'temporary' key in case the formatting tag should not be
# saved otherwise it is supposed that formatting tag is permanent.
if temporary:
openlp_tag[u'temporary'] = temporary
found_tags.append(openlp_tag)
existing_tag_ids = [tag[u'start tag']
for tag in FormattingTags.get_html_tags()]