From 354bec8b33c8c7de68d28a5250cf59acd381a0ee Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Thu, 22 Sep 2011 22:30:15 +0200 Subject: [PATCH] Fix - do not save temporary key by formatting tags into openlp configuration --- openlp/core/lib/formattingtags.py | 8 ++++++-- openlp/core/ui/formattingtagform.py | 2 +- openlp/plugins/songs/lib/xml.py | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index 6a0013635..ea5547f27 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -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'')) diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index df2c3d673..a08b004ca 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -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() diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 4a0ebc6af..d9aafd23f 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -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()]